Demonoid remove clutter

Removes ads and VPN shilling on Demonoid

  1. // ==UserScript==
  2. // @name Demonoid remove clutter
  3. // @namespace jxq8p6u6r9wtn2f6617i
  4. // @match https://demonoid.is/*
  5. // @match https://www.demonoid.is/*
  6. // @match https://dnoid.pw/*
  7. // @match https://www.dnoid.pw/*
  8. // @match https://dnoid.to/*
  9. // @match https://www.dnoid.to/*
  10. // @grant none
  11. // @version 1.2.1
  12. // @description Removes ads and VPN shilling on Demonoid
  13. // @run-at document-start
  14. // @inject-into content
  15. // @license MIT
  16. // ==/UserScript==
  17.  
  18. (function () {
  19. "use strict";
  20.  
  21. const { HTMLUnknownElement } = window;
  22.  
  23.  
  24. function hide(element, state = true) {
  25. if (!element) {
  26. return;
  27. }
  28.  
  29. element.hidden = state;
  30. if (state) {
  31. element.style.setProperty("display", "none", "important");
  32. } else {
  33. element.style.removeProperty("display");
  34. }
  35. }
  36.  
  37.  
  38. function inject(unwrap = (x)=>x, exporter = unwrap) {
  39. const proxyHandler = new window.Object();
  40. proxyHandler.apply = exporter(function (write, that, args) {
  41. if (args[0]?.toLowerCase?.().indexOf?.("<script") === -1) {
  42. return write.apply(that, args);
  43. }
  44. });
  45.  
  46. const doc = unwrap(Document.prototype);
  47. doc.write = new window.Proxy(doc.write, proxyHandler);
  48. }
  49.  
  50.  
  51. let unsafeDoc = document;
  52.  
  53. if (typeof globalThis.XPCNativeWrapper === "function") {
  54. inject(XPCNativeWrapper.unwrap, (f) => exportFunction(f, window));
  55. // Why is the Firefox sandbox so weird
  56. unsafeDoc = XPCNativeWrapper.unwrap(unsafeDoc);
  57. } else {
  58. const script = document.createElement("script");
  59. script.text = `"use strict";(${inject})();`;
  60. (document.head ?? document.documentElement).prepend(script);
  61. script.remove();
  62. }
  63.  
  64.  
  65. hide(document.documentElement);
  66.  
  67.  
  68. const sheet = new CSSStyleSheet();
  69. sheet.replace("#share-buttons,#downloadbox a:first-of-type,#downloadbox br:first-of-type,#rss_feed_link br,#rss_feed_link2 br,center a[href$='.php'] img[alt='']{display:none!important;}");
  70. // Copy to unprivileged page scope array or this won't work in Firefox
  71. unsafeDoc.adoptedStyleSheets = window.Array.from([sheet].concat(document.adoptedStyleSheets));
  72.  
  73.  
  74.  
  75. window.addEventListener("DOMContentLoaded", () => {
  76. // Hide big VPN message
  77. let adElement = document.evaluate(".//*[contains(text(), 'Get VPN')]", document.body, null, XPathResult.ANY_UNORDERED_NODE_TYPE, null).singleNodeValue;
  78. while (adElement && !(adElement instanceof HTMLUnknownElement)) {
  79. adElement = adElement.parentNode;
  80. }
  81.  
  82. if (adElement?.tagName) {
  83. for (const ad of document.getElementsByTagName(adElement.tagName)) {
  84. hide(ad);
  85. }
  86. }
  87.  
  88.  
  89. // Hide big black whitelist box
  90. adElement = document.evaluate(".//*[contains(text(), 'Ad-Blocker')]/ancestor-or-self::table", document.body, null, XPathResult.ANY_UNORDERED_NODE_TYPE, null).singleNodeValue;
  91. hide(adElement);
  92.  
  93.  
  94. hide(document.body.querySelector("td > hr + span")?.closest("tr")); // Sponsored Links box on torrent pages
  95.  
  96. const btcNags = document.body.querySelectorAll("a[href^='bitcoin:']");
  97. for (const nag of btcNags) {
  98. hide(nag.closest("span, p, div.block"));
  99. }
  100. });
  101.  
  102.  
  103. window.addEventListener("DOMContentLoaded", hide.bind(null, document.documentElement, false));
  104. })();

QingJ © 2025

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