Skip to content

Instantly share code, notes, and snippets.

@timheuer
Created April 23, 2023 00:18
Show Gist options
  • Save timheuer/2b830e7ce12208fd8f71ff847a1eff6c to your computer and use it in GitHub Desktop.
Save timheuer/2b830e7ce12208fd8f71ff847a1eff6c to your computer and use it in GitHub Desktop.
Simple Chrome extension
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']
}
);
}
});
document.addEventListener('DOMContentLoaded', function() {
console.log("content.js loaded");
});
// have also tried window.load, window.addEventListener(load), etc.
{
"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