-
Notifications
You must be signed in to change notification settings - Fork 5
/
background.js
537 lines (534 loc) · 8.24 KB
/
background.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
const WHITELISTS = `
.mil
.gov
2900larocca.dk
9apps.com
9game.cn
activpn.com
addepar.com
addeparvum.com
aetkasmart.de
affinity.co
agilebits.com
airbnb-aws.com
airbnbcitizen.com
airbnb.com
airtable.com
alditalk-kundenbetreuung.de
algolia.net
algolianet.com
alibaba.com
alibabagroup.com
alibaba-inc.com
alibabapictures.com
alibabaplanet.com
alicdn.com
aliexpress.com
aligame.com
alihealth.cn
alimama.com
alios.cn
alipay.com
aliqin.cn
alisports.com
alitrip.com
aliyun.com
allseason.net
amap.com
amazon.com
angha.me
anghami.com
apinetflix.com
arxius.io
ashleymadison.com
as.im
astaro.at
astaro.ch
astaro.com
astaro.de
astaroedu.com
astaro.info
astaro.net
astaro.org
astaro-security.com
astaro-tech.com
atairbnb.com
authy.com
autoconfig.de
autoconfig.email
autoconfig.nl
autoconfig.w
autodiscover.busines
autodiscover.cn
autodiscover.co
autodiscover.de
autodiscover.e
autodiscover.email
autodiscover.exchange
autodiscover.fr
autodiscover.in
autodiscover.info
autodiscover.nl
autodiscover.ru
autodiscover.u
autodiscover.w
autonavi.com
autumn.net
ayyildiz.de
base.de
berush.com
betterscience.org
binance.com
binary.com
bitbucket.io
bitdefender.com
bitdefender.net
blau.de
blauworld.de
blinksale.com
blogger.com
booztx.com
buddypress.org
bugcrowd.com
buildkiteartifacts.com
buildkiteassets.com
buildkite.com
buildkiteusercontent.com
byairbnb.com
cadre.com
caffeine.tv
cainiao.com
CAR10.net
cash.me
cbhq.net
cesppa.com
claritymoney.com
cobinhood.com
coinbase.com
coinfalcon.com
coinjar.com
colourbox.com
colourbox.de
colourbox.dk
concrete5.org
content.team
cougarlife.com
creditkarma.com
criteo.com
criteo.net
cudasvc.com
custhelp.com
cuvva.co
cuvva.com
cyberoam.com
cylance.com
damai.cn
data.com
dayu.com
defense.gov
deliveroo.com
deliveroo-data.io
deliveroo-data.net
deliveroo-data-test.io
deliveroo.net
delivery-club.ru
detectify.com
dev.media
dev.service
dev.support
dev.tool
dev.travel
digitaloceanspaces.com
dingtalk.com
directly.com
dns.ee
download.im
drchrono.com
drchronomedia.com
duckduckgo.com
dynoquant.com
dyson.com
earn.com
ebay-kleinanzeigen.de
editors.team
electroneum.com
envy.ph
establishedmen.com
etao.com
eventbrite.com
facebook.com
fanduel.com
fb.com
fb.me
fdbox.net
flickr.com
fliggy.com
fonic.de
fonic-mobile.de
force.com
freelancer.com
freemarket.com
freya.net
ftp.eu
ftp.gallery
ftp.in
ftp.media
ftp.new
fuzzing-project.org
fw-notify.net
gatecoin.com
geeny.io
getaltx.com
getmevo.com
getpostman.com
getsentry.com
getsentry.net
getsidekick.com
github.com
gitlab.com
gitter.im
gmail.com
gojekapi.com
goldman.com
goldmansachs.com
goodhire.com
google.com
gotinder.com
grab.co
grab.com
grabtaxi.com
grammarly.io
grammarly.net
gsam.com
gs.com
guardian.service
gusto.com
gusto-demo.com
hacker.one
hackerone.com
hackerone-ext-content.com
hackerone.net
hackerone-user-content.com
hboeck.de
healthifyme.com
highwebmedia.com
hitmanpro.com
hitmanpro.nl
honestdollar.com
hosted.by
hs-sites.com
hubapi.com
hubspot.com
hubspot.net
hulu.com
huluqa.com
ibm.com
icq.com
icq.net
identity.com
igpayment.com
ikarem.io
inbound.org
indeed.com
innogames.com
innogames.de
instagram.com
instapaper.com
intercomassets.com
intercomcdn.com
irccloud-cdn.com
irccloud.com
isc2cares.org
joomla.org
k-classic-mobil.de
kpn.com
labs-semrush.com
lamoda.ru
leantesting.com
leaseweb.com
letgo.com
liberapay.com
liberapay.org
library.co
lifeomic.com
live.com
live.net
livestream.com
load.support
localhost.cc
localhost.live
localhost.net
login.gov
lootdog.io
luxuryretreats.com
lync.com
ly.st
lyst.ca
lyst.com
made.by
magicleap.com
mail.biz
mail.black
mail.ci
mail.co
mail.eu
mail.exchange
mail.fr
mail.info
mail.jp
mail.media
mail.new
mail.pic
mail.plu
mail.support
mail.uk
mail.vip
mail.world
mapbox.com
marcus.com
mei.com
meraki.com
messenger.com
mevo.com
minodes.com
MIT.edu
mixmax.com
mojave.net
mozilla.net
mozilla.org
muscache.com
mx1.email
myastaro.com
mybank.cn
mykeymanager.com
myteksi.com
myteksi.net
naijatuale.com
nerdwallet.com
nero.cc
netflix.com
nettokom.de
network-auth.com
netzclub.net
newrelic.com
nflxext.com
nflximg.net
nflxvideo.net
nitata.com
nolimitvpn.com
norma-mobil.de
notjet.net
o2business.de
o2.de
o2online.de
o2service.de
oath.com
odnoklassniki.ru
office.com
ok.ru
onedrive.com
onpatient.com
ortelmobile.de
outlook.com
overstock.com
owncloud.com
owncloud.help
owncloud.org
owox.com
pandora.com
paydiant.com
paypal.com
payu.com
p-cdn.com
pegasus.cc
periscope.tv
pinterest.com
platform.sh
postman.co
prod.tool
pro.glas
pscp.tv
pstmn.io
purevpn.com
quantshack.com
quora.com
ratelimited.me
reflexion.net
remind.com
rets.io
rets.ly
retsly.com
rocket-internet.com
rocket-internet.de
s48.a
salesforce.com
salesforceiq.com
salesforceliveagent.com
salesforce.org
Sandboxie.com
savagebeast.com
season.net
secnews.gr
securegatewayaccess.com
secure.team
semrush.com
sfox.com
sharepoint.com
shenjing.com
shopify.com
shuqi.com
shuqireader.com
simfinity.de
simple.com
skyfish.com
skyscanner.com
skyscanner.net
sm.cn
smule.com
snapchat.com
soku.com
solarcity.com
sophos.com
spam.cn
spotflux.com
sproutsocial.com
square.com
squareup.com
staging-airtableblocks.com
staging.service
starbucks.ca
starbucks.com
starbucks.de
starbucks.fr
start.ru
summer.net
surfright.nl
sway.com
symphony.com
tech.team
telefonica.de
telegram.org
tesla.cn
tesla.com
teslamotors.com
tesla.service
tesla.services
test2.shop
test.exchange
test.support
theendlessweb.com
thefacebook.com
tinder.com
tmall.com
tornado.ee
tudou.com
tweetdeck.com
twilio.com
twimg.com
twitter.com
uber.com
uberinternal.com
ubnt.com
uc.cn
ucweb.com
udemy.com
umeng.com
upserve.com
upwork.com
urbandictionary.com
urbandictionary.net
vanillacommunities.com
vanilladevelopment.com
vanillaforums.com
vanillastaging.com
venmo.com
veritone.com
vhx.tv
vimeo.com
vine.co
vivy.com
warriorforum.com
webdisk.cloud
webdisk.cn
webdisk.de
webdisk.it
webdisk.me
webdisk.tech
webmail.blog
webmail.support
whatsapp.com
whatsapp.net
whatsappsim.de
who-is-using-me.com
will-never-love.me
withairbnb.com
wolfman.co
wordcamp.org
wordpress.net
wordpress.org
wrath.ph
xiami.com
xoom.com
yahoo.com
yahoo.net
yammer.com
yandex.com
yandex.ru
ycombinator.com
yelp.com
youku.com
youneedabudget.com
youtube.com
yunos.com
zellepay.com
zendesk.com
zeus.cc
zmbk.co
zoma.to
zomatobook.com
zomato.com
z.tt
zynga.com
zyngagames.com
127.0.0.1
`;
const BLACKLISTS = `
https://www.google.com/maps/embed
https://developer.mozilla.org/en-US/docs/
https://www.google.com/(search|recaptcha|sorry)
https://drive.google.com/\\w+/u/\\d+/preload
https://www.youtube.com/(watch|embed|search|results|playlist|channel)
`;
chrome.webRequest.onHeadersReceived.addListener(details=>{
if(!details.tabId) return; // return if it's missing tabId- idk
if(details.method!='GET') return; // return if not GET, assuming POST requests are CSRF protected
if(details.statusCode!=200) return; // return if not 200Ok, to avoid notifying for unnecessary things
const init = details.initiator || '';
if(init && init.startsWith('chrome-extension://')) return; // return if request initiated from an extension
const ignoreTypes = 'stylesheet,script,image,font,media,websocket'.split(',');
if(ignoreTypes.includes(details.type)) return; // return if not active document
const domain = new URL(details.url).hostname;
const parts = domain.split('.').reverse();
const pattern = new RegExp(`^[\\w.]*${parts[1]}\\.${parts[0]}$`, 'mu');
const match = WHITELISTS.match(pattern);
if(match && domain.endsWith(match)){
if(false==BLACKLISTS.split('\n').filter(url=>{return(url && new RegExp('^'+url.replace(/[.?\/[{'^"}\]&$]/g, '\\$&'), 'mu').test(details.url))})){
chrome.tabs.sendMessage(details.tabId, {url:details.url,body:'xsproceed'});
const validDocs = 'text/html,application/html,text/xml,application/xml,application/xhtml';
try{
const headers = JSON.stringify(details.responseHeaders);
let contentType = headers.match(/content-type","value":"([^"]+?)"/i)[1] || 'text/html';
if(!validDocs.includes(contentType.split(';')[0])) return; // return if the document is not an active document
let xxp = headers.match(/x-xss-protection","value":"([^"]+?)"/i)[1] || 1;
if(/block/i.test(xxp)) compare(details.url, details.tabId); // return if xxp is not set to block
// TODO: also consider filter mode
}
catch(e){
return;
}
}
}
},
{urls: ["<all_urls>"]},
["responseHeaders"]
);