我想打开网页自动填写登录信息。下面给出了我的 main.js 插件代码。我有 uname 和 upass 变量。我想在插件打开选项卡时使用这些填写登录表单。
var uname="username";
var upass="password";
tabs.open({
url: "https://www.facebook.com",
onReady:runScript
});
function runScript(tab) {
tab.attach({
contentScriptFile: data.url("mody.js")
});
我将此代码放入我的 mody.js 文件中:
document.getElementById("email").value=uname; // uname undefined
document.getElementById("pass").value=upass; // upass undefined
但我无法从 mody.js 访问这些变量。有没有办法将这个变量传递给登录页面?
最佳答案
使用 contentScriptOptions为此。
The contentScriptOptions is a JSON object that is exposed to content scripts as a read-only value under the self.options property:
关于javascript - Firefox 插件打开选项卡并在 onready 事件中修改,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24613261/