如何编写firefox扩展,在firebug的页面上下文中运行javascript代码

ccp*_*ava 5 javascript firebug firefox-addon

我知道出于安全原因,这不容易实现,但是有一种方法可以像萤火虫那样做...

请大家帮忙,想在页面的上下文中调用一些脚本来实现一些效果......

基本上,我想实现两个功能:1.如果尚未存在,则自动将jQuery添加到任何网页.2.当打开某个地址时,调用该页面的方法自动通知服务器.(页面的ajax功能)

我试图注射身体,没有运气.试图获取窗口对象,但是无法调用该函数.

将尝试将位置更改为:javascript:alert('test inject');

很多thx.

ccp*_*ava 2

好的,在阅读了一些官方文档和 GreaseMonkey 的源代码之后,我得到了以下基本上对我有用的方法。

希望它能节省某人的时间:

var appcontent = document.getElementById("appcontent");   // browser  
    if (appcontent) {
         appcontent.addEventListener("DOMContentLoaded", function (evnt) {
            var doc = evnt.originalTarget; 
            var win = doc.defaultView;
            var unsafeWin = win.wrappedJSObject;

            // vote.up is the function on the page's context
            // which is take from this site as example
            unsafeWin.vote.up(...);
         }, true);
    }
}
Run Code Online (Sandbox Code Playgroud)