Universal-Bypass/background.js

515 lines
13 KiB
JavaScript
Raw Normal View History

2019-04-25 18:30:47 +02:00
const brws=(typeof browser=="undefined"?chrome:browser),
platform=brws.runtime.getURL("").split("-")[0];
2019-01-11 23:23:44 +01:00
//Keeping track of options
2019-04-25 18:30:47 +02:00
var enabled=true,
instantNavigation=false,
trackerBypassEnabled=true,
blockIPLoggers=true,
crowdEnabled=true,
2019-01-17 16:04:45 +01:00
userscript="",
2019-03-09 12:47:57 +01:00
getRedirectUrl=url=>(instantNavigation?url:brws.runtime.getURL("html/before-navigate.html")+"?target="+encodeURIComponent(url)),
getRedirect=url=>({redirectUrl:getRedirectUrl(url)}),
encodedRedirect=url=>({redirectUrl:(instantNavigation?decodeURIComponent(url):brws.runtime.getURL("html/before-navigate.html")+"?target="+url)}),
isGoodLink=link=>{
2019-03-10 18:48:59 +01:00
if(!link||link.split("#")[0]==location.href.split("#")[0]||link.substr(0,6)=="about:"||link.substr(0,11)=="javascript:")
2019-03-09 12:47:57 +01:00
{
return false
}
try
{
new URL(link)
}
catch(e)
{
return false
}
return true
}
2019-01-11 19:28:26 +01:00
brws.storage.sync.get(["disable","instant_navigation","no_tracker_bypass","allow_ip_loggers","crowd_bypass_opt_out"],res=>{
if(res)
{
enabled=(!res.disable||res.disable!=="true")
instantNavigation=(res.instant_navigation&&res.instant_navigation==="true")
trackerBypassEnabled=(!res.no_tracker_bypass||res.no_tracker_bypass!=="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(changes.instant_navigation)
{
instantNavigation=(changes.instant_navigation.newValue==="true")
}
if(changes.no_tracker_bypass)
{
trackerBypassEnabled=(changes.no_tracker_bypass.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
}
})
2019-04-13 09:11:13 +02:00
2019-04-02 12:13:14 +02:00
brws.runtime.onMessage.addListener((req, sender, respond) => {
switch(req.type)
{
case "can-run":
respond({
enabled: enabled,
crowdEnabled: crowdEnabled,
userscript: userscript
})
break;
2019-04-13 09:11:13 +02:00
case "crowd-contribute":
if(crowdEnabled)
{
2019-04-10 19:47:18 +02:00
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)
}
2019-04-13 09:11:13 +02:00
else console.warn("Unexpected message:", req)
2019-04-10 19:47:18 +02:00
break;
2019-04-13 09:11:13 +02:00
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="))
2019-04-02 12:13:14 +02:00
{
2019-04-13 09:11:13 +02:00
t=decodeURIComponent(url.search.split("url=")[1].split("&")[0])
2019-04-02 12:13:14 +02:00
}
}
2019-04-13 09:11:13 +02:00
port.postMessage(t)
2019-04-02 12:13:14 +02:00
}
2019-04-13 09:11:13 +02:00
xhr.onerror=()=>port.postMessage(t)
if(iu.substr(iu.length - 1) != "/")
{
iu += "/"
}
xhr.open("GET", iu+"info", true)
xhr.send()
})
2019-01-17 16:04:45 +01:00
})
2019-01-11 19:28:26 +01:00
2019-04-25 18:30:47 +02:00
//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")
2019-01-11 23:23:44 +01:00
//Internal redirects to extension URLs to bypass content script limitations
brws.webRequest.onBeforeRequest.addListener(details=>{
2019-01-17 02:58:06 +01:00
if(details.url.substr(38)=="1")
2019-01-11 23:23:44 +01:00
{
2019-01-17 02:58:06 +01:00
return {redirectUrl:brws.runtime.getURL("html/firstrun.html")}
2019-01-11 23:23:44 +01:00
}
2019-01-17 02:58:06 +01:00
else
{
return {redirectUrl:brws.runtime.getURL("html/firstrun-noscript.html")}
}
},{types:["main_frame"],urls:["https://universal-bypass.org/firstrun?*"]},["blocking"])
2019-01-11 23:23:44 +01:00
brws.webRequest.onBeforeRequest.addListener(details=>{
2019-01-17 02:58:06 +01:00
return encodedRedirect(details.url.substr(52))
},{types:["main_frame"],urls:["https://universal-bypass.org/before-navigate?target=*"]},["blocking"])
2019-01-11 23:23:44 +01:00
brws.webRequest.onBeforeRequest.addListener(details=>{
2019-01-17 02:58:06 +01:00
return {redirectUrl:brws.runtime.getURL("html/crowd-bypassed.html")+details.url.substr(43)}
},{types:["main_frame"],urls:["https://universal-bypass.org/crowd-bypassed?*"]},["blocking"])
2019-01-11 23:23:44 +01:00
2019-02-01 04:39:53 +01:00
//Preflight Bypasses
2019-01-11 19:28:26 +01:00
brws.webRequest.onBeforeRequest.addListener(details=>{
2019-01-17 02:58:06 +01:00
if(enabled)
{
2019-01-30 20:21:00 +01:00
return getRedirect(details.url.substr(details.url.indexOf("url=")+4))
2019-01-17 02:58:06 +01:00
}
2019-02-03 20:04:53 +01:00
},{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"))
}
}
2019-02-02 22:00:42 +01:00
},{types:["main_frame"],urls:[
"*://*.raidcall.com.tw/direct.php?url=*",
2019-04-27 11:57:40 +02:00
"*://*.raidcall.com.tw/direct.tips.php?url=*",
"*://news-gg.com/l/?*"
2019-02-02 22:00:42 +01:00
]},["blocking"])
2019-01-11 19:28:26 +01:00
brws.webRequest.onBeforeRequest.addListener(details=>{
2019-01-17 02:58:06 +01:00
if(enabled)
{
2019-01-11 19:28:26 +01:00
return encodedRedirect(details.url.substr(details.url.indexOf("link=")+5))
2019-01-17 02:58:06 +01:00
}
},{types:["main_frame"],urls:["*://*.spaste.com/r/*link=*",]},["blocking"])
2019-01-11 19:28:26 +01:00
brws.webRequest.onBeforeRequest.addListener(details=>{
2019-01-17 02:58:06 +01:00
if(enabled)
{
2019-01-11 19:28:26 +01:00
return getRedirect(atob(details.url.substr(details.url.indexOf("?link=")+6)))
2019-01-17 02:58:06 +01:00
}
},{types:["main_frame"],urls:["*://*.leechpremium.link/cheat/?link=*"]},["blocking"])
2019-01-11 19:28:26 +01:00
brws.webRequest.onBeforeRequest.addListener(details=>{
2019-01-17 02:58:06 +01:00
if(enabled)
{
2019-01-11 19:28:26 +01:00
return encodedRedirect(details.url.substr(details.url.indexOf("?s=")+3))
2019-01-17 02:58:06 +01:00
}
},{types:["main_frame"],urls:["*://*.ouo.io/s/*?s=*","*://*.cpmlink.net/s/*?s=*"]},["blocking"])
2019-01-11 19:28:26 +01:00
brws.webRequest.onBeforeRequest.addListener(details=>{
2019-01-17 02:58:06 +01:00
if(enabled)
{
2019-01-11 19:28:26 +01:00
return encodedRedirect(details.url.substr(details.url.indexOf("/12/1/")+6))
2019-01-17 02:58:06 +01:00
}
},{types:["main_frame"],urls:["*://*.sh.st/r/*/12/1/*"]},["blocking"])
2019-01-11 19:28:26 +01:00
brws.webRequest.onBeforeRequest.addListener(details=>{
2019-01-17 02:58:06 +01:00
if(enabled)
{
2019-01-11 19:28:26 +01:00
return encodedRedirect(details.url.substr(details.url.indexOf("/s/")+3))
2019-01-17 02:58:06 +01:00
}
},{types:["main_frame"],urls:["*://*.gslink.co/e/*/s/*"]},["blocking"])
2019-01-11 19:28:26 +01:00
2019-01-22 19:39:15 +01:00
brws.webRequest.onBeforeRequest.addListener(details=>{
if(enabled)
{
2019-01-28 15:00:24 +01:00
let url=new URL(details.url)
if(url.searchParams.has("u"))
2019-01-26 17:40:40 +01:00
{
2019-01-28 15:00:24 +01:00
return getRedirect(atob(url.searchParams.get("u"))+url.hash)
2019-01-26 17:40:40 +01:00
}
2019-01-22 19:39:15 +01:00
}
2019-01-26 17:40:40 +01:00
},{types:["main_frame"],urls:["*://*.noriskdomain.com/*/analyze?*"]},["blocking"])
2019-01-22 19:39:15 +01:00
2019-03-08 08:51:36 +01:00
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"])
2019-04-19 06:57:57 +02:00
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"])
//Ouo.io/press Crowd Bypass
2019-03-09 12:47:57 +01:00
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]
2019-04-02 12:13:14 +02:00
if(header.name.toLowerCase() == "location" && isGoodLink(header.value))
2019-03-09 12:47:57 +01:00
{
details.responseHeaders[i].value = getRedirectUrl(target = header.value)
break
}
}
if(target)
{
let xhr=new XMLHttpRequest()
2019-04-10 19:47:18 +02:00
xhr.open("POST","https://universal-bypass.org/crowd/contribute_v1",true)
2019-03-09 12:47:57 +01:00
xhr.setRequestHeader("Content-Type","application/x-www-form-urlencoded")
2019-03-09 13:04:57 +01:00
xhr.send("domain=ouo.io&path="+encodeURIComponent(url.pathname.split("/")[2])+"&target="+encodeURIComponent(target))
2019-03-09 12:47:57 +01:00
return{responseHeaders:details.responseHeaders}
}
}
},{types:["main_frame"],urls:[
2019-03-09 13:04:57 +01:00
"*://*.ouo.io/go/*",
"*://*.ouo.press/go/*",
2019-03-09 12:47:57 +01:00
"*://*.ouo.io/rgo/*",
"*://*.ouo.press/rgo/*"
]},["blocking","responseHeaders"])
2018-11-09 15:00:05 +01:00
//Fixing Content-Security-Policy on Firefox because apparently extensions have no special privileges in Firefox
2019-04-25 18:30:47 +02:00
if(platform=="moz")
2019-01-11 19:28:26 +01:00
{
2018-12-05 09:04:17 +01:00
brws.webRequest.onHeadersReceived.addListener(details=>{
2019-01-17 02:58:06 +01:00
if(enabled)
2018-11-09 15:00:05 +01:00
{
2019-01-17 02:58:06 +01:00
let csp = false
2018-11-09 15:00:05 +01:00
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)
{
2019-01-17 02:58:06 +01:00
csp = true
let _policies = details.responseHeaders[i].value.replace(";,",";").split(";"),
policies = {}
2018-11-09 15:00:05 +01:00
for(let j in _policies)
{
2019-01-17 02:58:06 +01:00
let policy = _policies[j].trim(),name=policy.split(" ")[0]
policies[name] = policy.substr(name.length).trim().split(" ")
2018-11-09 15:00:05 +01:00
}
2018-11-10 10:25:19 +01:00
if(!("script-src"in policies)&&"default-src"in policies)
2018-11-09 15:00:05 +01:00
{
2019-01-17 02:58:06 +01:00
policies["script-src"] = policies["default-src"]
let ni = policies["script-src"].indexOf("'none'")
if(ni > -1)
{
2018-11-10 10:25:19 +01:00
policies["script-src"].splice(ni, 1)
2019-01-17 02:58:06 +01:00
}
2018-11-10 14:09:09 +01:00
}
if("script-src"in policies)
{
2018-11-09 15:00:05 +01:00
if(policies["script-src"].indexOf("'unsafe-inline'")==-1)
2019-01-17 02:58:06 +01:00
{
2018-11-09 15:00:05 +01:00
policies["script-src"].push("'unsafe-inline'")
2019-01-17 02:58:06 +01:00
}
2018-11-09 15:00:05 +01:00
if(policies["script-src"].indexOf("'unsafe-eval'")==-1)
2019-01-17 02:58:06 +01:00
{
2018-11-09 15:00:05 +01:00
policies["script-src"].push("'unsafe-eval'")
2019-01-17 02:58:06 +01:00
}
2018-11-09 15:00:05 +01:00
}
else
2019-01-04 21:17:38 +01:00
{
2018-11-10 14:09:09 +01:00
policies["script-src"]=["*","blob:","data:","'unsafe-inline'","'unsafe-eval'"]
2019-01-04 21:17:38 +01:00
}
2018-11-09 15:00:05 +01:00
let value=""
for(let name in policies)
{
value+=name;
for(let j in policies[name])
{
value+=" "+policies[name][j]
}
value+="; "
}
2018-11-10 10:25:19 +01:00
details.responseHeaders[i].value=value.substr(0,value.length-2)
2018-11-09 15:00:05 +01:00
}
}
2018-11-10 14:09:09 +01:00
if(csp)
2019-01-01 18:43:20 +01:00
{
2018-11-10 14:09:09 +01:00
return{responseHeaders:details.responseHeaders}
2019-01-01 18:43:20 +01:00
}
2018-11-09 15:00:05 +01:00
}
2019-01-17 02:58:06 +01:00
},{types:["main_frame"],urls:["<all_urls>"]},["blocking","responseHeaders"])
2019-01-11 19:28:26 +01:00
}
2018-10-02 19:31:00 +02:00
2018-12-30 12:25:26 +01:00
//Tracker Bypass using Apimon.de; see options for more details.
function resolveRedirect(url)
{
2018-08-22 19:09:23 +02:00
let xhr=new XMLHttpRequest(),destination
2019-04-13 09:11:13 +02:00
xhr.onload=()=>{
let json=JSON.parse(xhr.responseText)
if(json&&json.destination)
destination=json.destination
2018-07-03 10:18:59 +02:00
}
2018-12-01 01:34:17 +01:00
xhr.open("GET","https://apimon.de/redirect/"+encodeURIComponent(url),false)
2018-07-03 23:52:38 +02:00
xhr.send()
2018-08-22 19:09:23 +02:00
return destination
}
2018-12-05 09:04:17 +01:00
brws.webRequest.onBeforeRequest.addListener(details=>{
2019-01-17 02:58:06 +01:00
if(trackerBypassEnabled && new URL(details.url).pathname != "/")
2019-01-11 19:28:26 +01:00
{
2019-01-17 02:58:06 +01:00
let destination = resolveRedirect(details.url)
if(destination && destination != details.url)
{
return {redirectUrl: destination}
}
2019-01-11 19:28:26 +01:00
}
2018-08-22 19:09:23 +02:00
},{
2019-01-17 02:58:06 +01:00
types:["main_frame"],
2018-08-22 19:09:23 +02:00
urls:[
2018-07-11 11:59:08 +02:00
"*://*.great.social/*",
"*://*.send.digital/*",
"*://*.snipli.com/*",
"*://*.shortcm.li/*",
"*://*.page.link/*",
2018-07-13 20:22:59 +02:00
"*://*.go2l.ink/*",
2018-07-11 11:59:08 +02:00
"*://*.buff.ly/*",
"*://*.snip.li/*",
"*://*.hive.am/*",
"*://*.cutt.ly/*",
"*://*.tiny.ie/*",
2018-07-03 23:52:38 +02:00
"*://*.bit.ly/*",
2018-07-04 02:30:44 +02:00
"*://*.goo.gl/*",
2018-07-11 11:59:08 +02:00
"*://*.bit.do/*",
"*://*.t2m.io/*",
"*://*.dis.gd/*",
"*://*.zii.bz/*",
"*://*.plu.sh/*",
"*://*.b.link/*",
"*://*.po.st/*",
"*://*.ow.ly/*",
"*://*.is.gd/*",
"*://*.1b.yt/*",
"*://*.1w.tf/*",
"*://*.t.co/*",
2018-08-22 19:09:23 +02:00
"*://*.x.co/*"
]
},["blocking"])
2018-12-05 09:04:17 +01:00
brws.webRequest.onBeforeRequest.addListener(details=>{
2019-01-17 02:58:06 +01:00
if(new URL(details.url).pathname != "/")
2018-08-22 19:09:23 +02:00
{
2019-01-11 19:28:26 +01:00
if(trackerBypassEnabled)
{
2019-01-17 02:58:06 +01:00
let destination = resolveRedirect(details.url)
if(destination && destination != details.url)
2019-01-11 19:28:26 +01:00
{
2019-01-17 02:58:06 +01:00
return {redirectUrl: destination}
2019-01-11 19:28:26 +01:00
}
}
if(blockIPLoggers)
{
2019-01-17 02:58:06 +01:00
return {redirectUrl: brws.runtime.getURL("html/blocked.html")}
2019-01-11 19:28:26 +01:00
}
2018-08-22 19:09:23 +02:00
}
2019-01-17 02:58:06 +01:00
},{types:["main_frame"],urls:getIPLoggerPatterns()},["blocking"])
2018-08-22 19:09:23 +02:00
function getIPLoggerPatterns()
{
let patterns=[],
2018-07-03 23:52:38 +02:00
//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
2018-08-22 19:09:23 +02:00
# Cyberhub (formerly SkypeGrab)
2018-07-03 23:52:38 +02:00
2018-08-22 19:09:23 +02:00
ġ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
2018-07-03 23:52:38 +02:00
# 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)
2018-07-03 10:18:59 +02:00
{
2018-07-03 23:52:38 +02:00
let line=lines[i].trim();
if(line&&line.substr(0,1)!="#")
{
if(line.substr(0,4)=="www.")
line=line.substr(4)
2018-08-22 19:09:23 +02:00
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+"/*")
2018-07-03 23:52:38 +02:00
}
2018-07-03 10:18:59 +02:00
}
2018-08-22 19:09:23 +02:00
return patterns
2018-07-03 23:52:38 +02:00
}