I successfully converted my greasemonkey userscript to a chrome extension without any problem. But the last 2 days i am having issues while trying to convert it to a firefox extension also! I tried several examples from here and firefox builder website with Request/page-mod/ajax but nothing worked. I am now trying this:
var data = require("self").data;
var tabs = require("tabs");
var Request = require("request").Request;
var pm = require("page-mod").PageMod({
include: "http://www.example.com/player/*",
contentScriptFile: [data.url("jquery.js"), data.url("player.js")],
var replacediv = jQuery("div#box").eq(0).find('td').eq(3); // this is the div where i need to place the info from the "fetchedwebsite.com"
onAttach: function(worker) {
Request({
url: "http://www.fetchedwebsite.com/players/item/4556834",
onComplete: function (response) {
worker.port.emit('got-request', response.text);
}
}).get();
}
});
self.port.on('got-request', function(data) {
var columns = $('div.columns',data); // Here i want to keep only the div i want from the "fetchedwebsite.com"
columns.appendTo(replacediv); // And afaik this is to replace the divs
});
Please excuse me about any misunderstandings! I am new in all these jquery/javascript/firefox-addon things :P Can someone help me or point me in the correct direction, please? Sorry for my bad English and thanks a lot in advance!
The following line doesn't belong in main.js
:
var replacediv = jQuery("div#box").eq(0).find('td').eq(3);
This should cause a syntax error because you've put it in the middle of an object literal - if you open Error Console (Ctrl-Shift-J) you should see that syntax error. If you remove that line (or move it to the beginning of the content script?) your code should work fine from the look of it.