Greasy Fork

Heise Apple / Mac / IPhone News Remover

Remove all Mac&I news from the heise.de frontpage and newsticker

目前为 2023-06-15 提交的版本。查看 最新版本

// ==UserScript==
// @name         Heise Apple / Mac / IPhone News Remover
// @namespace    heise
// @version      0.2
// @description  Remove all Mac&I news from the heise.de frontpage and newsticker
// @author       synogen
// @match        https://www.heise.de/*
// @grant        none
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';

    let searchSelector = 'span.theme-mac-and-i,div[title="Ein Beitrag von: Mac & i"]'; // script searches for this all instances of this and then searches through its parent elements
    let titleSelector = 'span[data-component="TeaserHeadline"],span[class="a-article-teaser__title-text"]'; // selector to find article headline among the parents
    let tagToRemove = 'article'; // if this tag is found among the parents it gets hidden

    document.querySelectorAll(searchSelector).forEach(a => {
      let parent = a.parentElement;
      while (parent) {
          let title = '';
          if (!title) {
              let headline = parent.querySelector(titleSelector);
              if (headline) title = headline.innerHTML.trim();
          }
          if ('article'.localeCompare(parent.tagName.toLowerCase()) == 0) {
              parent.style.display = 'none';
              console.log('Removed article "' + title + '"');
              parent = null;
          } else {
              parent = parent.parentElement;
          }
      }
    });
})();