虫洞2.0(漫猫/爱恋/ MioBT 二合一脚本)

漫猫/爱恋/ MioBT 二合一脚本(种子列表增强/生存模式BT下载链接)

  1. // ==UserScript==
  2. // @name 虫洞2.0(漫猫/爱恋/ MioBT 二合一脚本)
  3. // @icon https://www.kisssub.org/images/favicon/kisssub.ico
  4. // @namespace https://www.kisssub.org
  5. // @version 0.2
  6. // @description 漫猫/爱恋/ MioBT 二合一脚本(种子列表增强/生存模式BT下载链接)
  7. // @author _Hyouka&TKF
  8. // @match http://*.kisssub.org/*
  9. // @match http://*.comicat.org/*
  10. // @match http://*.miobt.com/*
  11. // @match https://*.kisssub.org/*
  12. // @match https://*.comicat.org/*
  13. // @match https://*.miobt.com/*
  14. // @include http://*.kisssub.org/*
  15. // @include http://*.comicat.org/*
  16. // @include http://*.miobt.com/*
  17. // @include https://*.kisssub.org/*
  18. // @include https://*.comicat.org/*
  19. // @include https://*.miobt.com/*
  20. // @grant none
  21. // ==/UserScript==
  22.  
  23. //主要
  24. var acgscript_config;
  25. !function () {
  26. acgscript_config = {
  27. "miobt": {
  28. "3": {
  29. "base_url": "https://cdn.acgscript.com/script/miobt/live2d", "show_toggle": false
  30. },
  31. "4": {
  32. "api_url": "http://v2.uploadbt.com", "source": "cdn.acgscript.com"
  33. }
  34. }
  35. };
  36.  
  37. // -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> 种子列表增强 -> -> -> -> -> -> -> -> -> -> -> -> -> -> ->
  38. (function ($) {
  39. var log_name = 'acgscript/bt_list_enhanced';
  40.  
  41. console.log([log_name, {
  42. 'in_script': Config['in_script'],
  43. 'platform': Config['user_script']['platform']
  44. }]);
  45.  
  46. if (Config['user_script']['platform'] !== 'desktop') {
  47. return false;
  48. }
  49.  
  50. if ((Config['in_script'] !== 'index') && (Config['in_script'] !== 'search')) {
  51. return false;
  52. }
  53.  
  54. console.log([log_name, {
  55. 'execute': true
  56. }]);
  57.  
  58. $(document).ready(function () {
  59. //匹配BT列表顿
  60. if (!$(".clear > table#listTable > tbody.tbody > tr[class^='alt'] > td > a[href^='show']").length) {
  61. return false;
  62. }
  63.  
  64. var link;
  65. var tracker = 'http://open.acgtracker.com:1096/announce';
  66. var copyTextToClipboard = function (text) {
  67. var textArea = document.createElement("textarea");
  68. textArea.style.position = 'fixed';
  69. textArea.style.top = 0;
  70. textArea.style.left = 0;
  71. textArea.style.width = '2em';
  72. textArea.style.height = '2em';
  73. textArea.style.padding = 0;
  74. textArea.style.border = 'none';
  75. textArea.style.outline = 'none';
  76. textArea.style.boxShadow = 'none';
  77. textArea.style.background = 'transparent';
  78. textArea.value = text;
  79. document.body.appendChild(textArea);
  80. textArea.select();
  81.  
  82. try {
  83. var successful = document.execCommand('copy');
  84. var msg = successful ? 'successful' : 'unsuccessful';
  85. console.log('Copying text command was ' + msg);
  86. } catch (err) {
  87. console.log('Oops, unable to copy');
  88. }
  89. document.body.removeChild(textArea);
  90. };
  91.  
  92. //复制
  93. var copyMagnet = function () {
  94. var i = 0;
  95. var arr = new Array("");
  96. //获取所有勾上class为checkMagnet的checkbox(每行资源所对应的checkbox),遍历
  97. $(".checkMagnet:checked").each(function () {
  98. //获取该checkbox的val,即磁链,放到数组中
  99. arr[i] = $(this).val();
  100. i += 1;
  101. });
  102. //把数组以换行回车连接为一个字符串
  103. var multiMagnet = arr.join("\r\n");
  104. //弹出确认对话框,用户选择积极选项时把字符串放入剪贴板
  105. if (confirm("即将复制已选磁链,确认进行_")) {
  106. copyTextToClipboard(multiMagnet);
  107. }
  108. };
  109. //全选
  110. var checkAll = function () {
  111. //获取所有资源所对应的checkbox,遍县
  112. $(".checkMagnet").each(function () {
  113. //当全选复选框与当前复选框的勾选状态不一样时
  114. if ($(this).get(0).checked != $("#checkAll").get(0).checked) {
  115. //点击当前复选框
  116. $(this).get(0).click();
  117. }
  118. });
  119. };
  120. //全选状态的临界状态处理,即全选到差一个全选,以及差一个全选到全选
  121. var checkThis = function () {
  122. //如果当前checkbox不被勾上
  123. if ($(this).get(0).checked === false) {
  124. //全选复选框也不可以被勾丿
  125. $("#checkAll").get(0).checked = false;
  126. }
  127. //如果当前checkbox被勾上并且所有资源所对应的checkbox都被勾上
  128. else if ($(this).get(0).checked === true && $(".checkMagnet:checked").length == $(".checkMagnet").length) {
  129. //全选复选框也要被勾丿
  130. $("#checkAll").get(0).checked = true;
  131. }
  132. };
  133.  
  134. link = $(".clear > table#listTable > tbody.tbody > tr[class^='alt'] > td > a[href^='show']");
  135. var headTh = $("#listTable .l3");
  136. var newColumn = headTh.clone();
  137. newColumn.removeClass("l3").addClass("l31").css("width", "65px");
  138. var checkall = $("<input/>", {type: "checkbox", id: "checkAll", title: "全逿"});
  139. headTh.after(newColumn.text("").append(checkall).append($('<i class="fa fa-clipboard" id="copy_magnets"></i>')));
  140. //对全选复选框和其他复选框监听变更事件
  141. $("#checkAll").on("change", checkAll);
  142.  
  143. //对列表页表格中的每一衿
  144. if (link != null) { // 不可使用!==进行两者的比较,因为undefined !== null的值为true
  145. link.each(function () {
  146. //从资源页url中切出hex编码hash
  147. var str = $(this).attr("href").substring(5, 45);
  148. //构成磁链
  149. var magnet = "magnet:?xt=urn:btih:" + str + "&tr=" + tracker;
  150. var td = $("<td/>");
  151. var check = $("<input/>", {type: "checkbox", class: "checkMagnet", value: magnet});
  152. //把整个元素放到后面的td丿
  153. var a = $("<a/>", {href: magnet, class: "magnet", html: '<i class="fa fa-magnet"></i>'});
  154. $(this).parent().after(td.append(check).append(a));
  155. });
  156. }
  157. if ($(".checkMagnet")) {
  158. //对checkMagnet类的变更事件绑定全选复选框的选中变更函数
  159. $(".checkMagnet").on("change", checkThis);
  160. }
  161.  
  162. $('#copy_magnets').click(function () {
  163. copyMagnet();
  164. });
  165. $('i.fa').css('color', $('.box').css('border-color'));
  166. });
  167. })(jQuery);
  168. // <- <- <- <- <- <- <- <- <- <- <- <- <- <- <- END <- <- <- <- <- <- <- <- <- <- <- <- <- <- <-
  169.  
  170.  
  171. // -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> 生存模式BT下载链接 -> -> -> -> -> -> -> -> -> -> -> -> -> -> ->
  172. (function ($) {
  173. if (acgscript_config['miobt']['4']['loaded']) {
  174. return false;
  175. }
  176.  
  177. acgscript_config['miobt']['4']['loaded'] = true;
  178. var log_name = 'acgscript/miobt/bt_download';
  179.  
  180. console.log([log_name, {
  181. 'source': acgscript_config['miobt']['4']['source'], 'loaded': acgscript_config['miobt']['4']['loaded'], 'api_url': acgscript_config['miobt']['4']['api_url'], 'mika_mode': Config['mika_mode']['enabled'], 'in_script': Config['in_script'], 'platform': Config['user_script']['platform']
  182. }]);
  183.  
  184. if (!Config['mika_mode']['enabled']) {
  185. return false;
  186. }
  187.  
  188. if (Config['in_script'] !== 'show') {
  189. return false;
  190. }
  191.  
  192. if (!$('#box_download')) {
  193. return false;
  194. }
  195.  
  196. var api_url = acgscript_config['miobt']['4']['api_url'];
  197.  
  198. var torrent_url = {
  199. "lite": api_url + '/?r=down&hash=' + Config['hash_id'], 'full': api_url + '/?r=down&hash=' + Config['hash_id'] + '&name=' + Config['down_torrent_format'].replace('%s', Config['bt_data_title'])
  200. };
  201.  
  202. var magnet_url = {
  203. 'lite': 'magnet:?xt=urn:btih:' + Config['hash_id'], 'full': 'magnet:?xt=urn:btih:' + Config['hash_id']
  204. };
  205.  
  206. if (Config['user_script']['platform'] == 'desktop') {
  207. $('#box_download h2.title').text('下载地址');
  208. $('#magnet').attr('href', magnet_url.full).text('磁链下载');
  209. $('#download').attr('href', torrent_url.full).text('种子下载');
  210. $('#qrcode_magnet').removeAttr('href').text('磁链扫码');
  211. $('#qrcode_download').removeAttr('href').text('种子扫码');
  212. $('#qrcode_magnet_enlarged').attr('qr_content', magnet_url.full);
  213. $('#qrcode_download_enlarged').attr('qr_content', torrent_url.lite);
  214.  
  215. var register_qrcode_event = function (sel, sel_enlarged) {
  216. $(sel).click(function () {
  217.  
  218. $('.qrcode_enlarged').html('').hide();
  219. $(sel_enlarged).qrcode({
  220. render: "canvas", size: 256, fill: '#0480BE', background: '#FFF', quiet: 1, mode: 2, minVersion: 10, label: $(sel_enlarged).attr('qr_label'), fontname: '"Helvetica Neue", Helvetica, Arial, "PingFang SC", "Hiragino Sans GB", "Heiti SC", "Microsoft YaHei", "WenQuanYi Micro Hei", sans-serif', fontcolor: 'darkorange', text: $(sel_enlarged).attr('qr_content')
  221. });
  222.  
  223. $(sel_enlarged).fadeIn(200);
  224. });
  225.  
  226. $(sel_enlarged).click(function () {
  227. $(this).hide();
  228. });
  229. };
  230.  
  231. $(document).ready(function () {
  232. register_qrcode_event('#qrcode_magnet', '#qrcode_magnet_enlarged');
  233. register_qrcode_event('#qrcode_download', '#qrcode_download_enlarged');
  234. });
  235. }
  236. else if (Config['user_script']['platform'] == 'mobile') {
  237. $('#torrent_url').attr('href', torrent_url.full).text('种子下载').click(function () {
  238. return (prompt('确认下载该种孿', torrent_url.full) ? true : false);
  239. });
  240.  
  241. $('#magnet_url').attr('href', magnet_url.full).text('磁力下载').click(function () {
  242. return (prompt('确认下载磁链', magnet_url.full) ? true : false);
  243. });
  244. }
  245. else {
  246. return false;
  247. }
  248. })(jQuery);
  249. // <- <- <- <- <- <- <- <- <- <- <- <- <- <- <- END <- <- <- <- <- <- <- <- <- <- <- <- <- <- <-
  250. }();