磁力快显

在磁力宝、BTSOW、ØMagnet、磁力狗等磁力搜索引擎的搜索列表增加磁力链接显示,方便快速下载资源。

  1. // ==UserScript==
  2. // @name 磁力快显
  3. // @author zxf10608
  4. // @version 3.8.1
  5. // @homepageURL https://gf.qytechs.cn/zh-CN/scripts/397490
  6. // @icon https://cdn.jsdelivr.net/gh/zxf10608/JavaScript/icon/magnet00.png
  7. // @description 在磁力宝、BTSOW、ØMagnet、磁力狗等磁力搜索引擎的搜索列表增加磁力链接显示,方便快速下载资源。
  8. // @require https://cdn.jsdelivr.net/npm/jquery@3.7.1/dist/jquery.min.js
  9. // @include *://clb*.*
  10. // @include *://clg*.*/search*
  11. // @include *://www.btmov*.*/so/*
  12. // @include *://*mag.net/search*
  13. // @include *://btsow*/search/*
  14. // @include *://www.*yuhuage*.*/search/*
  15. // @connect *
  16. // @grant unsafeWindow
  17. // @grant GM_setValue
  18. // @grant GM_getValue
  19. // @grant GM_openInTab
  20. // @grant GM_notification
  21. // @grant GM_setClipboard
  22. // @grant GM_xmlhttpRequest
  23. // @grant GM_registerMenuCommand
  24. // @grant GM_unregisterMenuCommand
  25. // @run-at document-start
  26. // @license GPL License
  27. // @namespace http://tampermonkey.net/
  28. // ==/UserScript==
  29.  
  30. (function() {
  31. 'use strict';
  32. if(document.title.indexOf('磁力宝') != -1){
  33. unsafeWindow.alert=function(){
  34. console.log('已阻止弹窗');
  35. };
  36. };
  37. $(document).ready(function(){
  38. if(GM_getValue('open')==1){
  39. let close=GM_registerMenuCommand ('关闭复制弹窗通知', function(){
  40. GM_setValue('open',0);
  41. GM_unregisterMenuCommand(close);
  42. location.reload();
  43. });
  44. }else{
  45. let open=GM_registerMenuCommand ('开启复制弹窗通知', function(){
  46. GM_setValue('open',1);
  47. GM_unregisterMenuCommand(open);
  48. location.reload();
  49. });
  50. };
  51. function base32To16(str){
  52. if(str.length % 8 !== 0 || /[0189]/.test(str)){
  53. return str;
  54. };
  55. str = str.toUpperCase();
  56. var bin = "", newStr = "", i;
  57. for(i = 0;i < str.length;i++){
  58. var charCode=str.charCodeAt(i);
  59. if(charCode<65)charCode-=24;
  60. else charCode-=65;
  61. charCode='0000'+charCode.toString(2);
  62. charCode=charCode.substr(charCode.length-5);
  63. bin+=charCode;
  64. };
  65. for(i = 0;i < bin.length;i+=4){
  66. newStr += parseInt(bin.substring(i,i+4),2).toString(16);
  67. };
  68. return newStr;
  69. };
  70.  
  71. $('.common-link:odd,.search-tips,#cps-wrap').remove();
  72. $('a:not([href^="magnet:"])').each(function(){
  73. var reg1 = /(^|\/|&|-|\.|\?|=|:)([a-fA-F0-9]{40})/;
  74. var reg2 = /\/([a-zA-Z2-7]{32})$/;
  75. var link = $(this).attr('href') || '';
  76. if(reg1.test(link)){
  77. var hash = link.match(reg1)[2];
  78. }else if(reg2.test(link)){
  79. var hash = link.match(reg2)[1];
  80. hash = base32To16(hash).toUpperCase();
  81. }else{
  82. return;
  83. };
  84. $(this).attr('target','_blank');
  85. var newLink = 'magnet:?xt=urn:btih:' + hash;
  86. $(this).append('<img src="https://cdn.jsdelivr.net/gh/zxf10608/JavaScript/icon/magnet00.png" class="mag1" href='+newLink+' title="识别到磁力链接,左键打开,右键复制\n'+newLink+'" target="_blank" style="z-index:9123456789;display:inline-block;cursor:pointer;margin:0px 5px 2px;border-radius:50%;border:0px;vertical-align:middle;outline:none!important;padding:0px!important;height:20px!important;width:20px!important;left:0px!important;top:0px!important;">');
  87. });
  88. if($('.mag1').length < 1 && document.title.indexOf('磁力宝') == -1){
  89. function magnetCall(href){
  90. return new Promise(function(resolve, reject){
  91. GM_xmlhttpRequest({
  92. method: 'GET',
  93. url: href,
  94. onload: function(data,status) {
  95. if(data.readyState==4 && data.status==200){
  96. var htmlTxt = data.responseText;
  97. resolve(htmlTxt);
  98. };
  99. },
  100. onerror: function(error) {
  101. reject(error);
  102. },
  103. });
  104. });
  105. };
  106.  
  107. var magnetEl = $('h3 a[href!="/"],li a[href!="/"],td a[href!="/"],dd a[href!="/"]');
  108. magnetEl.attr({'target':'_blank','style':'display:inline-block;'});
  109. if (magnetEl.length<20){
  110. var n = magnetEl.length;
  111. }else{
  112. var n = 20;
  113. };
  114.  
  115. let arr = [];
  116. for (let i = 0; i < n; i++) {
  117. var link = magnetEl.eq(i).attr('href');
  118. if (/^\//.test(link)) {
  119. link = location.origin+link;
  120. };
  121. magnetCall(link).then(function(htmlTxt){
  122. arr[i] = new Promise((resolve, reject) => {
  123. var newLink = htmlTxt.match(/href="(magnet.{54}).*"/);
  124. if (newLink != null ) {
  125. magnetEl.eq(i).after('<img src="https://cdn.jsdelivr.net/gh/zxf10608/JavaScript/icon/magnet00.png" class="mag1" href='+newLink[1]+' title="识别到磁力链接,左键打开,右键复制\n'+newLink[1]+'" target="_blank" style="z-index:9123456789;display:inline-block;cursor:pointer;margin:0px 5px 2px;border-radius:50%;border:0px;vertical-align:middle;outline:none!important;padding:0px!important;height:20px!important;width:20px!important;left:0px!important;top:0px!important;">');
  126. }else{
  127. console.log(link+' 无磁力链接');
  128. };
  129. resolve(i);
  130. });
  131. });
  132. };
  133. Promise.all(arr).then((res) => {
  134. console.log('磁力链接有'+magnetEl.length+'个。');
  135. console.log('磁力链接已全部加载完成。');
  136. }).catch((err) => {
  137. console.log('磁力链接加载失败。');
  138. });
  139. }else{
  140. console.log('磁力链接有'+$('.mag1').length+'个。');
  141. };
  142. setTimeout(function(){
  143. if($('.115offline').length>0){
  144. $('.mag1').remove();
  145. };
  146. },800);
  147.  
  148. $('body').on('contextmenu click','.mag1', function(e) {
  149. var link=$(this).attr('href')
  150. if(e.type == 'click'){
  151. GM_openInTab(link,false);
  152. }else{
  153. GM_setClipboard(link);
  154. if(GM_getValue('open')==1){
  155. GM_notification({
  156. title:'磁力快显:',
  157. text:'磁力链接复制成功!',
  158. timeout:2000,
  159. });
  160. };
  161. console.log('磁力链接复制成功:\n'+link);
  162. };
  163. return false;
  164. });
  165. });
  166. })();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址