Created
April 23, 2023 00:18
-
-
Save timheuer/2b830e7ce12208fd8f71ff847a1eff6c to your computer and use it in GitHub Desktop.
Simple Chrome extension
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.tabs.onUpdated.addListener(function(tabId, changeInfo, tab) { | |
if (changeInfo.status == 'complete') { | |
console.log("Completed tab was loaded, injecting content.js"); | |
chrome.scripting.executeScript( | |
{ | |
target: {tabId: tabId}, | |
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
document.addEventListener('DOMContentLoaded', function() { | |
console.log("content.js loaded"); | |
}); | |
// have also tried window.load, window.addEventListener(load), etc. |
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
{ | |
"name": "Input Monitor", | |
"version": "0.9", | |
"manifest_version": 3, | |
"permissions": [ | |
"scripting", | |
"activeTab" | |
], | |
"host_permissions": [ | |
"http://*/", | |
"https://*/" | |
], | |
"background": { | |
"service_worker": "background.js" | |
}, | |
"description": "A Chrome extension that monitors input boxes for keywords." | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment