fork(2) download
  1. //【登録場所】リンク
  2. //【ラベル】
  3. // SearchExmodoki.js $LINK 1のときは「二次元画像検索」
  4. // SearchExmodoki.js $LINK 2のときは「画像情報検索サイト」
  5. // SearchExmodoki.js $LINK 3のときは「booru系類似画像検索」
  6. // SearchExmodoki.js $LINK 4のときは「Google画像検索」
  7. // SearchExmodoki.js $LINK 5 // kemuri-net.com (ポップアップ)
  8. // SearchExmodoki.js $LINK 6 // kemuri-net-.com (ブラウザ)
  9. //
  10. //【内容】linkをPOSTして、httprequestで返されたlocationをブラウザで開いたり、ブラウザに成形済みのURIを送ったり
  11. // 1 = 二次元画像検索(http://w...content-available-to-author-only...d.net/imagesearch)
  12. // 2 = 画像情報検索サイト(http://i...content-available-to-author-only...o.jp)
  13. // 3 = booru系類似画像検索(http://i...content-available-to-author-only...b.org)
  14. // << メモ >>
  15. // 2と3は、[HTTP/1.1 200 OK]の場合の対象方法が不明なためPOST用のURLを直接ブラウザで開く処理になってます
  16. //
  17. //【コマンド1】${SCRIPT:SF} SearchExmodoki.js $LINK 1 // 二次元画像検索
  18. //【コマンド2】${SCRIPT:SF} SearchExmodoki.js $LINK 2 // 画像情報検索サイト
  19. //【コマンド3】${SCRIPT:SF} SearchExmodoki.js $LINK 3 // booru系類似画像検索
  20. //【コマンド4】${SCRIPT:SF} SearchExmodoki.js $LINK 4 // Google画像検索 (SearchByImage)
  21. //【コマンド4】${SCRIPT:SF} SearchExmodoki.js $LINK 5 // kemuri-net.com (ポップアップ)
  22. //【コマンド4】${SCRIPT:SF} SearchExmodoki.js $LINK 6 // kemuri-net-.com (ブラウザ)
  23. //
  24. //【更新日】2011/04/28 (改変 4~6追加 2013/01/13)
  25. //【スクリプト】SearchExmodoki.js
  26. //
  27. var tmpdir = v2c.getScriptSubFile('dummy.txt');
  28. if (!tmpdir.exists()) { v2c.writeStringToFile(tmpdir, 'dummy'); }
  29. tmpdir = tmpdir.getParent();
  30.  
  31. var vcx = v2c.context;
  32. var link = vcx.link; // arg[0]でもOK?
  33. var args = v2c.context.args[1];
  34. var url = beforeRedirect(encodeURIComponent(link), args);
  35. if (!(url == "")) { v2c.browseURLExt(url); }
  36.  
  37. function beforeRedirect(data, si) {
  38. var hr;
  39. if (si == 2) {
  40. // 画像情報検索サイト
  41. return "http://i...content-available-to-author-only...o.jp/front.php?mode=1&url="+data+"?Shift_JIS?POST";
  42. } else if (si == 3) {
  43. // booru系類似画像検索
  44. return "http://i...content-available-to-author-only...b.org/?url="+data+"?UTF-8?POST";
  45. } else if (si == 4) {
  46. return "http://w...content-available-to-author-only...o.jp/searchbyimage?image_url="+data;
  47. } else if (si == 5) {
  48. var url = new java.net.URL("http://d...content-available-to-author-only...t.com/hashsearch.php");
  49. hr = v2c.createHttpRequest(url);
  50. hr.setRequestProperty("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8");
  51. hr.setRequestProperty("Accept-Language", "ja,en-us;q=0.7,en;q=0.3");
  52. hr.setRequestProperty("Host", "details.kemuri-net.com");
  53. hr.setRequestProperty("Accept-Encoding", "gzip, deflate");
  54. hr.setRequestProperty("Connection", "keep-alive");
  55. hr.setRequestProperty("User-Agent", "Mozilla/5.0");
  56. var str = hr.getContentsAsString();
  57. var cookie = hr.getResponseHeader('Set-Cookie');
  58. var auth = '';
  59. with (JavaImporter(Packages.java.util.regex.Pattern)) {
  60. var ptn2 = Pattern.compile('<input[^>]*name="authentication" value[ ]?=[\'"](.+)[\'"]', Pattern.CASE_INSENSITIVE);
  61. var m = ptn2.matcher(str);
  62. if (Boolean(m.find())) {
  63. auth = m.group(1);
  64. }
  65. }
  66. var encode_prm = java.net.URLDecoder.decode("q=" + data + "&mode=0&authentication=" + auth + "&search=1","utf-8");
  67. hr = v2c.createHttpRequest(url, encode_prm);
  68. hr.setRequestProperty("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8");
  69. hr.setRequestProperty("Accept-Language", "ja,en-us;q=0.7,en;q=0.3");
  70. hr.setRequestProperty("Host", "details.kemuri-net.com");
  71. hr.setRequestProperty("Referer", url.toString());
  72. hr.setRequestProperty("Accept-Encoding", "gzip, deflate");
  73. hr.setRequestProperty("Connection", "close");
  74. hr.setRequestProperty("User-Agent", "Mozilla/5.0");
  75. hr.setRequestProperty("Cookie", cookie);
  76. str = String(hr.getContentsAsString());
  77. str = str.substring(str.indexOf('<table border="1" width="800" cellspacing="0">'), str.indexOf('<br><HR><P align="right">'));
  78.  
  79. var b64 = new base64();
  80. var i = 0;
  81. var matches = [];
  82. while (/(<img src="data:image\/(jpg|png|bmp|gif);base64,([A-Za-z0-9+\/=]+)")/g.exec(str) != null) {
  83. var src = RegExp.$1;
  84. var img = b64.decode(RegExp.$3);
  85.  
  86. var f = v2c.getScriptSubFile(i + '.tmp');
  87. v2c.writeBytesToFile(f, img);
  88. var imgstr = '<img src="' + (new java.net.URL('file:///' + tmpdir + '/' + i + '.tmp')).toString() + '"';
  89. matches.push([src, imgstr]);
  90. i++;
  91. }
  92. for (i = 0; i < matches.length; i++) {
  93. str = str.replace(matches[i][0], matches[i][1]);
  94. }
  95. str = str.split('<A href="./').join('<A href="http://d...content-available-to-author-only...t.com/');
  96. vcx.setPopupHTML('<html><body style="margin:10px;">' + str + '</body></html>');
  97. return "";
  98. } else if (si == 6) {
  99. return "http://d...content-available-to-author-only...t.com/shashsearch.php" + "?a=&c=UTF-8&o=JANEVIEW&q=" + data;
  100. } else {
  101. // 二次元画像検索
  102. hr = v2c.createHttpRequest("http://w...content-available-to-author-only...d.net/imagesearch/search?uri="+data+"?UTF-8?POST", "");
  103. hr.setRequestProperty("Referer", "http://w...content-available-to-author-only...d.net/imagesearch");
  104. hr.getContentsAsString();
  105. if (hr.responseCode >= 301 && 303 >= hr.responseCode) {
  106. return hr.getResponseHeader("Location");
  107. } else {
  108. return "";
  109. }
  110. }
  111. }
  112.  
  113. /* Powered by kerry ( http://202.248.69.143/~goma/ ) */
  114. function base64()
  115. {
  116. var b64char = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
  117. var b64encTable = b64char.split("");
  118. var b64decTable = [];
  119. for (var i = 0; i < b64char.length; i++) b64decTable[b64char.charAt(i)] = i;
  120.  
  121. this.encode = function(_ary) {
  122. var md = _ary.length % 3;
  123. var b64 = "";
  124. var i, tmp = 0;
  125. if (md) for (i = 3 - md; i > 0; i--) _ary[_ary.length] = 0;
  126. for (i = 0; i < _ary.length; i += 3) {
  127. tmp = (_ary[i] << 16) | (_ary[i + i] << 8) | _ary[ i + 2];
  128. b64 += b64encTable[ (tmp >>> 18) & 0x3f]
  129. + b64encTable[ (tmp >>> 12) & 0x3f]
  130. + b64encTable[ (tmp >>> 6) & 0x3f]
  131. + b64encTable[ tmp & 0x3f];
  132. }
  133. if (md) { // 3の倍数にパディングした 0x0 分 = に置き換え
  134. md = 3 - md;
  135. b64 = b64.substr(0, b64.length - md);
  136. while (md--) b64 += "=";
  137. }
  138. return b64;
  139. };
  140.  
  141. this.decode = function(_b64) {
  142. _b64 = _b64.replace(/[^A-Za-z0-9\+\/]/g, "");
  143. var md = _b64.length % 4;
  144. var j, i, tmp;
  145. var dat = [];
  146.  
  147. // replace 時 = も削っている。その = の代わりに 0x0 を補間
  148. if (md) for (i=0; i<4-md; i++) _b64 += "A";
  149.  
  150. for (j=i=0; i<_b64.length; i+=4, j+=3)
  151. {
  152. tmp = (b64decTable[_b64.charAt( i )] <<18)
  153. | (b64decTable[_b64.charAt(i+1)] <<12)
  154. | (b64decTable[_b64.charAt(i+2)] << 6)
  155. | b64decTable[_b64.charAt(i+3)];
  156. dat[ j ] = tmp >>> 16;
  157. dat[j+1] = (tmp >>> 8) & 0xff;
  158. dat[j+2] = tmp & 0xff;
  159. }
  160. // 補完された 0x0 分削る
  161. if (md) dat.length -= [0,0,2,1][md];
  162. var jdat = java.lang.reflect.Array.newInstance(java.lang.Byte.TYPE, dat.length);
  163. for (i = 0; i < dat.length; i++) {
  164. jdat[i] = convSigned(dat[i]);
  165. }
  166. return jdat;
  167. }
  168. function convSigned(n) {
  169. return (n & (1 << 7))? -((~n & 0xFF) + 1) : n;
  170. }
  171. }
  172.  
  173. function getMD5(stringORbytesArray)
  174. {
  175. if (typeof stringORbytesArray == 'string' || stringORbytesArray instanceof String) {
  176. stringORbytesArray = (new java.lang.String(stringORbytesArray)).getBytes();
  177. }
  178. var m = new java.security.MessageDigest.getInstance("MD5");
  179. m.reset();
  180. var hash = m.digest(stringORbytesArray);
  181. var sb = new java.lang.StringBuffer(hash.length * 2);
  182. for ( var i = 0; i < hash.length; i++) {
  183. var b = java.lang.Integer.toHexString(hash[i] & 0xff);
  184. if (b.length() == 1) {
  185. sb.append(b);
  186. }
  187. }
  188. return sb.toString();
  189. }
  190.  
Runtime error #stdin #stdout 0.49s 382976KB
stdin
Standard input is empty
stdout
Standard output is empty