Clean CNN

Minimizes distractions in favor of trending top news only.

  1. // ==UserScript==
  2. // @name Clean CNN
  3. // @description Minimizes distractions in favor of trending top news only.
  4. // @version 0.7
  5. // @namespace https://github.com/sm18lr88
  6. // @match *://www.cnn.com/*
  7. // @run-at document-start
  8. // @grant none
  9. // @license MIT
  10. // ==/UserScript==
  11.  
  12. (function () {
  13. 'use strict';
  14.  
  15. const zoneSelectors = Array.from({ length: 20 }, (_, i) => [
  16. `.zone-${i + 3}-observer.zone--t-light.zone`,
  17. `.zone-${i + 3}-observer.zone--t-dark.zone`,
  18. `.product-zone-${i + 3}-observer.product-zone--t-light.product-zone`,
  19. `.product-zone-${i + 3}-observer.product-zone--t-dark.product-zone`
  20. ]).flat();
  21.  
  22. const additionalSelectors = [
  23. '.header__wrapper-outer',
  24. '.layout-homepage__bottom.layout__bottom',
  25. '.social-share',
  26. '.container_list-headlines-with-images.container',
  27. '.video-resource > .ad-feedback-link-container',
  28. '.layout-with-rail__rail.layout__rail',
  29. '.layout-with-rail__bottom.layout__bottom',
  30. '.layout-no-rail__bottom.layout__bottom',
  31. '.product-zone--t-light.product-zone',
  32. ...Array.from({ length: 10 }, (_, i) => `div.related-content--article.related-content:nth-of-type(${i + 1})`),
  33. ];
  34.  
  35. const allSelectors = [
  36. ...zoneSelectors,
  37. ...additionalSelectors,
  38. ];
  39.  
  40. function removeElements() {
  41. allSelectors.forEach(selector => {
  42. const elements = document.querySelectorAll(selector);
  43. elements.forEach(element => element.remove());
  44. });
  45. }
  46.  
  47. // Observe changes in the document body
  48. const observer = new MutationObserver(removeElements);
  49. window.addEventListener('DOMContentLoaded', () => {
  50. observer.observe(document.body, { childList: true, subtree: true });
  51. removeElements();
  52. });
  53. })();