Chrome扩展V2到V3的变化

Chrome扩展manifest V3变化、升级迁移指南_chrome_ZK645945-华为云开发者联盟 (csdn.net)

1.background

//V2
"background": "background.js"

//V3
"background": {
    "service_worker": "background.js"
 }

2.executeScript

//V2
chrome.tabs.executeScript({
    file: 'script.js'
});


//V3
"permissions": ["scripting"]

async function getCurrentTab() {/* ... */}
let tab = await getCurrentTab();

chrome.scripting.executeScript({
    target: { tabId: tab.id },
    files: [ 'script.js' ]
});

3.action

browser_action 改为 action。

你可能感兴趣的:(Chrome,Extension,chrome)