Weiblock

去除微博上烦人的东西。

  1. // ==UserScript==
  2. // @name Weiblock
  3. // @name:zh-CN Weiblock
  4. // @namespace http://tampermonkey.net/
  5. // @version 0.4
  6. // @description Block the annoying things on Weibo.
  7. // @description:zh-CN 去除微博上烦人的东西。
  8. // @author lujjjh
  9. // @include https://weibo.com/*
  10. // @include https://*.weibo.com/*
  11. // @grant none
  12. // @run-at document-start
  13. // ==/UserScript==
  14.  
  15. (function () {
  16. "use strict";
  17.  
  18. const observer = new MutationObserver((mutations) => {
  19. for (let { type, addedNodes } of mutations) {
  20. if (type !== "childList") continue;
  21. for (let node of addedNodes) {
  22. if (!(node instanceof HTMLElement)) continue;
  23. if (node.parentNode) node = node.parentNode;
  24. // Uncheck the autoplay switch.
  25. node
  26. .querySelectorAll(".VideoList_switch_1-TPG .woo-switch-checked")
  27. .forEach((node) => node.click());
  28. // Show the comments by default.
  29. node
  30. .querySelectorAll(".Index_tabitem_17MDI:first-child > div")
  31. .forEach((node) => node.click());
  32. // Remove the annoying audio and popup when a video is finished.
  33. node
  34. .querySelectorAll(".AfterPatch_bg_34rqc")
  35. .forEach((node) => node.remove());
  36. }
  37. }
  38. });
  39.  
  40. observer.observe(document.documentElement, {
  41. childList: true,
  42. subtree: true,
  43. });
  44. })();