google-chrome-extension - Chrome 扩展显示页面操作示例清单 v3
问题描述
我正在尝试使用清单 v3重现此示例。但我的操作始终处于活动状态 - 我将其在所有页面上禁用,而 URL 中没有“g”。
提前致谢!
清单.json
{
"name":"Example",
"description":"description",
"version":"0.1",
"manifest_version":3,
"background":{
"service_worker":"background.js"
},
"permissions":[
"declarativeContent"
],
"action":{
"default_icon":{
"16":"/images/get_started16.png",
"32":"/images/get_started32.png",
"48":"/images/get_started48.png",
"128":"/images/get_started128.png"
},
"default_title":"press here to open"
},
"icons":{
"16":"/images/get_started16.png",
"32":"/images/get_started32.png",
"48":"/images/get_started48.png",
"128":"/images/get_started128.png"
}
}
背景.js
chrome.runtime.onInstalled.addListener(() => {
// Replace all rules ...
chrome.declarativeContent.onPageChanged.removeRules(undefined, function() {
// With a new rule ...
chrome.declarativeContent.onPageChanged.addRules([
{
// That fires when a page's URL contains a 'g' ...
conditions: [
new chrome.declarativeContent.PageStateMatcher({
pageUrl: { urlContains: 'g' },
})
],
// And shows the extension's page action.
actions: [ new chrome.declarativeContent.ShowPageAction() ]
}
], function callback(details) {
console.log("chrome.declarativeContent.onPageChanged.addRules callback");
console.log(details);
});
});
});
解决方案
推荐阅读
- reactjs - React-Intl 同时使用多个语言环境
- flutter - StreamBuilder 快照 ConnectionState.done 不起作用
- python - 导航栏中的 Django 动态菜单
- javascript - PayPal 智能按钮交易显示错误
- javascript - 创建一个导入和修补另一个的 javascript 模块
- go - 如何使用光纤将密码解析为字节数组
- ruby-on-rails - html_safe 和非 html_safe 连接
- php - 让 Expression Engine v 2.5.5 与 PHP7 一起使用的最快方法
- docker - 在 github 操作中使用 docker 进行纱线测试永远不会完成
- python - 如何在python中保存和重用处理null的函数