Last active
November 13, 2024 15:15
-
-
Save royling/eb5276577f53d1332e413311ca904df8 to your computer and use it in GitHub Desktop.
Click Chrome extension icon to execute scripts on active tab
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
chrome.action.onClicked.addListener((tab) => { | |
chrome.scripting.executeScript({ | |
target: { | |
tabId: tab.id, | |
}, | |
files: ["content.js"], | |
}); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// modify page content here... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"manifest_version": 3, | |
"name": "Foo", | |
"version": "0.1", | |
"description": "Blabla...", | |
"action": { | |
"default_icon": { | |
"16": "images/icon16.png", | |
"32": "images/icon32.png" | |
}, | |
"default_title": "Foo" | |
}, | |
"permissions": ["activeTab", "scripting", "tabs"], | |
"host_permissions": [ | |
"*://*/*" | |
], | |
"background": { | |
"service_worker": "background.js" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Important note for anyone like me who tries this in the future: make sure that your background.js folder is in the same file as your manifest, otherwise the manifest is unable to access it. In general have all files in the same file as the manifest. Thanks for the code though, saved our lives at this hackathon