我偶然发现
this userscript
它在谷歌Chrome浏览器中运行。
我想把它用作谷歌Chrome扩展,因为这将给我将许多其他代码从用户脚本转换为谷歌Chrome扩展的经验。
有人能给我一个循序渐进的教程,告诉我如何用
this userscript code
?
// ==UserScript==
// @name Facebook Ads Hider
// @author Jose Luis Martin
// @namespace http://joseluismartin.info
// @description Hide Ads on Facebook
// @include http://www.facebook.com/*
// @run-at document-start
//
// ==/UserScript==
if (document.addEventListener) {
document.addEventListener("DOMNodeInserted", onNodeInserted, false);
}
// Event listener to hide ads containers
function onNodeInserted(event) {
target = event.target;
if (target.className == "ego_column") {
hideElement(target);
}
}
// trivial hide of ads container
function hideElement(elto) {
elto.style.visibility = "hidden";
elto.style.hight = "0px";
elto.style.width = "0px";
}
请不要回复说没有必要这样做,因为用户脚本可以在Google Chrome上原生运行。我这样做是为了学习如何制作谷歌Chrome扩展。
The Google Chrome extension tutorial
非常不利于理解,让我呕吐——我不知道是谁做的!