Imr*_*aza 4 google-chrome-extension manifest.json
我想将我的 Chrome 扩展程序从清单版本 2 迁移到版本 3,因为在不久的将来 Google 将从其商店中删除 MV2 扩展程序。现在我的扩展清单代码是这样的。
{
"browser_action": {
"default_icon": "img/icon_active.png",
"default_popup": "html/popup.html",
"default_title": "Title here"
},
"description": "description here",
"icons": {
"128": "img/icon_128.png",
"16": "img/icon_16.png"
},
"manifest_version": 2,
"name": "Title here",
"version": "1.0.1"
}
Run Code Online (Sandbox Code Playgroud)
popup.js 文件看起来像这样
$(document).on("click", ".copy-me", function(ev) {
var $body = document.getElementsByTagName('body')[0];
var rel = $(this).attr("rel");
var text = $("#"+rel).text();
var $tempInput = document.createElement("INPUT");
$body.appendChild($tempInput);
$tempInput.setAttribute("value", text)
$tempInput.select();
document.execCommand("copy");
$body.removeChild($tempInput);
});
Run Code Online (Sandbox Code Playgroud)
Chrome Manifest v2 扩展弃用时间表
\n2022 年1月 17 日:Chrome Web Store 不再接受新的 Manifest V2 扩展,但是,开发人员将被允许向其推送更新。
\n2023 年 1 月:Manifest V2 扩展将停止工作,并且无法在 Chrome 中运行,即使有企业策略,开发人员也可能无法向其推送更新。
\n\n我建议您阅读Google Chrome 官方迁移文章。
\n如果你不想花时间在这上面,我建议你使用Extension Manifest Converter,这是一个由 Google 开发的开源工具。
\n根据 README 文件,该工具有局限性:
\n\n\n该工具旨在简化MV3转换;它并没有完全自动化该过程。仅搜索和替换更改会应用于 .js 文件。
\n该工具不会:
\n\n
\n- 更新任何依赖 DOM 的 Service Worker 代码
\n
我尝试了该工具,它给出了以下输出:
\n{\n "description": "description here",\n "icons": {\n "128": "img/icon_128.png",\n "16": "img/icon_16.png"\n },\n "manifest_version": 3,\n "name": "Title here",\n "version": "1.0.1",\n "action": {\n "default_icon": "img/icon_active.png",\n "default_popup": "html/popup.html",\n "default_title": "Title here"\n },\n "content_security_policy": {}\n}\nRun Code Online (Sandbox Code Playgroud)\n在你的情况下manifest.json发生了变化,但没有任何变化popup.js。
| 归档时间: |
|
| 查看次数: |
14363 次 |
| 最近记录: |