我正在撰写Chrome扩展程序,在点击浏览器操作图标时会将我重定向到网址.
我正在尝试使用:
chrome.browserAction.onClicked.addListener
Run Code Online (Sandbox Code Playgroud)
但我明白了
未捕获的TypeError:无法读取未定义的属性'onClicked'
这是我的清单文件:
{
"name": "first extension",
"version": "2.2.12",
"description": "redirct to a link icon",
"browser_action": {
"default_icon": "icontest.png",
"default_title": "Do action"
},
"permissions": ["tabs", "http://*/*"],
"content_scripts": [{
"matches": ["http://*.twitter.com/*", "https://*.twitter.com/*"],
"js": ["twterland.js"]
}],
"icons": {
"16": "icontest.png",
"48": "icontest.png",
"128": "icontest.png"
}
}
Run Code Online (Sandbox Code Playgroud)
这是我的js文件:
chrome.browserAction.onClicked.addListener(function(tab) { alert("hi"); });
Run Code Online (Sandbox Code Playgroud) 我无法理解如何将我的 chrome 扩展清单 v2 升级到 v3
我检查了https://developer.chrome.com/extensions/migrating_to_manifest_v3但它没有谈论 manifest.json
知道在我的清单中需要更改什么:-
"name": "My Extension",
"version": "1.0.0",
"short_name": "Ex",
"author": "User",
"description": "cool chrome ex",
"browser_action": {
"default_title": "ex",
"default_icon": "img/logo.png"
},
"options_page": "options.html",
"options_ui": {
"page": "options.html",
"open_in_tab": true
},
"background": {
"scripts": [
"js/background.js"
]
},
"permissions": [
"tabs",
"background",
"storage"
],
"icons": {
"128": "img/logo128.png"
},
"content_scripts": [
{
"run_at": "document_end",
"matches": [
"https://conferfly.com/*",
"https://meet.google.com/*",
"https://teams.microsoft.com/*",
"https://*.zoom.us/*"
],
"js": [
"js/main.js",
"js/injected.js"
],
"css": [
"css/main.css"
]
} …Run Code Online (Sandbox Code Playgroud) 我正在尝试将函数和原语(使用模块)从我的index.js文件导入到我正在制作的Google扩展的background.js上,但随后它给我带来了“服务工作人员注册失败。状态代码:15”作为一旦我这样做了。删除该部分 'import { searchTransform, inputLang} from "./index.js";' 立即让我“工人服务活跃”。我尝试过更改标签属性;我将“模块”添加到我的清单和 html 文件中。我将 chrome 更新到最新版本。