javascript - How can I get the html of a page as a string in a Firefox extension? -


i need html of current page loaded string, may manipulate , use information later on. needing use in firefox extension, , having lot of trouble getting work.

i tried storing value using .outerhtml, had seen , got work in other places. here example of how worked:

var pagehtml = document.documentelement.outerhtml;  

i tried searching piece needed @ time, so:

document.getelementbyid("header") 

however, neither of these seem access html. assume because code operating in browser, not in document itself. how can go accessing html 'document' of page loaded in tab firefox extension.

the firefox addon sdk includes module called page-mod intended purpose. content scripts run under page-mod run in context of web page, rather typical sandboxed context.

from page's documentation:

you can modify document in script:

var pagemod = require("sdk/page-mod");  pagemod.pagemod({ include: "*.mozilla.org",                   contentscript: 'document.body.innerhtml =' +                                  '"<h1>page matches ruleset</h1>";'  }); 

Comments

Popular posts from this blog

ruby on rails - RuntimeError: Circular dependency detected while autoloading constant - ActiveAdmin.register Role -

c++ - OpenMP unpredictable overhead -

javascript - Wordpress slider, not displayed 100% width -