diff options
author | sameerasw <[email protected]> | 2025-04-25 18:11:44 +0530 |
---|---|---|
committer | sameerasw <[email protected]> | 2025-04-25 18:11:44 +0530 |
commit | 3321f7444165e703447f1f7761e358d69a6d4436 (patch) | |
tree | 35400557fe11eb8b281b32f803fd1f762791fd59 | |
parent | 9a5e14f6e66b6a0beb4a7c20c5512b873684b04a (diff) |
Version update
-rw-r--r-- | content-script.js | 42 | ||||
-rw-r--r-- | manifest.json | 2 |
2 files changed, 43 insertions, 1 deletions
diff --git a/content-script.js b/content-script.js new file mode 100644 index 0000000..4f02174 --- /dev/null +++ b/content-script.js @@ -0,0 +1,42 @@ +(function() { + const stylesheetId = 'zeninternet-custom-styles'; + + // Create or get our stylesheet element + function getStylesheet() { + let stylesheet = document.getElementById(stylesheetId); + if (!stylesheet) { + stylesheet = document.createElement('style'); + stylesheet.id = stylesheetId; + stylesheet.type = 'text/css'; + document.head.appendChild(stylesheet); + } + return stylesheet; + } + + // Update our stylesheet content + function updateStyles(css) { + const stylesheet = getStylesheet(); + stylesheet.textContent = css || ''; + console.log('ZenInternet: Styles were ' + (css ? 'updated' : 'removed')); + } + + // Announce content script is ready and provide current hostname + function announceReady() { + browser.runtime.sendMessage({ + action: 'contentScriptReady', + hostname: window.location.hostname, + }); + } + + // Listen for messages from background script + browser.runtime.onMessage.addListener((message) => { + if (message.action === 'applyStyles') { + updateStyles(message.css); + return Promise.resolve({ success: true }); + } + return false; + }); + + // Announce content script is ready on load + announceReady(); +})(); diff --git a/manifest.json b/manifest.json index 802bbb6..beae3aa 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "manifest_version": 2, "name": "Zen Internet", - "version": "1.8.0", + "version": "1.9.0", "description": "Inject custom css from my repository in real time", "browser_specific_settings": { "gecko": { |