Greasy Fork

Greasy Fork is available in English.

Purge Huffington Post from Yahoo News feed

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

目前为 2014-11-22 提交的版本,查看 最新版本

// ==UserScript==
// @name       Purge Huffington Post from Yahoo News feed
// @version    1.2
// @namespace  edward
// @author	   Edward
// @description  Eliminates Huffington Post Entries from Yahoo News list. Will run through iterative cycles to continue cleaning up the page as more are loaded.
// @include		 http*://*.yahoo.*/*
// @grant          unsafeWindow
// ==/UserScript==


setInterval(removeSpam, 2000);
function removeSpam() {
var spanTags = document.getElementsByTagName('span');
var spamNames = ['Huffington Post', 'The Huffington Post'];
var found;
for (var i = 0; i < spanTags.length; i++) {
  if (contains(spamNames, spanTags[i].textContent)) {
    found = spanTags[i];
    parentBlock = 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);
}
	
}