Hide Some Ads

Hide some ads on online-fix.me

  1. // ==UserScript==
  2. // @name Hide Some Ads
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.2
  5. // @description Hide some ads on online-fix.me
  6. // @match https://online-fix.me/*
  7. // @grant none
  8. // @license MIT
  9. // ==/UserScript==
  10.  
  11. (function() {
  12. 'use strict';
  13.  
  14. function hideAds() {
  15. let adElements = document.querySelectorAll('.no-pop');
  16. adElements.forEach(element => {
  17. element.style.display = 'none';
  18. });
  19.  
  20. let adBlockElement = document.querySelector('#dle-content > div > article > div.full-story-header.wide-block.clr');
  21. if (adBlockElement) {
  22. let childNodes = adBlockElement.childNodes;
  23. for (let node of childNodes) {
  24. if (node.nodeType === Node.TEXT_NODE && node.textContent.trim().includes("РЕКЛАМНЫЙ БЛОК:")) {
  25. node.textContent = '';
  26. break;
  27. }
  28. }
  29. }
  30.  
  31. let sidebarBlocks = document.querySelectorAll('.sidebar-block');
  32. sidebarBlocks.forEach(block => {
  33. if (block.textContent.includes("Если Вы хотите поддержать проект") ||
  34. block.textContent.includes("If you want to support the project")) {
  35. block.style.display = 'none';
  36. }
  37. });
  38.  
  39. let adPlayerElements = document.querySelectorAll('div[data-ad-player]');
  40. adPlayerElements.forEach(element => {
  41. element.style.display = 'none';
  42. });
  43.  
  44.  
  45. let articleElement = document.querySelector('div.article.fixed.clr');
  46. if (articleElement) {
  47. let parentArticle = articleElement.closest('article');
  48. if (parentArticle) {
  49. parentArticle.style.display = 'none';
  50. }
  51. }
  52. }
  53.  
  54. hideAds();
  55.  
  56. let observer = new MutationObserver(mutations => {
  57. for (let mutation of mutations) {
  58. if (mutation.type === 'childList') {
  59. hideAds();
  60. }
  61. }
  62. });
  63. observer.observe(document.body, {childList: true, subtree: true});
  64. })();