fork download
  1. function checkURL(u, cx) {
  2. var hr = createPresetRequest(u);
  3. var s1 = hr.getContentsAsString();
  4. if (s1) {
  5. // MIMEタイプが画像以外の場合はスクリプトで処理しない
  6. if (!s1.match('<b>MIME</b></span><span class="right">image/(jpeg|png|bmp|gif|vnd\\.wap\\.wbmp)</span>')) {
  7. v2c.browseURLDefExt(u);
  8. cx.applyImageViewURLReplace = false;
  9. return '';
  10. }
  11. // パスワードが何も入力されてないときポップアップ表示で入力させる
  12. var matches = '';
  13. if (matches = /キーワード: <input size="20" type="text" name="keyword" value="([^"]+)?">/i.exec(s1)) {
  14. var pass = '';
  15. if (matches.length > 1 && typeof(matches[1]) != 'undefined' && matches[1] !== '') {
  16. pass = matches[1];
  17. } else {
  18. pass = v2c.prompt('画像表示 ('+ u +')\nこの画像にはパスワードが設定されています。\n2分以内にパスワードを入力して下さい。', '');
  19. }
  20. }
  21. var sid = s1.match('<input type="hidden" name="sid" value="(\\d+)">')[1];
  22. var dqn = s1.match('<input type="hidden" name="dqn" value="(\\d+)">')[1];
  23. var param = 'sid=' + sid + '&dqn=' + dqn;
  24. if (pass) { param += '&keyword=' + pass; }
  25. param += '&origfilename=1&attachement=1';
  26. var cookie = cookieGen(hr.getResponseHeader('Set-Cookie'));
  27. var u2 = new java.net.URL('http://' + u.getHost().toString() + '/uploader/dl.pl');
  28. hr = createPresetRequest(u2, param);
  29. hr.setRequestProperty("Host", u.getHost());
  30. hr.setRequestProperty("Referer", u);
  31. hr.setRequestProperty("Content-Length", java.lang.Integer.valueOf(param.length - 1));
  32. hr.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
  33. hr.setRequestProperty("Cookie", cookie);
  34. s1 = hr.getContentsAsString();
  35. if (s1 && s1.match('<a href="\\./(link\\.pl?[^"]+)">')) {
  36. u2 = new java.net.URL('http://' + u2.getHost() + '/uploader/' + RegExp.$1);
  37. cookie = cookieGen(hr.getResponseHeader('Set-Cookie'));
  38. hr = createPresetRequest(u2);
  39. hr.setRequestProperty("Host", u2.getHost());
  40. hr.setRequestProperty("Cookie", cookie);
  41. s1 = hr.getContentsAsString();
  42. if (s1 && s1.match('<meta http-equiv="refresh" CONTENT="3; URL=([^"]+)')) {
  43. u = RegExp.$1;
  44. cx.applyImageViewURLReplace = false;
  45. cx.setRequestProperty("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8");
  46. cx.setRequestProperty("Accept-Language", "ja,en-us;q=0.7,en;q=0.3");
  47. cx.setRequestProperty("Accept-Encoding", "gzip, deflate");
  48. cx.setRequestProperty("Connection", "keep-alive");
  49. cx.setRequestProperty("Host", u2.getHost());
  50. cx.setRequestProperty("Referer", u2);
  51. cx.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 6.1; rv:19.0) Gecko/20100101 Firefox/19.0");
  52. cx.setRequestProperty('Cookie', cookie);
  53. }
  54. }
  55. }
  56. return u;
  57. }
  58. function createPresetRequest(u)
  59. {
  60. var hr;
  61. if (arguments.length > 1) { hr = v2c.createHttpRequest(u, arguments[1]); }
  62. else { hr = v2c.createHttpRequest(u); }
  63. hr.setRequestProperty("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8");
  64. hr.setRequestProperty("Accept-Language", "ja,en-us;q=0.7,en;q=0.3");
  65. hr.setRequestProperty("Accept-Encoding", "gzip, deflate");
  66. hr.setRequestProperty("Connection", "keep-alive");
  67. hr.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 6.1; rv:19.0) Gecko/20100101 Firefox/19.0");
  68. return hr;
  69. }
  70. function cookieGen(c)
  71. {
  72. var ret = '';
  73. ret = (c.match('(u_ses=\\d+;)'))? RegExp.$1 : '';
  74. ret += (c.match('(dl_n=\\d+;)'))? ' '+ RegExp.$1 : '';
  75. return ret;
  76. }
Not running #stdin #stdout 0s 0KB
stdin
Standard input is empty
stdout
Standard output is empty