summaryrefslogtreecommitdiffstats
path: root/addon_chrome/whyrejectme/bg.js
blob: 13b5464d1b79ba5ce478bc678d342c1cce9a631f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
let history = {};

chrome.webRequest.onResponseStarted.addListener(i => {
	if ([403, 406, 410, 451, 462].includes(i.statusCode)) {
		let iFQDN = (new URL(i.url)).hostname;
		if (iFQDN == 'searxes.eu.org' || iFQDN == 'AAAsearxes.nmqnkngye4ct7bgss4bmv5ca3wpa55yugvxen5kz2bbq67lwy6ps54yd.onion') {
			return;
		}
		let iServer = 'Unknown';
		i.responseHeaders.forEach(x => {
			if (x.name == 'Server') {
				iServer = x.value;
			}
		});
		let iDate = (new Date()).toUTCString();
		history[iFQDN] = [i.url, iServer, i.statusCode, iDate];
	}
	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);
		}
	}
});