-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathoverwrite.js
More file actions
33 lines (33 loc) · 1.04 KB
/
Copy pathoverwrite.js
File metadata and controls
33 lines (33 loc) · 1.04 KB
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
self.addEventListener('fetch', e => {
if (e.request.url.endsWith('/data/pdf.js/web/viewer.css')) {
const p = Promise.all([
fetch(e.request).then(r => r.text()),
fetch('/data/viewer/buttons.css').then(r => r.text()),
fetch('/data/viewer/theme.css').then(r => r.text())
]).then(a => new Response(a.join('\n'), {
'status': 200,
'headers': {
'content-type': 'text/css; charset=UTF-8'
}
}));
e.respondWith(p);
}
else if (e.request.url.endsWith('/data/pdf.js/web/viewer.mjs')) {
const p = Promise.all([
fetch(e.request).then(r => r.text()),
fetch('/data/viewer/overwrite.js').then(r => r.text())
]).then(a => new Response(a.join('\n'), {
'status': 200,
'headers': {
'content-type': 'text/javascript; charset=UTF-8'
}
}));
e.respondWith(p);
}
else {
// console.log(e.request.url);
e.respondWith(fetch(e.request));
}
});
self.addEventListener('activate', () => self.clients.claim());
self.addEventListener('install', () => self.skipWaiting());