0

I'm currently developing an Firefox addon with Mozilla's Firefox SDK. The basic idea is to modify the DOM and just leave some stuff there for later.

So here's what works so far:

var issues = require("page-mod");
var self = require("self");

issues.PageMod({
    include: '*',
    contentScriptFile: [self.data.url("jquery-1.8.2.min.js"), self.data.url("script.js")]
});

No big deal, jQuery works find and my custom script.js gets loaded.Now just for testing purposes I empty the pages body and try to append something, but it won't work and the script just stops. Things's i've tried so far are:

jQuery('body').empty();
$('body').append('<h1>TEST</h1>');
$('body').after('<h1>TEST</h1>');
$('body').html('<h1>TEST</h1>');

I guess it will be a real simple thing but I can't figure it out right now. Any help is greatly appreciated!

1 Answer 1

0

Do you get any errors? This works for me:

Main.js:

var issues = require("page-mod");
var data = require("self").data;

issues.PageMod({
    include: 'http://canuckistani.ca*',
    contentScriptFile: [data.url("jquery.min.js"), data.url("script.js")]
});

Script.js:

$('body').empty()
    .append('<h1>TEST</h1>')
    .after('<h1>TEST</h1>')
    .html('<h1>TEST</h1>');

https://builder.addons.mozilla.org/package/161694/latest/

1
  • Hi,thank you for your response. Your code actually works fine here too, it must be something different then. I hope to find the solution soon and will post the answer here.
    – zitscher
    Nov 19, 2012 at 11:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.