九月 14, 2024
本篇主要是开发的一些实践,可读性还比较粗糙,有待进一步施工
参考:
https://developer.chrome.com/docs/extensions/get-started (官方教程)
https://github.com/sxei/chrome-plugin-demo
https://www.pipipi.net/24804.html
方法调研:background模块(chrome extension模块),Message Passing API(chrome extension api),Broadcast Channel(发布-订阅模式),SharedWorker API(多TAB共享后台线程),localStorage/sessionStorage(本地浏览器存储)
HelloWorld manifest.json
{ "manifest_version": 3, "name": "Hello Extensions", "description": "Base Level Extension", "version": "1.0", "action": { "default_popup": "hello.html", "default_icon": "hello_extensions.png" } } hello.html
<html> <body> <h1>Hello Extensions</h1> </body> </html> chrome://extensions->Enable Developer Mode->Load unpacked button and select the extension directory
Reload
Extension component Requires extension reload The manifest Yes Service worker Yes Content scripts Yes (plus the host page) The popup No Options page No Other extension HTML pages No ReadTime manifest.
继续阅读