SuriJ
SuriJ
PD🧩 Plasmo Developers
Created by SuriJ on 4/25/2024 in #🔰newbie
Help: chrome.scripting.executeScript executes only once
Hey guys, I need help with the below code. I have created a popup with a button that calls the below mentioned handleClick function which executes the function foo from foo.ts The code works but it is executed only for the first button click. I see "bar" logged in the console window but nothing happens on further clicks. popup.tsx: import foo from "url:~scripts/foo.ts" const handleClick = async () => { const [tab] = await chrome.tabs.query({ active: true, currentWindow: true }) await chrome.scripting.executeScript({ target: { tabId: tab.id }, world: "MAIN", files: [foo.split("/").pop().split("?")[0]] }) } src/scripts/foo.ts: function foo() { console.log("bar") } foo()
2 replies