Greasy Fork

Purge Huffington Post from Yahoo News feed - 2020

Eliminates Huffington Post Entries from Yahoo News list. Will run through iterative cycles to continue cleaning up the page as more are loaded. Based on original code by Edward.

当前为 2020-10-24 提交的版本,查看 最新版本

// ==UserScript==
// @name       Purge Huffington Post from Yahoo News feed - 2020
// @version    1.0
// @namespace  ezChx
// @author	   ezChx
// @description  Eliminates Huffington Post Entries from Yahoo News list. Will run through iterative cycles to continue cleaning up the page as more are loaded. Based on original code by Edward.
// @include		 http*://*.yahoo.*/*
// @grant          unsafeWindow
// ==/UserScript==


setInterval(removeSpam, 2000);
function removeSpam() {

    var spanTags = document.querySelectorAll("[data-publisher-id='the_huffington_post_584']");

    var found;
    for (var i = 0; i < spanTags.length; i++) {
        found = spanTags[i];
        var parentBlock = getParent(getParent(getParent(getParent(found))));
        removeAllChildren(parentBlock);
    }
}

function getParent(o) {
    return o.parentNode;
}

function contains(a, obj) {
    var i = a.length;
    while (i--) {
       if (a[i] === obj) {
           return true;
       }
    }
    return false;
}

function removeAllChildren(o) {
	while (o.firstChild) {
        o.removeChild(o.firstChild);
    }
}