一次谷歌插件(chrome extension)开发的随手记

1,034 阅读1分钟

N年前的记录

指定网站点亮图标

image.png

注意:manifest.json中的permissions要填declarativeContent(扩展程序访问chrome.declarativeContent API的权限),不然会报错onPageChanged是undefined


image.png image.png image.png image.png

指定网站图标能点击,但所有网站的图标都高亮

manifest.json中的content_scripts的matches,如果填"<all_urls>",会匹配所有网站图标高亮,但是没有启用插件,最终还是在background.js中控制特定网站插件的启用。所以要注意matches的配置,与background.js中的网站匹配规则一致

image.png

chrome extension获取response body

参考:www.cnblogs.com/Higurashi-k… chrome.debugger:crxdoc-zh.appspot.com/extensions/…

开启监听response,再刷新浏览器,报错 Unchecked runtime.lastError: {"code":-32000,"message":"No data found for resource with given identifier"}

image.png

解决参考: stackoverflow.com/questions/4…

补充

相关文档

chrome.cenchy.com/getstarted.…

发现新大陆

为开发一个浏览器扩展提供的框架:Plasmo

mp.weixin.qq.com/s?__biz=Mzk…