English 中文(简体)
如何使用内容文字——使用Add-on建筑商的内容说明——查阅网页所附变量
原标题:How to access a variable attached to the webpage using contentscript in - contentscript using Add-on builder

我利用增建机设立了一个补充项目。 附有<代码>Mod的内容说明,载于main.js

我的内容说明是使用<代码>文件.createElement(创建的有活力的标签数目。 这样做的办法是创建文件索引,并在网页上添加文字标签。 我的法典如下。

contentscriptFile:

addJS_Node ("var count=0;");
function LogDocCreateElement ()
{
    var oldDocumentCreateElement = document.createElement;   
    document.createElement = function(tagName)
    {
       var elem = oldDocumentCreateElement.apply (document, arguments);     
       console.log("Dynamically created a(n)", tagName);
       count++;     
       return elem;
    } 
}
addJS_Node (null, null, LogDocCreateElement);
function addJS_Node (text, s_URL, funcToRun) {
     var D                                   = document;
     var scriptNode                          = D.createElement ( script );
     scriptNode.type                         = "text/javascript";
     if (text)       scriptNode.textContent  = text;
     if (s_URL)      scriptNode.src          = s_URL;
     if (funcToRun)  scriptNode.textContent  =  (  + funcToRun.toString() +  )() ;
     var targ = D.getElementsByTagName ( head )[0] || D.body || D.documentElement;
     targ.appendChild (scriptNode);    
}
window.addEventListener("load", function() {alert(count) }, false);

现在我成为无选择的例外情况:<代码>。 误差:未定义。

我如何能够查阅<条码>变量?

最佳回答
问题回答

暂无回答




相关问题
Accessing an iFrame s dom from a Firefox Extension

I ve spent a long time trying different things to get this to work but nothing does and documentation is not helping much. I m trying to populate a form inside an iframe that I dynamically inject ...

Google Analytics to track FireFox extension use

I m developing a Firefox extension and would like to track its use with google analytics, but I can t get it working. I ve tried manually calling a function from ga.js, but that didn t work for some ...

Accessing tabs on Firefox with a C++ XPCOM extension

What XPCOM interfaces should I use to detect opening, closing and switching of tabs and also get their associated URL from a firefox extension? I have seen instances of code that manage tabs in JS, ...

Open links in new tab in Firefox

I am developing an Firefox extension. How can all the links on a webpage to be opened in a new tab?

Rendering web page as thumbnail

I asked this question earlier, since I am a little new to Firefox extension development, the canvas thing for Firefox went a little over my head. Apologies for reposting this again. with the first ...

热门标签