Injecting CSUI dynamically

Is it possible to inject CSUI into a website programmatically and not statically via PlasmoCSConfig API? PlasmoCSConfig requires one to declare the URL of the websites which will be targeted, but what can I do in situation in which I determine whether to inject the CSUI during the runtime? i.e. my goal is to inject the CSUI with simple text to any visited website if current time is later than 1pm.
1 Reply
alanek2009
alanek2009OP•13mo ago
Currently trying to use chrome.scripting.executeScript() from my background service worker, but not sure on how would a JSX even get injected? I'm thinking this only works with plain .ts/.js.
import codeUrl from "url:~/src/testts"; // nope... the file name is is testts.ts
chrome.scripting.executeScript(
{
target: {
tabId,
},
world: "MAIN", // MAIN to access the window object
// files: ["./splash-overlay.tsx"]
files: [codeUrl],
},
() => {
console.log("Background script got callback after injection");
},
);
import codeUrl from "url:~/src/testts"; // nope... the file name is is testts.ts
chrome.scripting.executeScript(
{
target: {
tabId,
},
world: "MAIN", // MAIN to access the window object
// files: ["./splash-overlay.tsx"]
files: [codeUrl],
},
() => {
console.log("Background script got callback after injection");
},
);
Want results from more Discord servers?
Add your server