Clean CNN

Minimizes distractions in favor of trending top news only.

スクリプトをインストールするには、Tampermonkey, GreasemonkeyViolentmonkey のような拡張機能のインストールが必要です。

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

スクリプトをインストールするには、TampermonkeyViolentmonkey のような拡張機能のインストールが必要です。

スクリプトをインストールするには、TampermonkeyUserscripts のような拡張機能のインストールが必要です。

このスクリプトをインストールするには、Tampermonkeyなどの拡張機能をインストールする必要があります。

このスクリプトをインストールするには、ユーザースクリプト管理ツールの拡張機能をインストールする必要があります。

(ユーザースクリプト管理ツールは設定済みなのでインストール!)

このスタイルをインストールするには、Stylusなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus などの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus tなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

(ユーザースタイル管理ツールは設定済みなのでインストール!)

このスクリプトの質問や評価の投稿はこちら通報はこちらへお寄せください
// ==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();
  });
})();