-
Notifications
You must be signed in to change notification settings - Fork 0
/
worker.js
36 lines (31 loc) · 1.06 KB
/
worker.js
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
35
36
// THIS IS NECESSARY TO ENABLE CENSORSHIP.
self.addEventListener('install', function (event) {
console.log('Installing')
});
var censored = false;
self.addEventListener('message', e => {
censored = e.data;
});
self.addEventListener('fetch', function (event) {
var url = event.request.url.split('?')[0];
if (!!url.split('.')[1] && !!event.request.url.split('?')[1]) {
if (url.split('.')[url.split('.').length - 1] == 'ks') {
var file = url.split('/')[url.split('/').length - 1];
var updirectory = url.split('/')[url.split('/').length - 2];
var directory = (updirectory == "system" ? "system/" : "")
console.log(file, updirectory, directory)
if (censored) {
event.respondWith(fetch('censorship/'+directory+file));
} else {
return
}
} else {
return;
}
} else {
return
}
});
self.addEventListener('activate', function (event) {
console.log('Activated')
});