summaryrefslogtreecommitdiffstats
path: root/not_cloudflare/whyrejectme/bg.js
blob: a60583fa1d0b6bf80c5db6b54f583c0e05569de2 (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
let history = {};

browser.webRequest.onResponseStarted.addListener(i => {
	if (i.statusCode == 403) {
		let iFQDN = (new URL(i.url)).hostname;
		let iServer = 'Unknown';
		i.responseHeaders.forEach(x => {
			if (x.name == 'Server') {
				iServer = x.value;
			}
		});
		let iDate = (new Date()).toUTCString();
		history[iFQDN] = [i.url, iServer, iDate];
	}
	return;
}, {
	urls: ['http://*/*', 'https://*/*'],
	types: ['main_frame']
}, ['responseHeaders']);

browser.runtime.onMessage.addListener((request, sender, sendResponse) => {
	if (request && sender) {
		if (request == 'get') {
			sendResponse(history);
		}
		if (request == 'clear') {
			history = {};
			sendResponse(true);
		}
	}
});