forked from webtaculars/Universal-Bypass
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbackground.js
654 lines (612 loc) · 16.5 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
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
const brws=(typeof browser=="undefined"?chrome:browser),
platform=brws.runtime.getURL("").split("-")[0],
getRedirectUrl=(url,tracker)=>(instantNavigation||(tracker&&instantNavigationTrackers)?url:brws.runtime.getURL("html/before-navigate.html")+"?target="+encodeURIComponent(url)),
getRedirect=(url,tracker)=>({redirectUrl:getRedirectUrl(url,tracker)}),
encodedRedirect=url=>({redirectUrl:(instantNavigation?decodeURIComponent(url):brws.runtime.getURL("html/before-navigate.html")+"?target="+url)}),
isGoodLink=link=>{
if(!link||link.split("#")[0]==location.href.split("#")[0]||link.substr(0,6)=="about:"||link.substr(0,11)=="javascript:")
{
return false
}
try
{
new URL(link)
}
catch(e)
{
return false
}
return true
}
//Install & Uninstall Actions
brws.runtime.onInstalled.addListener(details=>{
if(details.reason=="install")
{
if(platform=="moz")
{
brws.windows.create({url:"https://universal-bypass.org/firstrun"})
}
else
{
window.open("https://universal-bypass.org/firstrun")
}
}
})
brws.runtime.setUninstallURL("https://docs.google.com/forms/d/e/1FAIpQLSdXw-Yf5IaDXZWw4fDHroZkDFOF6hgWEvVDaXT9ZADqnF2reg/viewform")
//Keeping track of options
var enabled=true,trackerBypassEnabled=true,instantNavigationTrackers=false,blockIPLoggers=true,crowdEnabled=true,userscript=""
brws.storage.sync.get(["disable","no_tracker_bypass","instant_navigation","no_instant_navigation_trackers","allow_ip_loggers","crowd_bypass_opt_out"],res=>{
if(res)
{
enabled=(!res.disable||res.disable!=="true")
if(!enabled)
{
brws.browserAction.setIcon({path: {
"40": "icon_disabled/40.png",
"48": "icon_disabled/48.png",
"128": "icon_disabled/128.png",
"150": "icon_disabled/150.png",
"176": "icon_disabled/176.png",
"512": "icon_disabled/512.png"
}})
}
trackerBypassEnabled=(!res.no_tracker_bypass||res.no_tracker_bypass!=="true")
instantNavigation=(res.instant_navigation&&res.instant_navigation==="true")
instantNavigationTrackers=(!res.no_instant_navigation_trackers||res.no_instant_navigation_trackers!=="true")
blockIPLoggers=(!res.allow_ip_loggers||res.allow_ip_loggers!=="true")
crowdEnabled=(!res.crowd_bypass_opt_out||res.crowd_bypass_opt_out!=="true")
}
})
brws.storage.local.get(["userscript"],res=>{
if(res&&res.userscript)
{
userscript=res.userscript
}
})
brws.storage.onChanged.addListener(changes=>{
if(changes.disable)
{
enabled=(changes.disable.newValue!=="true")
if(enabled)
{
brws.browserAction.setIcon({path: {
"40": "icon/40.png",
"48": "icon/48.png",
"128": "icon/128.png",
"150": "icon/150.png",
"176": "icon/176.png",
"512": "icon/512.png"
}})
}
else
{
brws.browserAction.setIcon({path: {
"40": "icon_disabled/40.png",
"48": "icon_disabled/48.png",
"128": "icon_disabled/128.png",
"150": "icon_disabled/150.png",
"176": "icon_disabled/176.png",
"512": "icon_disabled/512.png"
}})
}
}
if(changes.no_tracker_bypass)
{
trackerBypassEnabled=(changes.no_tracker_bypass.newValue!=="true")
}
if(changes.instant_navigation)
{
instantNavigation=(changes.instant_navigation.newValue==="true")
}
if(changes.no_instant_navigation_trackers)
{
instantNavigationTrackers=(changes.no_instant_navigation_trackers.newValue!=="true")
}
if(changes.allow_ip_loggers)
{
blockIPLoggers=(changes.allow_ip_loggers.newValue!=="true")
}
if(changes.crowd_bypass_opt_out)
{
crowdEnabled=(changes.crowd_bypass_opt_out.newValue!=="true")
}
if(changes.userscript)
{
userscript=changes.userscript.newValue
}
})
//Messaging
brws.runtime.onMessage.addListener((req, sender, respond) => {
switch(req.type)
{
case "can-run":
respond({
enabled: enabled,
crowdEnabled: crowdEnabled,
userscript: userscript
})
break
case "crowd-contribute":
if(crowdEnabled)
{
let xhr=new XMLHttpRequest()
xhr.open("POST","https://universal-bypass.org/crowd/contribute_v1",true)
xhr.setRequestHeader("Content-Type","application/x-www-form-urlencoded")
xhr.send(req.data)
}
else
{
console.warn("Unexpected message:", req)
}
break
default:
console.warn("Invalid message:", req)
}
})
brws.runtime.onConnect.addListener(port => {
console.assert(port.name == "adlinkfly-info")
port.onMessage.addListener(msg => {
let xhr=new XMLHttpRequest(),t="",iu=msg
xhr.onload=()=>{
let i=new DOMParser().parseFromString(xhr.responseText,"text/html").querySelector("img[src^='//api.miniature.io']")
if(i)
{
let url=new URL(i.src)
if(url.search&&url.search.indexOf("url="))
{
t=decodeURIComponent(url.search.split("url=")[1].split("&")[0])
}
}
port.postMessage(t)
}
xhr.onerror=()=>port.postMessage(t)
if(iu.substr(iu.length - 1) != "/")
{
iu += "/"
}
xhr.open("GET", iu+"info", true)
xhr.send()
})
})
//Internal redirects to extension URLs to bypass content script limitations
brws.webRequest.onBeforeRequest.addListener(details=>{
if(details.url.substr(38)=="1")
{
return {redirectUrl:brws.runtime.getURL("html/firstrun.html")}
}
else
{
return {redirectUrl:brws.runtime.getURL("html/firstrun-noscript.html")}
}
},{types:["main_frame"],urls:["https://universal-bypass.org/firstrun?*"]},["blocking"])
brws.webRequest.onBeforeRequest.addListener(details=>{
return encodedRedirect(details.url.substr(52))
},{types:["main_frame"],urls:["https://universal-bypass.org/before-navigate?target=*"]},["blocking"])
brws.webRequest.onBeforeRequest.addListener(details=>{
return {redirectUrl:brws.runtime.getURL("html/crowd-bypassed.html")+details.url.substr(43)}
},{types:["main_frame"],urls:["https://universal-bypass.org/crowd-bypassed?*"]},["blocking"])
//Preflight Bypasses
brws.webRequest.onBeforeRequest.addListener(details=>{
if(enabled)
{
return getRedirect(details.url.substr(details.url.indexOf("url=")+4))
}
},{types:["main_frame"],urls:["*://*/st?api=*&url=*","*://*.zxro.com/u/*?url=*"]},["blocking"])
brws.webRequest.onBeforeRequest.addListener(details=>{
if(enabled)
{
let url=new URL(details.url)
if(url.searchParams.has("url"))
{
return getRedirect(url.searchParams.get("url"))
}
}
},{types:["main_frame"],urls:[
"*://*.news-gg.com/l/?*",
"*://*.mobile01.com/redirect.php?*",
"*://ref.gamer.com.tw/redir.php?*"
]},["blocking"])
brws.webRequest.onBeforeRequest.addListener(details=>{
if(enabled)
{
let url=new URL(details.url)
if(url.search)
{
return getRedirect(url.search.substr(1))+url.hash
}
}
},{types:["main_frame"],urls:["*://*.anonym.to/?*"]},["blocking"])
brws.webRequest.onBeforeRequest.addListener(details=>{
if(enabled)
{
return encodedRedirect(details.url.substr(details.url.indexOf("link=")+5))
}
},{types:["main_frame"],urls:["*://*.spaste.com/r/*link=*",]},["blocking"])
brws.webRequest.onBeforeRequest.addListener(details=>{
if(enabled)
{
return getRedirect(atob(details.url.substr(details.url.indexOf("?link=")+6)))
}
},{types:["main_frame"],urls:["*://*.leechpremium.link/cheat/?link=*"]},["blocking"])
brws.webRequest.onBeforeRequest.addListener(details=>{
if(enabled)
{
return getRedirect(atob(details.url.substr(details.url.indexOf("?kesehatan=")+11)))
}
},{types:["main_frame"],urls:["*://*.infosia.xyz/?kesehatan=*"]},["blocking"])
brws.webRequest.onBeforeRequest.addListener(details=>{
if(enabled)
{
return getRedirect(atob(new URL(details.url).searchParams.values().next().value))
}
},{types:["main_frame"],urls:[
"*://pafpaf.info/?*=*",
"*://binerfile.info/?*=*",
"*://kurosafety.menantisenja.com/?*=*"
]},["blocking"])
brws.webRequest.onBeforeRequest.addListener(details=>{
if(enabled)
{
return getRedirect(atob(details.url.substr(details.url.indexOf("?r=")+3)))
}
},{types:["main_frame"],urls:["*://yumechan.club/?r=*"]},["blocking"])
brws.webRequest.onBeforeRequest.addListener(details=>{
if(enabled)
{
return encodedRedirect(details.url.substr(details.url.indexOf("?s=")+3))
}
},{types:["main_frame"],urls:[
"*://*.ouo.io/s/*?s=*",
"*://*.ouo.io/qs/*?s=*",
"*://*.cpmlink.net/s/*?s=*"
]},["blocking"])
brws.webRequest.onBeforeRequest.addListener(details=>{
if(enabled)
{
return encodedRedirect(details.url.substr(details.url.indexOf("/12/1/")+6))
}
},{types:["main_frame"],urls:["*://*.sh.st/r/*/12/1/*"]},["blocking"])
brws.webRequest.onBeforeRequest.addListener(details=>{
if(enabled)
{
return encodedRedirect(details.url.substr(details.url.indexOf("/s/")+3))
}
},{types:["main_frame"],urls:["*://*.gslink.co/e/*/s/*"]},["blocking"])
brws.webRequest.onBeforeRequest.addListener(details=>{
if(enabled)
{
let url=details.url
do
{
let arr=url.substr(19).split("/")
if(arr.length!=2)
{
return
}
url=atob(arr[1])
}
while(url.length>=19&&url.substr(0,19)=="http://gslink.co/a/");
if(url!=details.url&&isGoodLink(url))
{
return getRedirect(url)
}
}
},{types:["main_frame"],urls:["http://gslink.co/a/*"]},["blocking"])
brws.webRequest.onBeforeRequest.addListener(details=>{
if(enabled)
{
let url=new URL(details.url)
if(url.searchParams.has("u"))
{
return getRedirect(atob(url.searchParams.get("u"))+url.hash)
}
}
},{types:["main_frame"],urls:["*://*.noriskdomain.com/*/analyze?*"]},["blocking"])
brws.webRequest.onBeforeRequest.addListener(details=>{
if(enabled)
{
return getRedirect(atob(details.url.substr(details.url.indexOf("/dl/")+4)))
}
},{types:["main_frame"],urls:["*://*.k2nblog.com/dl/*"]},["blocking"])
brws.webRequest.onBeforeRequest.addListener(details=>{
if(enabled)
{
let url=new URL(details.url)
if(url.searchParams.has("id"))
{
return getRedirect(atob(url.searchParams.get("id").split("").reverse().join("")))
}
}
},{types:["main_frame"],urls:["*://*.masterads.info/instagram/campanha.php?*"]},["blocking"])
brws.webRequest.onBeforeRequest.addListener(details=>{
if(enabled)
{
let url=new URL(details.url)
if(url.searchParams.has("go"))
{
return getRedirect("https://clickar.net/"+url.searchParams.get("go"))
}
}
},{types:["main_frame"],urls:["*://*.surfsees.com/?*"]},["blocking"])
brws.webRequest.onBeforeRequest.addListener(details=>{
if(enabled)
{
let url=new URL(details.url)
if(url.searchParams.has("href"))
{
return getRedirect(url.searchParams.get("href"))
}
}
},{types:["main_frame"],urls:["*://*.maranhesduve.club/?*"]},["blocking"])
brws.webRequest.onBeforeRequest.addListener(details=>{
if(enabled)
{
let url=new URL(details.url)
if(url.searchParams.has("id"))
{
return getRedirect(atob(url.searchParams.get("id")).split("!").join("a").split(")").join("e").split("_").join("i").split("(").join("o").split("*").join("u"))
}
}
},{types:["main_frame"],urls:[
"*://*.safelinkconverter.com/*?*",
"*://*.safelinkreview.com/*?*",
"*://*.safelinkreviewx.com/*?*",
"*://*.safelinkreview.co/*?*",
"*://*.awsubsco.ml/*?*",
"*://*.awsubsco.cf/*?*"
]},["blocking"])
//Ouo.io/press Crowd Bypass
brws.webRequest.onHeadersReceived.addListener(details=>{
if(enabled)
{
let url = new URL(details.url), target
for(let i in details.responseHeaders)
{
let header = details.responseHeaders[i]
if(header.name.toLowerCase() == "location" && isGoodLink(header.value))
{
details.responseHeaders[i].value = getRedirectUrl(target = header.value)
break
}
}
if(target)
{
let xhr=new XMLHttpRequest()
xhr.open("POST","https://universal-bypass.org/crowd/contribute_v1",true)
xhr.setRequestHeader("Content-Type","application/x-www-form-urlencoded")
xhr.send("domain=ouo.io&path="+encodeURIComponent(url.pathname.split("/")[2])+"&target="+encodeURIComponent(target))
return{responseHeaders:details.responseHeaders}
}
}
},{types:["main_frame"],urls:[
"*://*.ouo.io/go/*",
"*://*.ouo.press/go/*",
"*://*.ouo.io/rgo/*",
"*://*.ouo.press/rgo/*"
]},["blocking","responseHeaders"])
//Fixing Content-Security-Policy on Firefox because apparently extensions have no special privileges in Firefox
if(platform=="moz")
{
brws.webRequest.onHeadersReceived.addListener(details=>{
if(enabled)
{
let csp = false
for(let i in details.responseHeaders)
{
if("value"in details.responseHeaders[i]&&["content-security-policy","x-content-security-policy"].indexOf(details.responseHeaders[i].name.toLowerCase())>-1)
{
csp = true
let _policies = details.responseHeaders[i].value.replace(";,",";").split(";"),
policies = {}
for(let j in _policies)
{
let policy = _policies[j].trim(),name=policy.split(" ")[0]
policies[name] = policy.substr(name.length).trim().split(" ")
}
if(!("script-src"in policies)&&"default-src"in policies)
{
policies["script-src"] = policies["default-src"]
let ni = policies["script-src"].indexOf("'none'")
if(ni > -1)
{
policies["script-src"].splice(ni, 1)
}
}
if("script-src"in policies)
{
if(policies["script-src"].indexOf("'unsafe-inline'")==-1)
{
policies["script-src"].push("'unsafe-inline'")
}
if(policies["script-src"].indexOf("'unsafe-eval'")==-1)
{
policies["script-src"].push("'unsafe-eval'")
}
}
else
{
policies["script-src"]=["*","blob:","data:","'unsafe-inline'","'unsafe-eval'"]
}
let value=""
for(let name in policies)
{
value+=name
for(let j in policies[name])
{
value+=" "+policies[name][j]
}
value+="; "
}
details.responseHeaders[i].value=value.substr(0,value.length-2)
}
}
if(csp)
{
return{responseHeaders:details.responseHeaders}
}
}
},{types:["main_frame"],urls:["<all_urls>"]},["blocking","responseHeaders"])
}
//Tracker Bypass using Apimon.de
function resolveRedirect(url)
{
let xhr=new XMLHttpRequest(),destination
xhr.onload=()=>{
let json=JSON.parse(xhr.responseText)
if(json&&json.destination)
destination=json.destination
}
xhr.open("GET","https://apimon.de/redirect/"+encodeURIComponent(url),false)
xhr.send()
return destination
}
brws.webRequest.onBeforeRequest.addListener(details=>{
if(trackerBypassEnabled&&new URL(details.url).pathname!="/")
{
let destination=resolveRedirect(details.url)
if(destination&&destination!=details.url)
{
return getRedirect(destination,true)
}
}
},{
types:["main_frame"],
urls:[
"*://*.great.social/*",
"*://*.send.digital/*",
"*://*.snipli.com/*",
"*://*.shortcm.li/*",
"*://*.page.link/*",
"*://*.go2l.ink/*",
"*://*.buff.ly/*",
"*://*.snip.li/*",
"*://*.hive.am/*",
"*://*.cutt.ly/*",
"*://*.tiny.ie/*",
"*://*.bit.ly/*",
"*://*.goo.gl/*",
"*://*.bit.do/*",
"*://*.t2m.io/*",
"*://*.dis.gd/*",
"*://*.zii.bz/*",
"*://*.plu.sh/*",
"*://*.b.link/*",
"*://*.po.st/*",
"*://*.ow.ly/*",
"*://*.is.gd/*",
"*://*.1b.yt/*",
"*://*.1w.tf/*",
"*://*.t.co/*",
"*://*.x.co/*"
]
},["blocking"])
brws.webRequest.onBeforeRequest.addListener(details=>{
if(new URL(details.url).pathname!="/")
{
if(trackerBypassEnabled)
{
let destination=resolveRedirect(details.url)
if(destination&&destination!=details.url)
{
return getRedirect(destination,true)
}
}
if(blockIPLoggers)
{
return {redirectUrl:brws.runtime.getURL("html/blocked.html")}
}
}
},{types:["main_frame"],urls:getIPLoggerPatterns()},["blocking"])
function getIPLoggerPatterns()
{
let patterns=[],
//https://github.com/timmyrs/Evil-Domains/blob/master/lists/IP%20Loggers.txt
ipLoggers=`viral.over-blog.com
gyazo.in
ps3cfw.com
urlz.fr
webpanel.space
steamcommumity.com
i.imgur.com.de
www.fuglekos.com
# Grabify
grabify.link
bmwforum.co
leancoding.co
quickmessage.io
spottyfly.com
spötify.com
stopify.co
yoütu.be
yoütübe.co
yoütübe.com
xda-developers.io
starbucksiswrong.com
starbucksisbadforyou.com
bucks.as
discörd.com
minecräft.com
cyberh1.xyz
discördapp.com
freegiftcards.co
disçordapp.com
rëddït.com
# Cyberhub (formerly SkypeGrab)
ġooģle.com
drive.ġooģle.com
maps.ġooģle.com
disċordapp.com
ìṃgur.com
transferfiles.cloud
tvshare.co
publicwiki.me
hbotv.co
gameskeys.shop
videoblog.tech
twitch-stats.stream
anonfiles.download
bbcbloggers.co.uk
# Yip
yip.su
iplogger.com
iplogger.org
iplogger.ru
2no.co
02ip.ru
iplis.ru
iplo.ru
ezstat.ru
# What's their IP
www.whatstheirip.com
www.hondachat.com
www.bvog.com
www.youramonkey.com
# Pronosparadise
pronosparadise.com
freebooter.pro
# Blasze
blasze.com
blasze.tk
# IPGrab
ipgrab.org
i.gyazos.com`,
lines=ipLoggers.split("\n")
for(let i in lines)
{
let line=lines[i].trim()
if(line&&line.substr(0,1)!="#")
{
if(line.substr(0,4)=="www.")
line=line.substr(4)
else if(line.substr(0,2)=="i.")
line=line.substr(2)
else if(line.substr(0,6)=="drive.")
line=line.substr(6)
else if(line.substr(0,5)=="maps.")
line=line.substr(5)
if(patterns.indexOf(line)==-1)
patterns.push("*://*."+line+"/*")
}
}
return patterns
}