Writing extension in ts and i’m trying to execute some code in tab, but it makes an error.
Using webpack for compile. I have a code like this:
//background.ts
chrome.action.onClicked.addListener((tab) => {
if (tab.id) {
// Внедряем скрипт в активную вкладку
chrome.scripting.executeScript({
target: { tabId: tab.id },
files: ["dist/script.js"],
});
}
});
//script.ts
document.body.style.backgroundColor = "lightblue";
console.log("Injected script executed successfully!");
and error like these:
Uncaught (in promise) Error: Cannot access a chrome:// URL
Context: dist/background.js
Stack trace: dist/background.js:0 (anonymous functions)
1