Acfun屏蔽计划

帮助你屏蔽不想看的UP主

目前为 2023-01-16 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name Acfun屏蔽计划
  3. // @namespace http://tampermonkey.net/
  4. // @version 3.004
  5. // @author 人文情怀
  6. // @exclude https://www.acfun.cn/login/*
  7. // @exclude http://www.acfun.cn/login/*
  8. // @match http://www.acfun.cn/a/ac*
  9. // @match http://www.acfun.cn/v/list63
  10. // @match https://www.acfun.cn/a/ac*
  11. // @match http://www.acfun.cn/*
  12. // @match https://www.acfun.cn/*
  13. // @match https://www.acfun.cn/v/list*
  14. // @match http://www.acfun.cn/a/ac*
  15. // @match https://www.acfun.cn/a/ac*
  16. // @match http://www.acfun.cn/v/ac*
  17. // @match https://www.acfun.cn/v/ac*
  18. // @match https://www.acfun.cn/v/as*
  19. // @match http://www.acfun.cn/v/as*
  20. // @connect gf.qytechs.cn
  21. // @connect localhost
  22. // @grant GM_getValue
  23. // @grant GM_setValue
  24. // @grant GM.getValue
  25. // @grant GM.setValue
  26. // @grant GM_deleteValue
  27. // @grant GM.deleteValue
  28. // @grant GM_xmlhttpRequest
  29. // @grant GM.xmlHttpRequest
  30. // @grant unsafeWindow
  31. // @run-at document-start
  32. // @description 帮助你屏蔽不想看的UP主
  33. // @license MIT
  34. // ==/UserScript==
  35.  
  36. // 添加上面的exclude两行表示这个脚本不会在登陆页面出现
  37. //这只是个代码下载器,用来下载正式的代码,具体想了解代码的人可以自己去看看。
  38. // 开源代码: https://gf.qytechs.cn/zh-CN/scripts/387296-acfunblock%E5%BC%80%E6%BA%90%E4%BB%A3%E7%A0%81
  39. (function(){
  40.  
  41. let dev = false;
  42.  
  43. let empty = (a) => {
  44. return typeof a === "undefined" ? () => {
  45. console.log("EmptyFunction Called");
  46. console.trace();
  47. } : a;
  48. };
  49. let GM_set = typeof GM_setValue === "undefined" ?
  50. function (key, value, callback, failcallback) {
  51. let p = GM.setValue(key, value);
  52. p.then(empty(callback), empty(failcallback));
  53.  
  54.  
  55. }
  56. : function (key, value, callback) {
  57. let res = GM_setValue(key, value);
  58. callback();
  59. };
  60.  
  61.  
  62. let GM_get = typeof GM_getValue === "undefined" ?
  63. function (key, value, callback) {
  64. let p = GM.getValue(key, value);
  65. p.then((debug) => {
  66. empty(callback)(debug);
  67. }, () => {
  68. callback(value);
  69. });
  70. //console.log("empty", empty(callback));
  71. }
  72. : function (key, value, callback, failcallback) {
  73. let res = GM_getValue(key, value);
  74. callback(res);
  75. };
  76.  
  77. let xhttp = typeof GM_xmlhttpRequest !== "undefined" ? GM_xmlhttpRequest : GM.xmlHttpRequest;
  78.  
  79. //下载代码并运行
  80. function downloadScript(callback, i=0){
  81.  
  82. //debug url
  83. let debugUrl = "http://localhost:8080/acfunBlock-opensource.user.js?time="+(+new Date());
  84.  
  85. let urls = [
  86. "https://gf.qytechs.cn/scripts/387296-acfunblock%E5%BC%80%E6%BA%90%E4%BB%A3%E7%A0%81/code/AcfunBlock%E5%BC%80%E6%BA%90%E4%BB%A3%E7%A0%81.user.js", //开源地址
  87. "https://github.com/baldhumanity/AcfunComplement/raw/master/acfunBlock-opensource.user.js",//备用开源地址
  88. ]
  89.  
  90. if (i>=urls.length){
  91. console.log("DEBUG 插件下载失败!");
  92. return;
  93. }
  94.  
  95.  
  96. xhttp({
  97. nocache:true,
  98. method: "GET",
  99. url:dev ? debugUrl : urls[i],
  100. onload: function (response) {
  101. let text = response.responseText;
  102. callback(text);
  103. },
  104. onerror(evt) {
  105. console.log("DEBUG use fallback url.")
  106. downloadScript(callback, i+1);
  107.  
  108. }
  109. });
  110. }
  111.  
  112. function getVersion(s){
  113. try{
  114. if (typeof s === "undefined" || s==null || s==="undefined" || s==="") return 0;
  115. let p = /@version +(\d+\.\d+)/;
  116. let arr = p.exec(s);
  117. let latest = arr[1];
  118. return parseFloat(latest);
  119. }catch(e){
  120. return 0;
  121. }
  122. }
  123.  
  124.  
  125. function Initialise(){
  126. //Check if script is downloaded;
  127. GM_get("ACFUN_BLOCK_CODE","", (s)=>{
  128. let currentVersion = getVersion(s);
  129. console.log("Current Version = "+currentVersion);
  130. //如果已经有可用版本,先使用
  131. if (currentVersion>0 && !dev){
  132. var code = s;
  133.  
  134. setTimeout(()=>{
  135. eval(code);
  136. })
  137. }
  138. //检查更新
  139. downloadScript(
  140. (s)=>{
  141. if (typeof s === "undefined" || s==null || s==="undefined") {
  142. console.log("ACFUN屏蔽计划载入失败,请不要联系A站插件作者:人文情怀。")
  143. }
  144. let onlineVersion = getVersion(s);
  145. console.log("online Version = "+onlineVersion);
  146. //如果有更新
  147. if (onlineVersion> currentVersion || dev){
  148. //Update code
  149. GM_set("ACFUN_BLOCK_CODE", s, ()=>{
  150. //Updated, if this is the firsttime running:
  151. if (currentVersion==0 || dev){
  152. //如果没有可用版本,直接运行
  153. console.log("直接运行");
  154. setTimeout(()=>{
  155. eval(s);
  156. })
  157. }
  158. }, ()=>{
  159. console.log("ACFUN屏蔽计划缓存代码失败。请不要联系作者。");
  160. })
  161. }
  162. })
  163. })
  164. }
  165. function reset(){
  166. GM_set("ACFUN_BLOCK_CODE", "", ()=>{})
  167. }
  168.  
  169.  
  170.  
  171. if (unsafeWindow){
  172. unsafeWindow.reset = reset;
  173. }
  174. if (window){
  175. window.reset = reset;
  176. }
  177. //debug();
  178. Initialise();
  179. })();

QingJ © 2025

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