我正在尝试通过Chrome扩展程序向活动文档(活动标签)添加一些内容。这就是我所拥有的:
popup.html
<button class="btn btn-default" id="clear" type="submit"></button>
popup.js
$('#clear').on('click', function () {
$('tr').eq(0).append("Some Test");
});
和manifest.json
{
"manifest_version": 2,
"name": "Adder",
"description": "Adding Content",
"version": "1.0",
"background" : {
"scripts" : ["jquery.min.js","popup.js"],
"persistent": false
},
"content_scripts": [ {
"js": [ "jquery.min.js", "popup.js"],
"matches": [ "http://*/*", "https://*/*"]
}],
"browser_action": {
"default_icon": "icon.png"
},
"permissions": [
"activeTab"
]
}
更新
$('#clear').on('click', function () {
chrome.tabs.executeScript({ code:
'document.body.style.backgroundColor="red"' });
alert("test");
});