我希望有人可以帮助我.我想通过扩展重新声明js函数.例如,网站上有基本的js功能:
function foo(){
..something here..
}
Run Code Online (Sandbox Code Playgroud)
我想通过自己的同名函数重新声明它.怎么做最容易的?
编辑1.我会尝试更好地解释.
网站上有一个本机代码:
Notifier = {
debug: false,
init: function (options) {
curNotifier = extend({
q_events: [],
q_shown: [],
q_closed: [],
q_max: 3,
q_idle_max: 5,
done_events: {},
addQueues: curNotifier.addQueues || {},
recvClbks: curNotifier.recvClbks || {},
error_timeout: 1,
sound: new Sound('mp3/bb1'),
sound_im: new Sound('mp3/bb2')
}, options);
if (!this.initFrameTransport() && !this.initFlashTransport(options)) {
return false;
}
this.initIdleMan();
if (!(curNotifier.cont = ge('notifiers_wrap'))) {
bodyNode.insertBefore(curNotifier.cont = ce('div', {id: 'notifiers_wrap', className: 'fixed'}), ge('page_wrap'));
}
},
destroy: function () {
Notifier.hideAllEvents(); …
Run Code Online (Sandbox Code Playgroud) 制作firefox插件的最简单方法是什么,它重复了这个chrome功能:
chrome.webRequest.onBeforeRequest.addListener(
function(info) {
if(info.url.indexOf("notifier") + 1){
return {redirectUrl: "https://domain.null/1.js"};
}
},
{
urls: [
"*://domain2.null/*"
],
types: ["script"]
}, ["blocking"]);
Run Code Online (Sandbox Code Playgroud)
我知道firefox中的nsIContentPolicy,但我不明白如何使用它.
所有的意见,建议和帮助将不胜感激
我已经确定了无重启扩展的问题.
阻止内容我们可以使用nsIContentPolicy作为Wladimir说.我们还可以使用windowListener(aWindow.gBrowser)将脚本注入页面.
例如,这种做法非常有效:https://github.com/jvillalobos/AMO-Admin-Assistant/blob/master/src/bootstrap.js
javascript browser firefox firefox-addon google-chrome-extension