Javascript 更改Chrome扩展中的选项卡位置
我希望能够单击HTMLdiv按钮并重新定位当前选项卡 redirect.js popup.htmlJavascript 更改Chrome扩展中的选项卡位置,javascript,jquery,html,google-chrome,Javascript,Jquery,Html,Google Chrome,我希望能够单击HTMLdiv按钮并重新定位当前选项卡 redirect.js popup.html manifest.json { “名称”:“z”, “版本”:“0.1”, “说明”:“z”, “背景”:{ “页面”:“popup.html” }, “清单版本”:2, “内容脚本”:[ { “匹配项”:[“http://*/*”,“https://*/*”], “js”:[“redirect.js”] } ], “权限”:[ “标签”, “书签”, "", “无限制存储” ] } 这些是
manifest.json
{
“名称”:“z”,
“版本”:“0.1”,
“说明”:“z”,
“背景”:{
“页面”:“popup.html”
},
“清单版本”:2,
“内容脚本”:[
{
“匹配项”:[“http://*/*”,“https://*/*”],
“js”:[“redirect.js”]
}
],
“权限”:[
“标签”,
“书签”,
"",
“无限制存储”
]
}
这些是我当前的脚本,当我添加div按钮时,它不允许我使用onclick,我主要需要帮助。1:您没有在manifest.json中指定browserAction。如果要使用chrome.browserAction.onClicked,必须指定浏览器操作。添加一个扩展图标 2:您不需要内容脚本 3:如果您只需要一个重定向功能,则不需要请求书签、所有URL和存储权限 这是您的manifest.json应该是:
{
"name": "z",
"version": "0.1",
"description": "z",
"background": {
"page":"popup.html"
},
"manifest_version": 2,
"permissions": [
"tabs"
],
"browser_action": {
"default_icon": {
"19": "icon.png" //you have to put an image icon.png in to the folder.
},
"default_title": "Redirect" //optional
}
}
那它就行了
另外,不要将背景文件命名为“popup.html”,popup通常用作弹出窗口
你也可以在这里下载扩展,只有这个脚本会在点击后重定向到谷歌。您可以自己修改它
已修改,还添加了可下载链接。
<html>
<script src="redirect.js"></script>
</html>
{
"name": "z",
"version": "0.1",
"description": "z",
"background": {
"page":"popup.html"
},
"manifest_version": 2,
"content_scripts": [
{
"matches": ["http://*/*", "https://*/*"],
"js": ["redirect.js"]
}
],
"permissions": [
"tabs",
"bookmarks",
"<all_urls>",
"unlimitedStorage"
]
}
{
"name": "z",
"version": "0.1",
"description": "z",
"background": {
"page":"popup.html"
},
"manifest_version": 2,
"permissions": [
"tabs"
],
"browser_action": {
"default_icon": {
"19": "icon.png" //you have to put an image icon.png in to the folder.
},
"default_title": "Redirect" //optional
}
}