我偶然发现了this userscript,它可以在谷歌Chrome上运行。
我想使用它作为谷歌浏览器的扩展,因为这将给我的经验,以转换许多其他代码从用户脚本到谷歌浏览器的扩展。
有人能给我一个如何在this userscript code中创建Google Chrome扩展的循序渐进的教程吗
// ==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扩展。
The Google Chrome extension tutorial非常不好理解,让我作吐--我不知道是谁做的!
发布于 2012-09-12 20:50:02
在Google Chrome中,用户脚本是扩展。该脚本被打包为,并自动生成扩展manifest.json。
要走向“完全成熟”的扩展:
manifest.json,如中所示。@include和@run-at指令的值传输到要生成的manifest.json文件中。参考链接答案中的示例。中的说明对扩展模块进行打包
https://stackoverflow.com/questions/12387989
复制相似问题