Created
March 10, 2026 19:18
-
-
Save marcinantkiewicz/44134741dab7d0286b3d6d0fab94729e to your computer and use it in GitHub Desktop.
extension to log headers, this extension will probably burn your computer down
This file contains hidden or 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
| const clacksCache = {}; | |
| const loggerURL = "https://localhost/crx_header_logger" | |
| chrome.webRequest.onHeadersReceived.addListener( | |
| (details) => { | |
| const clacks = details.responseHeaders.find( | |
| (h) => h.name.toLowerCase() === 'x-clacks-overhead' | |
| ); | |
| if (clacks && details.tabId > 0) { | |
| clacksCache[details.tabId] = clacks.value; | |
| const data = { msg: clacks.value, url: details.url, time: Date.now() }; | |
| chrome.storage.local.get({logs: []}, (result) => { | |
| const newLogs = [...result.logs, data]; | |
| chrome.storage.local.set({logs: newLogs}); | |
| }); | |
| fetch('logerUrl', { | |
| method: 'POST', | |
| body: JSON.stringify(data), | |
| headers: { 'Content-Type': 'application/json' } | |
| }).catch(err => console.error("Post failed:", err)); | |
| } | |
| }, | |
| { urls: ["<all_urls>"], types: ["main_frame"] }, | |
| ["responseHeaders"] | |
| ); | |
| // Listen for the Content Script asking for the match | |
| chrome.runtime.onMessage.addListener((request, sender, sendResponse) => { | |
| if (request.type === 'GET_CLACKS_HEADER') { | |
| const value = clacksCache[sender.tab.id]; | |
| sendResponse({ value: value }); | |
| // cleanup | |
| delete clacksCache[sender.tab.id]; | |
| } | |
| });back |
This file contains hidden or 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
| (function() { | |
| const UI_ID = 'clacks-universal-overlay'; | |
| function display(msg) { | |
| if (!msg || document.getElementById(UI_ID)) return; | |
| const div = document.createElement('div'); | |
| div.id = UI_ID; | |
| div.textContent = msg.startsWith("GNU") ? msg : `GNU ${msg}`; | |
| Object.assign(div.style, { | |
| position: 'fixed', bottom: '20px', right: '20px', | |
| backgroundColor: '#111', color: '#0f0', padding: '12px', | |
| border: '2px solid #0f0', zIndex: '2147483647', | |
| fontFamily: 'monospace', borderRadius: '4px' | |
| }); | |
| document.body.appendChild(div); | |
| setTimeout(() => div.remove(), 5000); | |
| } | |
| // first Check Meta Tag | |
| const meta = document.querySelector('meta[http-equiv="X-Clacks-Overhead"]'); | |
| if (meta && meta.content) { | |
| display(meta.content); | |
| } | |
| // ask the worker if it came in headers | |
| chrome.runtime.sendMessage({ type: 'GET_CLACKS_HEADER' }, (response) => { | |
| if (response && response.value) { | |
| display(response.value); | |
| } | |
| }); | |
| })(); |
This file contains hidden or 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": "Clacks Universal Tracker", | |
| "version": "2.2", | |
| "permissions": ["webRequest", "scripting", "storage"], | |
| "host_permissions": ["*://*/*"], | |
| "background": { | |
| "service_worker": "background.js" | |
| }, | |
| "content_scripts": [ | |
| { | |
| "matches": ["<all_urls>"], | |
| "js": ["content.js"], | |
| "run_at": "document_end" | |
| } | |
| ] | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment