From ba55495f75e1371e25973e1338e85ba7265e28fa Mon Sep 17 00:00:00 2001 From: Andrew Fitch <7fe82a138a5365a1fb70f0b3ae2afd10d13c5cc4@cloudflare.com> Date: Thu, 20 Aug 2020 09:57:40 +0200 Subject: [PATCH] bg.js --- addons/urejectCR/bg.js | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/addons/urejectCR/bg.js b/addons/urejectCR/bg.js index 945c9b46d..3e2cde70c 100644 --- a/addons/urejectCR/bg.js +++ b/addons/urejectCR/bg.js @@ -1 +1,34 @@ -. \ No newline at end of file +let history = {}; +chrome.webRequest.onResponseStarted.addListener(i => { + if ([403, 406, 410, 429, 451, 462].includes(i.statusCode)) { + let iFQDN = (new URL(i.url)).hostname; + if (['crimeflare.eu.org', 'ansero.eu.org', 'crimeflare.wodferndripvpe6ib4uz4rtngrnzichnirgn7t5x64gxcyroopbhsuqd.onion', 'ansero.wodferndripvpe6ib4uz4rtngrnzichnirgn7t5x64gxcyroopbhsuqd.onion'].includes(iFQDN)) { + return; + } + let iServer = '?'; + i.responseHeaders.forEach(x => { + if (x.name == 'Server' || x.name == 'server') { + iServer = x.value; + } + }); + history[iFQDN] = [i.url, iServer, i.statusCode, (new Date()).toUTCString()]; + } + return; +}, { + urls: ['http://*/*', 'https://*/*'], + types: ['main_frame'] +}, ['responseHeaders']); +chrome.runtime.onMessage.addListener((request, sender, sendResponse) => { + if (request && sender) { + if (request == 'get') { + sendResponse(history); + } + if (request == 'clear') { + history = {}; + sendResponse(true); + } + } +}); +chrome.browserAction.onClicked.addListener(() => { + chrome.runtime.openOptionsPage(); +}); \ No newline at end of file