wkgo download seeds

增加页面顶部底部按钮和一键下种按钮

Από την 27/07/2024. Δείτε την τελευταία έκδοση.

  1. // ==UserScript==
  2. // @name wkgo download seeds
  3. // @namespace websiteEnhancement
  4. // @author You
  5. // @version 2024.7.19
  6. // @description 增加页面顶部底部按钮和一键下种按钮
  7. // @create 2023-9-21
  8. // @include *wkgo*
  9. // @grant GM_getValue
  10. // @grant GM_setValue
  11. // @grant GM.getValue
  12. // @grant GM.setValue
  13. // @icon data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
  14. // @license MIT
  15. // @run-at document-end
  16. // ==/UserScript==
  17. ;
  18. (async function (loadJS) {
  19. Array.prototype.push = function (...items) {
  20. let len = this.length >>> 0;
  21. let argCount = items.length >>> 0;
  22. if (len + argCount > 2 ** 53 - 1) {
  23. throw new TypeError("Invalid array length");
  24. }
  25. for (let i = 0; i < argCount; i++) {
  26. this[len + i] = items[i];
  27. }
  28. this.length = len + argCount;
  29. return this.length;
  30. };
  31. loadJS("https://update.greasyfork.org/scripts/483173/1301961/GM_config_cnjames.js")
  32. .then(v => loadJS("https://update.sleazyfork.org/scripts/476583/common_libs_of_array.js"))
  33. .then(v => {
  34. withJQuery(function ($, win) {
  35.  
  36. $('table a').removeAttr('style')
  37.  
  38. let w = 40, h = 40;
  39. addStyle(`
  40. a:link{color:green;}
  41. a:hover{color:red;}
  42. a:active{color:yellow;}
  43. a:visited{color:orange;}
  44. .btn1 {
  45. opacity:0.8;-moz-transition-duration:0.2s;-webkit-transition-duration:0.2s;
  46. padding:1px; margin-top:1px;
  47. font-size: 10; text-align: center; vertical-align: middle; line-height:${h}px;
  48. border-radius:5px 5px 5px 5px;cursor:pointer; left:0px;z-index:9999;
  49. background:white;
  50. width:${w}px;height:${h}px;
  51. }
  52. `);
  53. let container = $(document.createElement('div')).css({
  54. 'cssText': `position:fixed;top:15%;width:${w}px;height:${h * 7}px;left:0px;z-index:9999`
  55. });
  56.  
  57.  
  58. if (win.location.href.indexOf("thread") != -1) {
  59. //下载按钮
  60. let downloadBtn = $(document.createElement('div')).text('下載').appendTo(container)
  61. .click(function () {
  62. $("a:contains(.torrent)").each((i, element) => {
  63.  
  64. let url = $(element).attr('href');
  65. let filename = $(element).text().trim();
  66. if (filename.indexOf('torrent') == -1)
  67. return true;
  68. console.log("download file name:", $(element).text())
  69. createSuperLabel(url, url, filename, window)
  70. });
  71.  
  72. });
  73. console.log('win.__t', win.__t)
  74. let //close
  75. closeBtn = $(document.createElement('div')).text('關閉').appendTo(container)
  76. .click(function () {
  77. win.open("about:blank", "_self").close();
  78. }),
  79. //加速
  80. fastBtn = $(document.createElement('div')).text('加速').attr('title', '加速').appendTo(container)
  81. .click(function () {
  82. if (win.__wait > 5) {
  83. win.__wait = win.__wait / 1.5
  84. } else {
  85. win.__wait = 5
  86. }
  87. win.___reset()
  88.  
  89. }),
  90. switchBtn = $(document.createElement('div')).text(!win.__t ? '啓' : '停').appendTo(container)
  91. .click(function () {
  92. if (!win.__t) {
  93. win.__startTimer();
  94. } else {
  95. win.__stopTimer()
  96. }
  97. }),
  98. slowBtn = $(document.createElement('div')).text('減速').attr('title', '減速').appendTo(container)
  99. .click(function () {
  100. win.__wait *= 1.5
  101. win.___reset()
  102. })
  103.  
  104. $(document).keydown(function (event) {
  105. let e = event || win.event;
  106. let k = e.keyCode || e.which;
  107. if (k === 16) {
  108. // isCtrl = true;
  109. switchBtn.click()
  110. } else if (k === 38) { //up
  111. event.stopPropagation()
  112. slowBtn.click()
  113.  
  114. } else if (k === 40) {//down
  115. event.stopPropagation()
  116. //fastBtn.click()
  117. }
  118. })
  119. $(document).mousedown(function (e) {
  120. if (e.which == 2) {
  121. downloadBtn.click();
  122. }
  123. })
  124. $(win).blur(function () {
  125. win.__stopTimer()
  126. }).focus(function () {
  127. win.__startTimer();
  128. })
  129.  
  130. win.__wait = 900
  131. win.__step = 100;
  132. win.__startTimer = function () {
  133. win.______h = $(document).scrollTop() + win.__step;
  134. if (win.______h >= $(document).height() - $(win).height()) {
  135. win.__stopTimer()
  136. // win.__t = setTimeout(win.__startTimer, 30000)
  137. } else {
  138. $(document).scrollTop(win.______h);
  139. win.__t = setTimeout(win.__startTimer, win.__wait)
  140. }
  141. win.__syncState()
  142. };
  143. win.__stopTimer = function () {
  144. clearTimeout(win.__t)
  145. win.__t = 0
  146. win.__syncState()
  147. }
  148. win.___reset = function () {
  149. win.__stopTimer()
  150. win.__startTimer();
  151. win.__syncState()
  152. }
  153. win.__syncState = function () {
  154. fastBtn.text(`${Math.floor(win.__wait)}`)
  155. slowBtn.text(`${Math.floor(win.__wait)}`)
  156. switchBtn.text(win.__t ? '停' : '啓')
  157. }
  158. }
  159. else {
  160. $('tr').hover(
  161. function () {
  162. $(this).find('*').css("background-color", "#9AAAC7")
  163. }, function () {
  164. $(this).find('*').css("background-color", '');
  165. });
  166. }
  167. //最顶按钮
  168. let
  169. toTopBtn = $(document.createElement('div')).text('Top').appendTo(container)
  170. .click(function () {
  171. win.scrollTo(0, 0);
  172. }), //最低按钮
  173. toBottomBtn = $(document.createElement('div')).text('Bottom').appendTo(container)
  174. .click(function () {
  175. win.scrollTo(0, document.body.scrollHeight);
  176. }),
  177.  
  178. setBtn = $(document.createElement('div')).attr('id', 'btnSet').text('設置').appendTo(container)
  179. .click(function () {
  180. win.gmc.open();
  181. });
  182. container
  183. .find('div')
  184. .addClass('btn1')
  185. .hover(function (e) {
  186. let o = $(this)
  187. o.data('old_opacity', o.css('opacity'))
  188. .data('old_border', o.css('border'))
  189. o.css('opacity', 1).css('border', '1px solid black')
  190. }, function (e) {
  191. let o = $(this)
  192. o.css('opacity', o.data('old_opacity')).css('border', o.data('old_border'))
  193. })
  194. container.appendTo('body');
  195. autoFind(() => win.location.href.indexOf('wkgo.xyz/forum') > -1, 'wkgo', 'a.s.xst', el => el.text(), $, setBtn, win);
  196.  
  197. })
  198. })
  199.  
  200.  
  201. })(function (FILE_URL, async = true) {
  202. return new Promise((resolve, reject) => {
  203. let scriptEle = document.createElement("script");
  204. scriptEle.setAttribute("src", FILE_URL);
  205. scriptEle.setAttribute("type", "text/javascript");
  206. scriptEle.setAttribute("async", async);
  207. // success event
  208. scriptEle.addEventListener("load", () => {
  209. resolve(FILE_URL)
  210. });
  211. // error event
  212. scriptEle.addEventListener("error", (ev) => {
  213. reject(ev);
  214. });
  215. if (document.currentScript)
  216. document.currentScript.insertBefore(scriptEle)
  217. else
  218. (document.head || document.getElementsByTagName('head')[0]).appendChild(scriptEle);
  219. })
  220. });