bilibili-filter-roll-ads

过滤b站换一换中的广告。(filter bilibili roll ads.)

  1. // ==UserScript==
  2. // @name bilibili-filter-roll-ads
  3. // @namespace Violentmonkey Scripts
  4. // @match https://www.bilibili.com/
  5. // @run-at document-start
  6. // @grant none
  7. // @version 1.2
  8. // @author mesimpler
  9. // @license MIT
  10. // @description 过滤b站换一换中的广告。(filter bilibili roll ads.)
  11. // ==/UserScript==
  12.  
  13. const rmcd = "//api.bilibili.com/x/web-interface/wbi/index/top/feed/rcmd";
  14. const feedNum = 12;
  15.  
  16. window.fetch = new Proxy(window.fetch, {
  17. apply: function (target, thisArg, argumentsList) {
  18. const [url, options] = argumentsList;
  19.  
  20. // 请求命中
  21. if (url.includes(rmcd)) {
  22. const hookUrl = url.replace("ps=10", `ps=${feedNum}`);
  23. const hookOptions = {
  24. ...options,
  25. params: {
  26. ...options.params,
  27. ps: feedNum,
  28. },
  29. };
  30.  
  31. return Reflect.apply(target, thisArg, [hookUrl, hookOptions]).then(
  32. (response) => {
  33. return response.json().then((res) => {
  34. // 过滤广告特征
  35. res.data.item = res.data.item.filter((video) => video.id !== 0);
  36. return new Response(JSON.stringify(res), response);
  37. });
  38. }
  39. );
  40. }
  41.  
  42. // 调用原始 fetch
  43. return Reflect.apply(target, thisArg, argumentsList);
  44. },
  45. });

QingJ © 2025

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