【发布时间】:2022-08-02 18:02:59
【问题描述】:
在 Manifest 3 到 Manifest 3 的迁移过程中,我遇到了一些困难:没有任何效果。 我开发了一个简单的Chrome 扩展程序在上下文菜单中添加一个新项目,因此您可以在某些网站中搜索插入的文本。它在清单 2 中正常工作,但在清单 3 中不能正常工作。 所以有清单代码(3)
{
\"manifest_version\": 3,
\"name\": \"name\",
\"short_name\": \"shortN\",
\"description\": \"This extension will work someday I hope so\",
\"background\": [{
\"service_worker\": [ \"background.js\" ]
}],
\"icons\": {
\"128\": \"icons/128.png\",
\"48\": \"icons/48.png\",
\"32\": \"icons/32.png\",
\"16\": \"icons/16.png\"
},
\"permissions\": [ \"contextMenus\", \"tabs\", \"activeTab\" ],
\"version\": \"1.3\"
}
以及背景代码示例
chrome.runtime.onInstalled.addListener(function() {
chrome.contextMenus.create({
title: \"title\",
contexts: [\"selection\"],
id: \"title1\"
});
});
chrome.contextMenus.onClicked.addListener(function (info, tab) {
if (info.menuItemId === \"title1\") {
let getToSite = \"https://*\" + info.selectionText
chrome.tabs.create({index: tab.index + 1, url: getQ, selected: true});
}
})
有人可以看看并说什么s wrong with it? Im 也是 JS 的新手(比如,三天新),所以我很欣赏简单的解释
谢谢!
-
删除
background部分中的所有四个[和]。
标签: javascript google-chrome-extension manifest.json chrome-extension-manifest-v3