Clean CNN

Minimizes distractions in favor of trending top news only.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey, το Greasemonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

You will need to install an extension such as Tampermonkey to install this script.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Userscripts για να εγκαταστήσετε αυτόν τον κώδικα.

You will need to install an extension such as Tampermonkey to install this script.

Θα χρειαστεί να εγκαταστήσετε μια επέκταση διαχείρισης κώδικα χρήστη για να εγκαταστήσετε αυτόν τον κώδικα.

(Έχω ήδη έναν διαχειριστή κώδικα χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Έχω ήδη έναν διαχειριστή στυλ χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

// ==UserScript==
// @name            Clean CNN
// @description     Minimizes distractions in favor of trending top news only.
// @version         0.7
// @namespace       https://github.com/sm18lr88
// @match           *://www.cnn.com/*
// @run-at          document-start
// @grant           none
// @license         MIT
// ==/UserScript==

(function () {
  'use strict';

  const zoneSelectors = Array.from({ length: 20 }, (_, i) => [
    `.zone-${i + 3}-observer.zone--t-light.zone`,
    `.zone-${i + 3}-observer.zone--t-dark.zone`,
    `.product-zone-${i + 3}-observer.product-zone--t-light.product-zone`,
    `.product-zone-${i + 3}-observer.product-zone--t-dark.product-zone`
  ]).flat();

  const additionalSelectors = [
    '.header__wrapper-outer',
    '.layout-homepage__bottom.layout__bottom',
    '.social-share',
    '.container_list-headlines-with-images.container',
    '.video-resource > .ad-feedback-link-container',
    '.layout-with-rail__rail.layout__rail',
    '.layout-with-rail__bottom.layout__bottom',
    '.layout-no-rail__bottom.layout__bottom',
    '.product-zone--t-light.product-zone',
    ...Array.from({ length: 10 }, (_, i) => `div.related-content--article.related-content:nth-of-type(${i + 1})`),
  ];

  const allSelectors = [
    ...zoneSelectors,
    ...additionalSelectors,
  ];

  function removeElements() {
    allSelectors.forEach(selector => {
      const elements = document.querySelectorAll(selector);
      elements.forEach(element => element.remove());
    });
  }

  // Observe changes in the document body
  const observer = new MutationObserver(removeElements);
  window.addEventListener('DOMContentLoaded', () => {
    observer.observe(document.body, { childList: true, subtree: true });
    removeElements();
  });
})();