asmboy.
asmboy.
PD🧩 Plasmo Developers
Created by asmboy. on 11/10/2023 in #👟framework
Injecting Content Script UI on Extension Click (and disabling popup)
I've got the popup disabled already by renaming the file. However, I'm still trying to figure out how to dynamically inject a content script UI on to the page when the extension is clicked. The end functionality of the extension should be a UI that appears on screen instead of a popup. So far my background/index.ts file looks something roughly like this:
import menuUrl from './injected_helper'

chrome.action.onClicked.addListener((tab) => {
console.log('action click', tab.id)

chrome.scripting.executeScript({
target: { tabId: tab.id },
world: "MAIN",
func: menuUrl
})
});
import menuUrl from './injected_helper'

chrome.action.onClicked.addListener((tab) => {
console.log('action click', tab.id)

chrome.scripting.executeScript({
target: { tabId: tab.id },
world: "MAIN",
func: menuUrl
})
});
It works for importing in a regular .ts file (./injected_helper), but I can't seem to get it to work with a content script UI file.
5 replies