【发布时间】:2016-04-28 15:04:09
【问题描述】:
我正在开发一个谷歌扩展程序,我想通过按popup.html 中的按钮然后运行我的函数来更改 youtube.com 的背景颜色。
这是我的代码:
JavaScript 文件ms.js:
function color1(){
document.getElementById("body-container").style.backgroundColor="blue";}
HTML popup.html 文件:
<!DOCTYPE html>
<html>
<head>
<script src="ms.js">
</script>
</head>
<body>
<p> TEST </p>
<input type="button" value="blue" id="btn1" onclick="color1"/>
</body>
</html>
这是我的manifest.json 文件:
{
"name": "my extension test",
"version": "1.0",
"permissions": [
"activeTab",
"pageCapture"
],
"manifest_version": 2,
"description": "Test extension :D",
"browser_action": {
"default_icon": "ikon.png",
"default_popup": "popup.html"
},
"web_accessible_resources": [
"script/ms.js"
],
"content_scripts": [
{
"matches": ["https://www.youtube.com/*"],
"js": ["ms.js"]
}
]
}
【问题讨论】:
-
如果对您有帮助,请查看SO question :)
标签: javascript html google-chrome-extension