Create Download Links for HACG

琉璃神社神秘代码转换成下载链接

  1. // ==UserScript==
  2. // @name Create Download Links for HACG
  3. // @namespace https://greasyfork.org/zh-CN/scripts/7762
  4. // @description 琉璃神社神秘代码转换成下载链接
  5. // @author 天涯倦客
  6. // @supportURL http://t.qq.com/HeartBlade
  7. // @include http*://www.hacg.*/wordpress/*
  8. // @include http*://hacg.*/wordpress/*
  9. // @include http*://www.hacg.*/wp/*
  10. // @include http*://hacg.*/wp/*
  11. // @include http://pan.baidu.com/share/*
  12. // @include http://pan.baidu.com/s/*
  13. // @include http://www.llss.me/wp/*
  14. // @include https://www.llss.fun/wp/*
  15. // @include http://www.llss.fun/wp/*
  16. // @include https://www.llss.pw/wp/*
  17. // @version 3.08
  18. // @grant none
  19. // ==/UserScript==
  20. (function(){
  21. //度盘填充提取码
  22. if(/baidu/.test(location.href)&&location.hash.slice(1).length!=0){
  23. document.querySelector("#accessCode").value=decodeURI (location.hash.slice(1));
  24. //document.querySelector("#submitBtn").click();
  25. requestToken();
  26. }
  27. var i;
  28. //防爆补丁
  29. var feiZao=document.getElementsByTagName("p1");
  30. var fZLength=feiZao.length;
  31. if (!!fZLength){
  32. for (i=0;i<fZLength;i++){
  33. feiZao[0].parentNode.removeChild(feiZao[0]);
  34. }
  35. }
  36. //老司机
  37. var oldDriver = document.getElementsByClassName('entry-content')[0];
  38. var regObj={ //用于匹配的正则
  39. btih:/(?:[^\/=\|])(([a-fA-F0-9]{40})|(\w{32}))/g,
  40. bdshare:/b?\/s\/(\w{8})(?:\s+(\w{4}))?(?![\">])/g, //度娘 类型:/s/1i31aCbb b/s/1i31aCbb >>>其后非?!xxx
  41. howfile:/@?(?:HF|howfile)\/file\/(\w{4,10})\/(\w{8,})\/?/gi, //好盘 类型I:@HF/file/61dbeea7/0c7f2f56/ @howfile/file/61dbeea7/0c7f2f56/
  42. tcn:/\bt\/(\w{7})/g, //t.cn短链接 类型I:t/RZEWYLu
  43. yyw:/(\/lb\/)?(5lb[a-zA-Z0-9]{8,12})/g, //115礼包:/lb/5lbeo3p8eh02
  44. mega:/(?:\.co)?(\.nz\/(#[\w!-]{22,}))/g //.co.nz/#!AZcSmbJA!Q5ZbtIDoQecZc_3Cmc2v_vMaLFJRO6Ctd7uaWdWKqK0
  45. //.nz/#F!Cw9HSQCR!GgOIg9e9FNQGSplRDNxWDw
  46. };
  47. var linkArr=[]; //用于替换的链接
  48. //linkArr.btih='<a href="magnet:?xt=urn:btih:$1$2">磁链:$1$2</a>';
  49. linkArr.btih='';//未定义
  50. linkArr.baidu="<a href='http://pan.baidu.com/s/$1#$2' target='_blank'>度娘:$1</a> $2";
  51. linkArr.howf="<a href='http://howfile.com/file/$1/$2/' target='_blank'>好盘:howfile.com/file/$1/$2</a>";
  52. linkArr.tcn="<a href='http://t.cn/$1' target='_blank'>短链:t.cn/$1</a>";
  53. linkArr.yyw="<a href='http://115.com/lb/$2' target='_blank'>115礼包:$2</a> ";
  54. linkArr.mega="<a href='https://mega.co$1' target='_blank'>MEGA网盘:$2</a>";
  55. var txt=oldDriver.innerHTML.toString();
  56. //磁链
  57. function hashFunc(hash){ //hash操作
  58. hashWord=hash.match(/^\W*/g)[0];
  59. hash=hash.replace(/[\s\W]*/g, "").toUpperCase();
  60. console.log("hash="+hash);
  61. hashStart=hash.slice(0,2);
  62. hashEnd=hash.slice(-2);
  63. return [hashStart,hashEnd,hash,hashWord];
  64. }
  65.  
  66. if(regObj.btih.test(txt)){
  67. var magH=txt.match(regObj.btih);
  68. for (j=0;j<magH.length;j++){
  69. linkArr.btih=hashFunc(magH[j])[3]+'<a href="magnet:?xt=urn:btih:'+hashFunc(magH[j])[2]+'" >磁力链接 </a>';
  70. linkArr.btih+=' →<a href="http://www.torrent.org.cn/Home/Convert/magnet2torrent.html?hash='+hashFunc(magH[j])[2]+'" target="_blank" title="需要先注册登陆">【下载种子】</a>';
  71. //linkArr.btih+=' <a href="http://www.btaia.com/torrent/detail/hash/'+hashFunc(magH[j])[2]+'" target="_blank" title="支持Base32,可查看种子内容,需要验证码,长期Invalid CAPTCHA token">【种子详情】</a>';
  72.  
  73. txt=txt.replace(magH[j],linkArr.btih)
  74. }
  75. }
  76.  
  77. //度娘
  78. txt=txt.replace(regObj.bdshare,linkArr.baidu);
  79. //好盘
  80. txt=txt.replace(regObj.howfile,linkArr.howf);
  81. //短链接
  82. txt=txt.replace(regObj.tcn,linkArr.tcn);
  83. //115
  84. txt=txt.replace(regObj.yyw,linkArr.yyw);
  85. //mega
  86. txt=txt.replace(regObj.mega,linkArr.mega);
  87. oldDriver.innerHTML=txt;
  88. //手动转换文本框
  89. var oD_box=document.createElement("div");
  90. oD_box.id="oD_box";
  91. oD_box.style="position:fixed;top:10px;right:10px; width:210px;";
  92. var oD_text=document.createElement("input");
  93. oD_text.id="oD_text";
  94. oD_text.type="text";
  95. oD_text.placeholder="粘贴hash值";
  96. oD_text.title='将自动添加"magnet:?xt=urn:btih:",去除[]中的内容、非字母数字字符、空格';
  97. var oD_button=document.createElement("button");
  98. oD_button.id="oD_button";
  99. oD_button.type="button";
  100. oD_button.textContent="开车";
  101. oD_button.style="padding:4px 0; position: relative; top:-1px";
  102. oD_button.onclick=function (){
  103. var oD_hash=oD_text.value.replace(/(\[.*\])|[\W_]/g,"");
  104. if (oD_hash.length!==40&&oD_hash.length!==32){
  105. oD_link.textContent="";
  106. oD_link2.textContent="";
  107. alert("长度错误,请重试");
  108. }else{
  109. oD_link.href="magnet:?xt=urn:btih:"+oD_hash;
  110. oD_link.textContent="磁链";
  111. oD_link2.href="http://www.torrent.org.cn/Home/Convert/magnet2torrent.html?hash="+oD_hash;
  112. oD_link2.textContent="种子";
  113. oD_link2.style="margin-left:20px";
  114. // oD_link3.href="http://www.btaia.com/torrent/detail/hash/"+oD_hash;
  115. // oD_link3.textContent="详情";
  116. // oD_link3.style="margin-left:20px";
  117. }
  118.  
  119. };
  120. var oD_link=document.createElement("a");
  121. var oD_link2=document.createElement("a");
  122. var oD_link3=document.createElement("a");
  123. oD_link2.target="_blank";
  124. oD_link3.target="_blank";
  125. oD_box.appendChild(oD_text);
  126. oD_box.appendChild(oD_button);
  127. oD_box.appendChild(oD_link);
  128. oD_box.appendChild(oD_link2);
  129. oD_box.appendChild(oD_link3);
  130. document.body.appendChild(oD_box);
  131. //评论区度娘、115、tcn
  132. var buDang=document.getElementsByClassName('comment-content');
  133. for (i in buDang){
  134. buDang[i].innerHTML=buDang[i].innerHTML.replace(/\b(\w{8})\b(?:\s*(?:<br>|密码:|密码:|pw:|提取码:)?\s*(\w{4}|8酱)?)/gi,linkArr.baidu).replace(regObj.yyw,linkArr.yyw).replace(regObj.tcn,linkArr.tcn);
  135. }
  136.  
  137. })();