[英]Autofill script doesn't work
Previously, user Robin (thank you) helped me to solve some typing mistakes on my code. 以前,用户Robin(感谢您)帮助我解决了我的代码中的一些输入错误。 Anyway, when I click on the button to make the code working, it doesn't do anything.
无论如何,当我单击按钮使代码正常工作时,它什么也没做。
Where are my mistakes? 我的错误在哪里? Thank you very much.
非常感谢你。
Here are the codes: 以下是代码:
Manifest.json Manifest.json
{
"name": "Bwin pages",
"version": "1.0",
"manifest_version": 2,
"description": "Open Bwin pages",
"background": {"scripts": ["background.js"]},
"browser_action": {"default_icon": "icon.gif"},
"permissions": ["tabs","activeTab","https://www.bwin.com"],
"content_scripts": [{
"matches": ["https://www.bwin.com/"],
"js": ["autofill.js"]
}],
"run_at": "document_end",
"all_frames": true
}
Background.js Background.js
console.log("Background.js Started .. ");
chrome.browserAction.onClicked.addListener(function (tab) {chrome.tabs.executeScript(tab.id, {file: 'autofill.js'});
console.log("Script Executed .. ");
});
Autofill.js Autofill.js
console.log("Autofill.js Started .. ");
var myUsername = "aaa";
var myPassword = "bbb";
var loginField = document.getElementById("ct106_ct107_loginview_baw_template_logincontrol_edtUsername");
var passwordField = document.getElementById("ct106_ct107_loginview_baw_template_logincontrol_edtPassword");
loginField.value = myUsername;
passwordField.value = myPassword;
var loginForm = document.getElementById ("ct106_ct107_loginview_baw_template_logincontrol_btnLogin");
loginForm.submit();
checkCookie();
The "content_script" section needs to be an array of objects, because an extension can contain multiple content scripts, matching different patterns. “ content_script”部分需要是一个对象数组,因为扩展可以包含多个内容脚本,它们匹配不同的模式。
Eg 例如
"content_scripts": [{
"matches": ["https://www.bwin.com/"],
"js": ["autofill.js"]
}],
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.