【问题标题】:Migrating Extension to Manifest v3将扩展迁移到清单 v3
【发布时间】:2021-10-02 19:26:02
【问题描述】:

我想将我的 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"
}

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);
});

【问题讨论】:

    标签: google-chrome-extension manifest.json


    【解决方案1】:

    Chrome Manifest v2 扩展程序弃用时间表

    2022 年 1 月 17 日:Chrome 网上应用店不再接受新的 Manifest V2 扩展,但允许开发者向其推送更新。

    2023 年 1 月:Manifest V2 扩展程序将停止工作,并且无法在 Chrome 中运行,即使有企业政策,开发人员也可能无法向其推送更新。

    Offical Resource


    我建议你阅读Google Chrome Offical Migration Article

    如果你不想花时间在这上面,我建议Extension Manifest Converter,它是一个由谷歌开源和开发的工具。

    根据README文件,该工具有局限性:

    此工具旨在简化 MV3 转换;它并没有完全自动化这个过程。仅对 .js 文件应用搜索和替换更改。

    此工具没有:

    • 更新任何依赖 DOM 的 service worker 代码

    我尝试了这个工具,它给了我以下输出:

    {
      "description": "description here",
      "icons": {
        "128": "img/icon_128.png",
        "16": "img/icon_16.png"
      },
      "manifest_version": 3,
      "name": "Title here",
      "version": "1.0.1",
      "action": {
        "default_icon": "img/icon_active.png",
        "default_popup": "html/popup.html",
        "default_title": "Title here"
      },
      "content_security_policy": {}
    }
    

    在您的情况下,manifest.json 发生了变化,但 popup.js 没有任何变化。

    【讨论】:

      猜你喜欢
      • 2021-03-26
      • 2020-11-28
      • 1970-01-01
      • 2021-09-16
      • 2022-08-04
      • 2021-09-30
      • 2022-01-09
      • 2023-02-14
      • 2022-10-20
      相关资源
      最近更新 更多