Sleazy Fork is available in English.

Create Download Links for HACG (https)

琉璃神社、灵梦御所、纯爱计划神秘代码转换成下载链接(https版)

Pada tanggal 22 September 2016. Lihat %(latest_version_link).

  1. // ==UserScript==
  2. // @name Create Download Links for HACG (https)
  3. // @namespace hoothin
  4. // @description 琉璃神社、灵梦御所、纯爱计划神秘代码转换成下载链接(https版)
  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*://blog.reimu.net/*
  12. // @include http*://pan.baidu.com/share/*
  13. // @include http*://pan.baidu.com/s/*
  14. // @include http*://sexacg.com/*
  15. // @version 3.19
  16. // @grant none
  17. // @run-at document-end
  18. // ==/UserScript==
  19. (function(){
  20. //度盘填充提取码
  21. if(/baidu/.test(location.href)){
  22. if(location.hash.slice(1)){
  23. document.querySelector("#accessCode").value=location.hash.slice(1);
  24. document.querySelector('#submitBtn').click();
  25. }
  26. return;
  27. }
  28. var codeRule = /(?:提取|访问|密|艾)[码碼]?\s*[:: ]?\s*([a-z\d]{4}|\S*)/i;
  29. if (location.href.indexOf(".reimu.") != -1){
  30. document.querySelector("#main").addEventListener('DOMNodeInserted', function(e) {
  31. var pre = document.querySelector("pre");
  32. if (pre && !document.querySelector("#blockBtn")) {
  33. var blockBtn=document.createElement("button");
  34. blockBtn.id="blockBtn";
  35. blockBtn.type="button";
  36. blockBtn.textContent="好孩子看不到";
  37. blockBtn.style="padding:4px 0;position: relative;width:120px;";
  38. pre.before(blockBtn);
  39.  
  40. var oldDriver = document.querySelector(".entry-content");
  41. var txt=oldDriver.innerHTML.toString();
  42. if(regObj.btih.test(txt)){
  43. var magH=txt.match(regObj.btih);
  44. for (j=0;j<magH.length;j++){
  45. linkArr.btih=hashFunc(magH[j])[3]+'<a href="magnet:?xt=urn:btih:'+hashFunc(magH[j])[2]+'" >磁力链接 </a>';
  46. linkArr.btih+=' →<a href="http://www.torrent.org.cn/Home/Convert/magnet2torrent.html?hash='+hashFunc(magH[j])[2]+'" target="_blank" title="需要先注册登陆">【下载种子】</a>';
  47. linkArr.btih+=' <a href="http://www.btaia.com/torrent/detail/hash/'+hashFunc(magH[j])[2]+'" target="_blank" title="支持Base32,可查看种子内容,需要验证码,长期Invalid CAPTCHA token">【种子详情】</a>';
  48.  
  49. txt=txt.replace(magH[j],linkArr.btih);
  50. }
  51. }
  52. //度娘
  53. txt=txt.replace(regObj.bdshare,linkArr.baidu);
  54. //好盘
  55. txt=txt.replace(regObj.howfile,linkArr.howf);
  56. //短链接
  57. txt=txt.replace(regObj.tcn,linkArr.tcn);
  58. //115
  59. txt=txt.replace(regObj.yyw,linkArr.yyw);
  60. //mega
  61. txt=txt.replace(regObj.mega,linkArr.mega);
  62. oldDriver.innerHTML=txt;
  63. var link;
  64. if (document.querySelectorAll) {
  65. link = document.querySelectorAll('a');
  66. } else {
  67. link = document.getElementsByTagName('a');
  68. }
  69. for (var i = 0, k = link.length; i < k; i++) {
  70. var target=link[i];
  71. if(/baidu.com/i.test(target.href)&&!/(?:eyun|tieba)\.baidu\.com/i.test(target.href)&&!/#/i.test(target.href)){ //正则校验匹配的网盘,豁免 百度企业云盘
  72. if(codeRule.test(target.textContent)){
  73. target.href+='#'+extCode(target);
  74. } else if(target.nextSibling&&codeRule.test(target.nextSibling.textContent)){
  75. if(!/#\S+/i.test(target.href)){
  76. target.href+=/#/i.test(target.href)?extCode(target.nextSibling):('#'+extCode(target.nextSibling));
  77. }
  78. } else if(codeRule.test(target.parentNode.textContent)){
  79. if(!/#\S+/i.test(target.href)) target.href+=/#/i.test(target.href)?extCode(target.nextSibling):('#'+extCode(target.nextSibling));
  80. } else {
  81. var j = 0,
  82. maxParent = 5, //向上遍历的层级
  83. parent = target;
  84. while(j<maxParent) {
  85. j++; //遍历计数
  86. parent = parent.parentNode; //取得父对象
  87. if(parent.tagName=="TR") { //如果父对象是表格,则从表格中提取密码
  88. if(codeRule.test(parent.nextElementSibling.textContent)) {
  89. parent=parent.nextElementSibling;
  90. target.href+='#'+extCode(parent);
  91. break;
  92. }
  93. } else if(codeRule.test(parent.textContent)) { //否则按照常规方式提取密码
  94. target.href+='#'+extCode(parent);
  95. break;
  96. }
  97. if(parent==document.body) break; //如果已经遍历到最顶部,停止遍历
  98. }
  99. }
  100. }
  101. }
  102.  
  103.  
  104. document.querySelector("#blockBtn").addEventListener("click",function(){
  105. if(this.nextSibling.style.display == 'block'){
  106. this.nextSibling.style.display = '';
  107. }else{
  108. this.nextSibling.style.display = 'block';
  109. }
  110. });
  111. }
  112.  
  113.  
  114. });
  115. var pre = document.querySelector("pre");
  116. if (pre && !document.querySelector("#blockBtn")) {
  117. var blockBtn=document.createElement("button");
  118. blockBtn.id="blockBtn";
  119. blockBtn.type="button";
  120. blockBtn.textContent="好孩子看不到";
  121. blockBtn.style="padding:4px 0;position: relative;width:120px;";
  122. pre.before(blockBtn);
  123. }
  124. }
  125.  
  126. var i;
  127. //防爆补丁
  128. var feiZao=document.getElementsByTagName("p1");
  129. var fZLength=feiZao.length;
  130. if (!!fZLength){
  131. for (i=0;i<fZLength;i++){
  132. feiZao[0].parentNode.removeChild(feiZao[0]);
  133. }
  134. }
  135.  
  136. var regObj={ //用于匹配的正则
  137. btih:/(?:[^\/=\|])?([a-fA-F0-9]{40})/g,
  138. bdshare:/\s(b?\/s\/)?(\w{7,8})\b(?:\s+(\w{4}))?(?![\">])/g, //度娘 类型:/s/1i31aCbb b/s/1i31aCbb >>>其后非?!xxx
  139. howfile:/@?(?:HF|howfile)\/file\/(\w{4,10})\/(\w{8,})\/?/gi, //好盘 类型I:@HF/file/61dbeea7/0c7f2f56/ @howfile/file/61dbeea7/0c7f2f56/
  140. tcn:/\bt\/(\w{7})/g, //t.cn短链接 类型I:t/RZEWYLu
  141. yyw:/(\/lb\/)?(5lb[a-zA-Z0-9]{8,12})/g, //115礼包:/lb/5lbeo3p8eh02
  142. mega:/(?:\.co)?(\.nz\/(#[\w!-]{22,}))/g //.co.nz/#!AZcSmbJA!Q5ZbtIDoQecZc_3Cmc2v_vMaLFJRO6Ctd7uaWdWKqK0
  143. //.nz/#F!Cw9HSQCR!GgOIg9e9FNQGSplRDNxWDw
  144. };
  145. var linkArr=[]; //用于替换的链接
  146. linkArr.btih='';//未定义
  147. linkArr.baidu="<a href='http://pan.baidu.com/s/$1#$2' target='_blank'>度娘:$1</a> $2";
  148. linkArr.howf="<a href='http://howfile.com/file/$1/$2/' target='_blank'>好盘:howfile.com/file/$1/$2</a>";
  149. linkArr.tcn="<a href='http://t.cn/$1' target='_blank'>短链:t.cn/$1</a>";
  150. linkArr.yyw="<a href='http://115.com/lb/$2' target='_blank'>115礼包:$2</a> ";
  151. linkArr.mega="<a href='https://mega.co$1' target='_blank'>MEGA网盘:$2</a>";
  152. //磁链
  153. function hashFunc(hash){ //hash操作
  154. hashWord=hash.match(/^\W*/g)[0];
  155. hash=hash.replace(/[\s\W]*/g, "").toUpperCase();
  156. hashStart=hash.slice(0,2);
  157. hashEnd=hash.slice(-2);
  158. return [hashStart,hashEnd,hash,hashWord];
  159. }
  160.  
  161. function processTxt(target){
  162. var txt=target.innerHTML;
  163. if(regObj.btih.test(txt)){
  164. var magH=txt.match(regObj.btih);
  165. for (j=0;j<magH.length;j++){
  166. linkArr.btih=hashFunc(magH[j])[3]+'<a href="magnet:?xt=urn:btih:'+hashFunc(magH[j])[2]+'" >磁力链接 </a>';
  167. linkArr.btih+=' →<a href="http://www.torrent.org.cn/Home/Convert/magnet2torrent.html?hash='+hashFunc(magH[j])[2]+'" target="_blank" title="需要先注册登陆">【下载种子】</a>';
  168. linkArr.btih+=' <a href="http://www.btaia.com/torrent/detail/hash/'+hashFunc(magH[j])[2]+'" target="_blank" title="支持Base32,可查看种子内容,需要验证码,长期Invalid CAPTCHA token">【种子详情】</a>';
  169.  
  170. txt=txt.replace(magH[j],linkArr.btih);
  171. }
  172. }
  173.  
  174. //度娘
  175. txt=txt.replace(regObj.bdshare,linkArr.baidu);
  176. //好盘
  177. txt=txt.replace(regObj.howfile,linkArr.howf);
  178. //短链接
  179. txt=txt.replace(regObj.tcn,linkArr.tcn);
  180. //115
  181. txt=txt.replace(regObj.yyw,linkArr.yyw);
  182. //mega
  183. txt=txt.replace(regObj.mega,linkArr.mega);
  184. target.innerHTML=txt;
  185. }
  186.  
  187. var content=document.querySelector('.entry-content');
  188. if(location.href.indexOf("sexacg.") != -1)content=document.querySelector('article');
  189. if(content){
  190. var oldDrivers = content.querySelectorAll("p");
  191. if(location.href.indexOf("sexacg.") != -1){
  192. var quote = content.querySelector('.su-quote-inner');
  193. if(quote){
  194. processTxt(quote);
  195. }
  196. }
  197. for(var i=0,k=oldDrivers.length;i<k;i++){
  198. processTxt(oldDrivers[i]);
  199. }
  200. }
  201.  
  202. function extCode(obj){
  203. text=obj.textContent.trim();
  204. var rule=new RegExp('(?:提取|访问)[码碼]?\s*[:: ]?\\s*([a-z\\d]{4})','i');
  205. return rule.test(text)?text.match(rule)[1]:(codeRule.test(text)?text.match(codeRule)[1]:""); //首先尝试使用 提取码|访问码 作为密码匹配的关键字,无效时则使用更完整的匹配规则
  206. }
  207.  
  208. var link;
  209. if (document.querySelectorAll) {
  210. link = document.querySelectorAll('a');
  211. } else {
  212. link = document.getElementsByTagName('a');
  213. }
  214. for (var i = 0, k = link.length; i < k; i++) {
  215. if (/.*http:.*\.hacg\./i.test(link[i].outerHTML)) {
  216. link[i].href = link[i].outerHTML.match(/(?<=href=").*?(?=")/i)[0].replace(/http/, 'https');
  217. }
  218. var target=link[i];
  219. if(/baidu.com/i.test(target.href)&&!/(?:eyun|tieba)\.baidu\.com/i.test(target.href)&&!/#/i.test(target.href)){ //正则校验匹配的网盘,豁免 百度企业云盘
  220. if(codeRule.test(target.textContent)){
  221. target.href+='#'+extCode(target);
  222. } else if(target.nextSibling&&codeRule.test(target.nextSibling.textContent)){
  223. if(!/#\S+/i.test(target.href)){
  224. target.href+=/#/i.test(target.href)?extCode(target.nextSibling):('#'+extCode(target.nextSibling));
  225. }
  226. } else if(codeRule.test(target.parentNode.textContent)){
  227. if(!/#\S+/i.test(target.href)) target.href+=/#/i.test(target.href)?extCode(target.nextSibling):('#'+extCode(target.nextSibling));
  228. } else {
  229. var j = 0,
  230. maxParent = 5, //向上遍历的层级
  231. parent = target;
  232. while(j<maxParent) {
  233. j++; //遍历计数
  234. parent = parent.parentNode; //取得父对象
  235. if(parent.tagName=="TR") { //如果父对象是表格,则从表格中提取密码
  236. if(codeRule.test(parent.nextElementSibling.textContent)) {
  237. parent=parent.nextElementSibling;
  238. target.href+='#'+extCode(parent);
  239. break;
  240. }
  241. } else if(codeRule.test(parent.textContent)) { //否则按照常规方式提取密码
  242. target.href+='#'+extCode(parent);
  243. break;
  244. }
  245. if(parent==document.body) break; //如果已经遍历到最顶部,停止遍历
  246. }
  247. }
  248. }
  249. }
  250. //手动转换文本框
  251. var oD_box=document.createElement("div");
  252. oD_box.id="oD_box";
  253. oD_box.style="position:fixed;top:10px;right:10px; width:210px;";
  254. var oD_text=document.createElement("input");
  255. oD_text.id="oD_text";
  256. oD_text.type="text";
  257. oD_text.placeholder="输入hash值";
  258. oD_text.title='将自动添加"magnet:?xt=urn:btih:",去除[]中的内容、非字母数字字符、空格';
  259. var oD_button=document.createElement("button");
  260. oD_button.id="oD_button";
  261. oD_button.type="button";
  262. oD_button.textContent="开车";
  263. oD_button.style="padding:4px 0; position: relative; top:-1px";
  264. oD_button.onclick=function (){
  265. var oD_hash=oD_text.value.replace(/(\[.*\])|[\W_]/g,"");
  266. oD_link.href="magnet:?xt=urn:btih:"+oD_hash;
  267. oD_link.textContent="磁链";
  268. oD_link2.href="http://www.torrent.org.cn/Home/Convert/magnet2torrent.html?hash="+oD_hash;
  269. oD_link2.textContent="种子";
  270. oD_link2.style="margin-left:20px";
  271. oD_link3.href="http://www.btaia.com/torrent/detail/hash/"+oD_hash;
  272. oD_link3.textContent="详情";
  273. oD_link3.style="margin-left:20px";
  274. };
  275. var oD_link=document.createElement("a");
  276. var oD_link2=document.createElement("a");
  277. var oD_link3=document.createElement("a");
  278. oD_link2.target="_blank";
  279. oD_link3.target="_blank";
  280. oD_box.appendChild(oD_text);
  281. oD_box.appendChild(oD_button);
  282. oD_box.appendChild(oD_link);
  283. oD_box.appendChild(oD_link2);
  284. oD_box.appendChild(oD_link3);
  285. document.body.appendChild(oD_box);
  286. if(document.querySelector("#blockBtn")){
  287. document.querySelector("#blockBtn").addEventListener("click", function(){
  288. if(this.nextSibling.style.display == 'block'){
  289. this.nextSibling.style.display = '';
  290. }else{
  291. this.nextSibling.style.display = 'block';
  292. }
  293. });
  294. }
  295. //评论区度娘、115、tcn
  296. var buDang=document.getElementsByClassName('comment-content');
  297. for (i in buDang){
  298. if(buDang[i]&&buDang[i].innerHTML)
  299. buDang[i].innerHTML=buDang[i].innerHTML.replace(/\b(\w{8})\b(?:\s*(?:<br>|密码:|密码:|pw:|提取码:)?\s*(\w{4}|\S*?(?=\<)|\S*)?)/gi,linkArr.baidu).replace(regObj.yyw,linkArr.yyw).replace(regObj.tcn,linkArr.tcn);
  300. }
  301.  
  302. })();