Greasy Fork

来自缓存

Greasy Fork is available in English.

No more Fox/Newsmax on Yahoo News

Remove Fox and Newsmax from Yahoo News feed. Variation on another script by Edward.

当前为 2016-11-06 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name        No more Fox/Newsmax on Yahoo News
// @namespace   bbstats
// @version     7
// @author      edward
// @description Remove Fox and Newsmax from Yahoo News feed.  Variation on another script by Edward.
// @include		 http*://*.yahoo.*/*
// @grant          unsafeWindow
// ==/UserScript==
setInterval(removeSpam, 2000);
function removeSpam() {
var spanTags = document.getElementsByTagName('span');
var spamNames = ['Fox News Insider','Fox News', 'FOX News Videos', 'Fox Business Videos', 'Newsmax', 'CNS News', 'The Federalist', 'The New York Observer', 'New York Post'];
var found;
for (var i = 0; i < spanTags.length; i++) {
  if (contains(spamNames, spanTags[i].textContent)) {
    console.log("blocking " + spanTags[i].textContent)
    found = spanTags[i];
    parentBlock = getParent(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);
}
	
}