There is a need to access to DOM functions from Firefox extension.
I have code that works perfectly from Firefox console:
var chk = document.querySelectorAll( 'input[type=checkbox]' );
for (var i=0; i < chk.length; i++)
{
if (!(chk[i].disabled))
{
chk[i].checked = true;
}
}
I want to make a simple extension for Firefox in order to don't copy-paste this code each time. But I've faced with issue that cannot access to DOM functions from main.js.
Could you please advise a way to solve this issue?
Note:
Found this solution but it didn't help:
var wuntils = require('sdk/window/utils');
var window = wuntils.getMostRecentBrowserWindow();
var document = window.document;
main.js
will be run only once, and not for each window or tab.
Either use a PageMod
content-script or attach a content script via tabs.attach
.
The content script would be your querySelectorAll
snippet, of course.