androabhay
androabhay

Reputation: 655

Firefox extension DOM manipulation using content script

I want to make changes on the current web page's dom

tabs.activeTab.attach({  
                contentScript:
window.content.document.body.length); // is showing undefined 

so I am not able to iterate over all the dom elements and make changes to them. And when I directly tried to write the tag I got a security exception

Please suggest me a way to access window object.

Upvotes: 1

Views: 647

Answers (1)

Bryan Clark
Bryan Clark

Reputation: 2602

Your example isn't working for me either, but the contentScript property only takes a String or Array so you'll need to do something like this:

var tabs = require('tabs');
tabs.activeTab.attach({
  contentScript: 'console.log(window.content.document.body.toString());'
});

You should be able to modify the DOM from there but unless you include jQuery it'll be a bit harder using document.querySelectorAll and then working with raw DOM Element nodes.

Upvotes: 1

Related Questions