Sleazy Fork is available in English.

avtb auto open

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

  1. // ==UserScript==
  2. // @name avtb auto open
  3. // @namespace websiteEnhancement
  4. // @author jimmly
  5. // @version 2024.1.25
  6. // @description 增加页面顶部底部按钮和一键下种按钮
  7. // @create 2023-9-21
  8. // @include *avtb*
  9. // @grant GM_getValue
  10. // @grant GM_setValue
  11. // @grant GM.getValue
  12. // @grant GM.setValue
  13. // @license MIT
  14. // @run-at document-idle
  15. // ==/UserScript==
  16.  
  17. /**
  18. * @typedef { import('jquery') } $
  19. * @typedef { import('jQuery') } jQuery
  20. */;
  21. ; (async function (loadJS) {
  22. loadJS("https://update.greasyfork.org/scripts/483173/GM_config_cnjames.js")
  23. .then(v => loadJS("https://update.sleazyfork.org/scripts/476583/common_libs_of_array.js"))
  24. .then(v => {
  25. withJQuery(function ($, win) {
  26.  
  27. let w = 40, h = 40;
  28. addStyle(`
  29. a:link{color:green;}
  30. a:hover{color:red;}
  31. a:active{color:yellow;}
  32. a:visited{color:orange;}
  33. .btn1 {
  34. opacity:0.8;-moz-transition-duration:0.2s;-webkit-transition-duration:0.2s;
  35. padding:1px; margin-top:1px;
  36. font-size: 10; text-align: center; vertical-align: middle; line-height:${h}px;
  37. border-radius:5px 5px 5px 5px;cursor:pointer; left:0px;z-index:9999;
  38. background:white;
  39. width:${w}px;height:${h}px;
  40. }
  41. `);
  42. let container = $(document.createElement('div')).css({
  43. 'cssText': `position:fixed;top:15%;width:${w}px;height:${h * 7}px;left:0px;z-index:9999`
  44. });
  45.  
  46. if (win.location.href.indexOf('tags') == -1) {
  47. //下载按钮
  48. let downloadBtn = $(document.createElement('div')).text('下載').appendTo(container)
  49. .click(function () {
  50. let url = $(".t_attachlist > dt > a:eq(1)").prop('href');
  51. let filename = $("div.mainbox.viewthread>h1").text().trim() + '.torrent';
  52. console.log(filename)
  53. $.ajax({
  54. url,
  55. success: function (result, status, xhr) {
  56. let alink = document.createElement('a');
  57. alink.download = filename;
  58. alink.href = $(result).find("#downloadBtn").prop('href');
  59. document.body.appendChild(alink);
  60. alink.click();
  61. },
  62. error: function (xhr, status, error) {
  63. console.log(status, error)
  64. }
  65. });
  66. });
  67.  
  68. $(document).keydown(function (event) {
  69. let e = event || win.event;
  70. let k = e.keyCode || e.which;
  71. if (k === 16) {
  72. // isCtrl = true;
  73. startBtn.click()
  74. } else if (k === 38) { //up
  75. event.stopPropagation()
  76. slowBtn.click()
  77.  
  78. } else if (k === 40) {//down
  79. event.stopPropagation()
  80. //fastBtn.click()
  81. }
  82. })
  83. // $(win).blur(function () {
  84. // clearTimeout(win.___t)
  85. // win.___t = 0
  86. // }).focus(function () {
  87. // win.___func();
  88. // })
  89.  
  90. win.__wait = 900
  91. win.__step = 100;
  92. win.___func = function () {
  93. win.______h = $(document).scrollTop() + win.__step;
  94. if (win.______h >= $(document).height() - $(win).height()) {
  95. clearTimeout(win.___t)
  96. // win.___t = setTimeout(win.___func, 30000)
  97. } else {
  98. $(document).scrollTop(win.______h);
  99. win.___t = setTimeout(win.___func, win.__wait)
  100. }
  101. };
  102. }
  103. else {
  104. $('tr').hover(
  105. function () {
  106. $(this).find('*').css("background-color", "#9AAAC7")
  107. }, function () {
  108. $(this).find('*').css("background-color", '');
  109. });
  110. }
  111.  
  112. //最顶按钮
  113. let
  114. toTopBtn = $(document.createElement('div')).text('Top').appendTo(container)
  115. .click(function () {
  116. win.scrollTo(0, 0);
  117. }),
  118. //最低按钮
  119. toBottomBtn = $(document.createElement('div')).text('Bottom').appendTo(container)
  120. .click(function () {
  121. win.scrollTo(0, document.body.scrollHeight);
  122. }),
  123. //加速
  124. fastBtn = $(document.createElement('div')).text('加速').appendTo(container)
  125. .click(function () {
  126. if (win.__wait > 5) {
  127. win.__wait = win.__wait / 1.5
  128. } else {
  129. win.__wait = 5
  130. }
  131. }),
  132. startBtn = $(document.createElement('div')).text('啓停').appendTo(container)
  133. .click(function () {
  134. if (!!!win.___t) {
  135. win.___func();
  136. } else {
  137. clearTimeout(win.___t)
  138. win.___t = 0
  139. }
  140. }),
  141. slowBtn = $(document.createElement('div')).text('減速').appendTo(container)
  142. .click(function () {
  143. win.__wait *= 1.5
  144. }),
  145. setBtn = $(document.createElement('div')).text('設置').appendTo(container)
  146. .click(function () {
  147.  
  148. });
  149. container
  150. .find('div')
  151. .addClass('btn1')
  152. .hover(function (e) {
  153. let o = $(this)
  154. o.data('old_opacity', o.css('opacity'))
  155. .data('old_border', o.css('border'))
  156. o.css('opacity', 1).css('border', '1px solid black')
  157. }, function (e) {
  158. let o = $(this)
  159. o.css('opacity', o.data('old_opacity')).css('border', o.data('old_border'))
  160. })
  161. container.appendTo('body');
  162.  
  163. autoFind(gmc => !(/[www]+\.avtb\.info\/\d+\//g).test(win.location.href), 'avtb', '.video>a', el => el.attr('title'), $, setBtn);
  164.  
  165. })
  166. })
  167.  
  168.  
  169. })(function (FILE_URL, async = true) {
  170. return new Promise((resolve, reject) => {
  171. let scriptEle = document.createElement("script");
  172. scriptEle.setAttribute("src", FILE_URL);
  173. scriptEle.setAttribute("type", "text/javascript");
  174. scriptEle.setAttribute("async", async);
  175. // success event
  176. scriptEle.addEventListener("load", () => {
  177. resolve(FILE_URL)
  178. });
  179. // error event
  180. scriptEle.addEventListener("error", (ev) => {
  181. reject(ev);
  182. });
  183. if (document.currentScript)
  184. document.currentScript.insertBefore(scriptEle)
  185. else
  186. (document.head || document.getElementsByTagName('head')[0]).appendChild(scriptEle);
  187. })
  188. });