所以我创建了一个附加组件,可以在打开的每个页面上找到某些字符串,它可以正常工作。我遇到的唯一问题是:当页面使用 AJAX 更新其内容时,我不知道如何检测它并重新运行我的 contentScriptFile。
我的内容脚本文件中是否有我应该使用的模块或某种类型的 JS 监听器?
这是页面模式:
pageMod.PageMod({
include: "*",
contentScriptFile: [self.data.url("jquery-1.9.1.min.js"), self.data.url("script.js")],
onAttach: function(worker){
var apiKey = require("sdk/simple-prefs").prefs.apiKey;
var ignoreList = require("sdk/simple-prefs").prefs.ignoreList;
worker.port.emit("prefSet", [ignoreList, apiKey]);
});
最佳答案
无论 Ajax 事件成功完成还是失败,以下 jQuery 代码都会检测到任何 Ajax 事件完成:
$(document).ready(function () {
$(document).ajaxComplete(function() {
alert("AJAX call completed");
});
});
要使 JQuery 可用于 FireFox 附加组件,请安装 this Firefox 附加组件/扩展
关于javascript - 火狐插件 : pageMod how to run contentScript everytime AJAX is Done,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25189789/