您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Remove sports stories from the Guardian frontpage, as well as links to the sports sections. This requires that you use what is currently (Jun 2014) the "beta" version of the Guardian, although this will presumably one day become the main version.
当前为
// ==UserScript== // @name Guardian Anti-Jock // @namespace http://xyxyx.org/ // @include http://www.theguardian.com/* // @version 0.3 // @description Remove sports stories from the Guardian frontpage, as well as links to the sports sections. This requires that you use what is currently (Jun 2014) the "beta" version of the Guardian, although this will presumably one day become the main version. // @grant none // ==/UserScript== function getSection(sectionName) { var sections = document.getElementsByTagName("section"); for (var i = 0; i < sections.length; i++) { if (sections.item(i).attributes.getNamedItem("data-component").value === sectionName) { return sections.item(i); } } } function getNavItem(name) { var navItems = document.getElementsByClassName("nav__item"); for (var i = 0; i < navItems.length; i++) { var navItem = navItems.item(i); var link = navItem.children.item(0); if( link.attributes.getNamedItem('data-link-name').value === name) { navItem.parentNode.removeChild(navItem); } } } function removeFrontPageStory(pattern) { var frontPageItems = document.getElementsByClassName("item__container"); for (var i = 0; i < frontPageItems.length; i++) { var frontPageItem = frontPageItems.item(i); var link = frontPageItem.children.item(0).href; if (link.match(pattern)) { console.log("Matches " + link + ":" + link) var container = frontPageItem.parentNode.parentNode; console.log("Container = " + container); container.parentNode.removeChild(container); } } // TODO frontPageItems = document.getElementsByClassName("fromage__container"); for (var i = 0; i < frontPageItems.length; i++) { var frontPageItem = frontPageItems.item(i); var link = frontPageItem.children.item(0).href; if (link.match(pattern)) { console.log("Matches " + link + ":" + link) var container = frontPageItem.parentNode.parentNode; console.log("Container = " + container); container.parentNode.removeChild(container); } } } try { var section; section = getSection('sport'); if (section) { section.style.visibility = 'hidden'; } section = getSection('world-cup'); if (section) { section.style.visibility = 'hidden'; } var navItem = getNavItem("/sport"); if (navItem) { navItem.style.visibility = 'hidden'; } var navItem = getNavItem("/football"); if (navItem) { navItem.style.visibility = 'hidden'; } var navItem = getNavItem("/fashion"); if (navItem) { navItem.style.visibility = 'hidden'; } removeFrontPageStory(/\/football\//); removeFrontPageStory(/\/sport\//); } catch (e) { console.log(e); }