0

我成功地将我的greasemonkey 用户脚本转换为chrome 扩展,没有任何问题。但是最近两天我在尝试将其转换为 Firefox 扩展时也遇到了问题!我从这里尝试了几个示例,并使用 Request/page-mod/ajax 尝试了 firefox builder 网站,但没有任何效果。我现在正在尝试这个:

主.js:

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();
    }
});

播放器.js:

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
});

有什么误解请见谅!我是所有这些 jquery/javascript/firefox-addon 的新手:P 有人可以帮助我或指出正确的方向吗?对不起我的英语不好,提前非常感谢!

4

1 回答 1

2

以下行不属于main.js

var replacediv = jQuery("div#box").eq(0).find('td').eq(3);

这应该会导致语法错误,因为您已将其放在对象文字的中间 - 如果您打开错误控制台 (Ctrl-Shift-J),您应该会看到该语法错误。如果您删除该行(或将其移至内容脚本的开头?)您的代码应该可以正常工作。

于 2012-10-10T10:59:14.830 回答