plasmo
plasmo copied to clipboard
[RFC] Content Script UI on click with activeTab permission only
How do you envision this feature/change to look/work like?
Instead of providing match URLs in PlasmoCSConfig, allow a UI (ex. react component) to be mounted when the extension icon is clicked, on thus activeTab permission is acquired; https://developer.chrome.com/docs/extensions/get-started/tutorial/scripts-activetab#active-tab
What is the purpose of this change/feature? Why?
By using the URL match approach, a warning is triggered when installing the extension (see example). It is encouraged to use activeTab permissions. The content script will always be injected on the matching URLs, some extensions might only need to inject scripts on (extension icon) click action.
(OPTIONAL) Example implementations
Option to leave matches key empty in CS(UI) (or not use PlasmoCSConfig at all)
export const config: PlasmoCSConfig = {
matches: []
};
Trigger the UI injection from background service worker
chrome.action.onClicked.addListener(async (tab) => {
// Any code before injection (check URL, ...)
// Invoke UI injection of some Plasmo CSUI
}
(OPTIONAL) Contribution
- [ ] I would like to contribute to this RFC via a PR
Verify canary release
- [X] I verified that the issue exists in
plasmo
canary release
Code of Conduct
- [X] I agree to follow this project's Code of Conduct
- [X] I checked the current issues for duplicate problems.