Universal-Bypass/background.js

970 lines
27 KiB
JavaScript
Raw Normal View History

2019-04-25 18:30:47 +02:00
const brws=(typeof browser=="undefined"?chrome:browser),
firefox=(brws.runtime.getURL("").substr(0,4)=="moz-"),
getRedirect=(url,referer,safe_in)=>{
if(!isGoodLink(url))
{
return
}
let redirectUrl=brws.runtime.getURL("html/before-navigate.html")+"?target="+encodeURIComponent(url)
if(referer)
{
redirectUrl+="&referer="+referer
}
if(safe_in!==undefined)
{
redirectUrl+="&safe_in="+safe_in
2019-10-01 12:59:27 +02:00
}
countIt()
return {redirectUrl}
2019-10-01 12:59:27 +02:00
},
encodedRedirect=(url,referer,safe_in)=>getRedirect(decodeURIComponent(url),referer,safe_in),
2019-03-09 12:47:57 +01:00
isGoodLink=link=>{
2020-02-10 08:18:48 +01:00
if(!link||link.substr(0,6)=="about:"||link.substr(0,11)=="javascript:")//jshint ignore:line
2019-03-09 12:47:57 +01:00
{
return false
}
try
{
new URL(link)
}
catch(e)
{
return false
}
return true
},
countIt=()=>brws.storage.local.set({bypass_counter:++bypassCounter})
2019-04-28 19:06:13 +02:00
// Install handler
2019-04-28 19:06:13 +02:00
brws.runtime.onInstalled.addListener(details=>{
if(details.reason=="install")
{
brws.tabs.create({url:"https://universal-bypass.org/firstrun"})
2019-04-28 19:06:13 +02:00
}
})
// Keeping track of options
var bypassCounter=0,enabled=true,instantNavigation=true,trackerBypassEnabled=true,instantNavigationTrackers=false,blockIPLoggers=true,crowdEnabled=true,userScript=""
brws.storage.sync.get(["disable","navigation_delay","no_tracker_bypass","no_instant_navigation_trackers","allow_ip_loggers","crowd_bypass_opt_out","crowd_open_delay","crowd_close_delay","no_info_box"],res=>{
2019-01-11 19:28:26 +01:00
if(res)
{
enabled=(!res.disable||res.disable!=="true")
2019-05-05 08:57:03 +02:00
if(!enabled)
{
brws.browserAction.setIcon({path: {
"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(res.navigation_delay)
{
instantNavigation=(res.navigation_delay==0)
if(res.navigation_delay==61)
{
brws.storage.sync.set({navigation_delay:-11})
}
}
else
{
brws.storage.sync.set({navigation_delay:0})
}
trackerBypassEnabled=(res.no_tracker_bypass!=="true")
instantNavigationTrackers=(res.no_instant_navigation_trackers!=="true")
blockIPLoggers=(res.allow_ip_loggers!=="true")
crowdEnabled=(res.crowd_bypass_opt_out!=="true")
if(!res.crowd_open_delay||res.crowd_open_delay==61)
{
brws.storage.sync.set({crowd_open_delay:-11})
}
if(!res.crowd_close_delay||res.crowd_close_delay==61)
{
brws.storage.sync.set({crowd_close_delay:-11})
}
if(res.no_info_box)
{
brws.storage.sync.remove(["no_info_box"])
}
2019-01-11 19:28:26 +01:00
}
})
brws.storage.local.get(["userscript","bypass_counter"],res=>{
if(res)
2019-01-11 19:28:26 +01:00
{
if(res.userscript)
{
userScript=res.userscript
refreshInjectionScript()
}
if(res.bypass_counter)
{
bypassCounter=res.bypass_counter
}
2019-01-11 19:28:26 +01:00
}
})
brws.storage.onChanged.addListener(changes=>{
if(changes.disable)
{
enabled=(changes.disable.newValue!=="true")
2019-05-05 08:57:03 +02:00
if(enabled)
{
brws.browserAction.setIcon({path: {
"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: {
"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"
}})
}
2019-01-11 19:28:26 +01:00
}
if(changes.navigation_delay)
2019-04-28 19:06:13 +02:00
{
instantNavigation=(changes.navigation_delay.newValue==0)
2019-04-28 19:06:13 +02:00
}
if(changes.no_tracker_bypass)
2019-01-11 19:28:26 +01:00
{
trackerBypassEnabled=(changes.no_tracker_bypass.newValue!=="true")
2019-01-11 19:28:26 +01:00
}
2019-04-28 19:06:13 +02:00
if(changes.no_instant_navigation_trackers)
2019-01-11 19:28:26 +01:00
{
2019-04-28 19:06:13 +02:00
instantNavigationTrackers=(changes.no_instant_navigation_trackers.newValue!=="true")
2019-01-11 19:28:26 +01:00
}
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-01-11 19:28:26 +01:00
}
refreshInjectionScript()
2019-01-11 19:28:26 +01:00
})
2019-04-13 09:11:13 +02:00
// Bypass definition management
let injectionScript = "", upstreamInjectionScript = "", upstreamCommit, channel = {}
const downloadInjectionScript = () => new Promise(callback => {
const finishDownload = () => {
channel = {}
2020-02-10 13:18:56 +01:00
let uniqueness = []
;["stop_watching","crowd_referer","crowd_path","crowd_query","crowd_queried","crowd_contribute","adlinkfly_info","adlinkfly_target"].forEach(name => {
2020-02-10 13:18:56 +01:00
let val
do
{
val = Math.random().toString().substr(2)
}
while(uniqueness.indexOf(val) != -1);
uniqueness.push(val)
upstreamInjectionScript = upstreamInjectionScript.split("{{channel."+name+"}}").join(channel[name] = "data-" + val)
})
;["crowdWait","crowdDisabled"].forEach(name => {
upstreamInjectionScript = upstreamInjectionScript.split("{{msg."+name+"}}").join(brws.i18n.getMessage(name).split("\\").join("\\\\").split("\"").join("\\\""))
})
upstreamInjectionScript = upstreamInjectionScript.split("{{icon/48.png}}").join(brws.runtime.getURL("icon/48.png"))
refreshInjectionScript()
callback(true)
}
let xhr = new XMLHttpRequest()
xhr.onload = () => {
upstreamInjectionScript = xhr.responseText
xhr = new XMLHttpRequest()
xhr.open("GET", brws.runtime.getURL("rules.json"), true)
xhr.onload = () => {
preflightRules = JSON.parse(xhr.responseText)
finishDownload()
}
xhr.send()
}
xhr.onerror = () => {
let xhr = new XMLHttpRequest()
xhr.onload = () => {
const latestCommit = JSON.parse(xhr.responseText).sha
if(latestCommit == upstreamCommit)
{
callback(false)
}
else
{
upstreamCommit = latestCommit
let downloads = 0
xhr = new XMLHttpRequest()
xhr.onload = () => {
upstreamInjectionScript = xhr.responseText
if(++downloads == 2)
{
finishDownload()
}
}
xhr.open("GET", "https://raw.githubusercontent.com/timmyRS/Universal-Bypass/" + upstreamCommit + "/injection_script.js", true)
xhr.send()
let xhr2 = new XMLHttpRequest()
xhr2.onload = () => {
preflightRules = JSON.parse(xhr2.responseText)
if(++downloads == 2)
{
finishDownload()
}
}
xhr2.open("GET", "https://raw.githubusercontent.com/timmyRS/Universal-Bypass/" + upstreamCommit + "/rules.json", true)
xhr2.send()
}
}
xhr.open("GET", "https://api.github.com/repos/timmyRS/Universal-Bypass/commits/master", true)
xhr.send()
}
xhr.open("GET", brws.runtime.getURL("injection_script.js"), true)
xhr.send()
}),
refreshInjectionScript = () => {
Object.values(onBeforeRequest_rules).forEach(brws.webRequest.onBeforeRequest.removeListener)
Object.values(onHeadersReceived_rules).forEach(brws.webRequest.onHeadersReceived.removeListener)
if(enabled)
{
injectionScript = (upstreamInjectionScript + "\n" + userScript)
.split("UNIVERSAL_BYPASS_INTERNAL_VERSION").join("5")
.split("UNIVERSAL_BYPASS_EXTERNAL_VERSION").join(brws.runtime.getManifest().version)
.split("UNIVERSAL_BYPASS_INJECTION_VERSION").join(upstreamCommit?upstreamCommit.substr(0,7):"dev")
Object.keys(preflightRules).forEach(name=>{
if(name in onBeforeRequest_rules)
{
brws.webRequest.onBeforeRequest.addListener(onBeforeRequest_rules[name],{types:["main_frame"],urls:preflightRules[name]},["blocking"])
}
else if(name in onHeadersReceived_rules)
{
brws.webRequest.onHeadersReceived.addListener(onHeadersReceived_rules[name],{types:["main_frame"],urls:preflightRules[name]},["blocking","responseHeaders"])
}
})
}
}
downloadInjectionScript()
brws.alarms.create("update-injection-script", {periodInMinutes: 60})
brws.alarms.onAlarm.addListener(alert => {
console.assert(alert.name == "update-injection-script")
downloadInjectionScript()
})
// Messaging
2019-04-02 12:13:14 +02:00
brws.runtime.onMessage.addListener((req, sender, respond) => {
switch(req.type)
{
case "content":
respond({enabled, channel, crowdEnabled, injectionScript})
break;
case "options":
respond({upstreamCommit, bypassCounter, userScript})
break;
case "open-tab":
brws.tabs.create({
url: req.url
})
break;
2019-04-02 12:13:14 +02:00
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-05-12 07:47:26 +02:00
else
{
console.warn("Unexpected message:", req)
}
break;
2019-04-10 19:47:18 +02:00
2019-04-13 09:11:13 +02:00
default:
console.warn("Invalid message:", req)
}
})
brws.runtime.onConnect.addListener(port => {
switch(port.name)
{
case "update":
downloadInjectionScript().then(success => port.postMessage({success, upstreamCommit}))
break;
case "crowd-query":
port.onMessage.addListener(msg=>{
let xhr=new XMLHttpRequest()
xhr.onreadystatechange=()=>{
if(xhr.readyState==4)
{
port.postMessage(xhr.status==200&&xhr.responseText!=""?xhr.responseText:"")
}
}
xhr.open("POST","https://universal-bypass.org/crowd/query_v1",true)
xhr.setRequestHeader("Content-Type","application/x-www-form-urlencoded")
xhr.send("domain="+encodeURIComponent(msg.domain)+"&path="+encodeURIComponent(msg.crowdPath))
})
break;
case "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)
2019-04-02 12:13:14 +02:00
{
let url=new URL(i.src)
if(url.search&&url.search.indexOf("url="))
{
t=decodeURIComponent(url.search.split("url=")[1].split("&")[0])
}
2019-04-02 12:13:14 +02:00
}
port.postMessage(t)
2019-04-02 12:13:14 +02:00
}
xhr.onerror=()=>port.postMessage(t)
if(iu.substr(-1) != "/")
{
iu += "/"
}
xhr.open("GET", iu+"info", true)
xhr.send()
})
break;
default:
console.warn("Invalid connection:", port)
}
2019-01-17 16:04:45 +01:00
})
2019-01-11 19:28:26 +01:00
// Internal redirects to extension URLs to bypass content script limitations
2019-01-11 23:23:44 +01:00
brws.webRequest.onBeforeRequest.addListener(details=>{
2020-02-08 07:18:23 +01:00
return {redirectUrl:brws.runtime.getURL("html/noscript.html")}
},{types:["main_frame"],urls:["*://universal-bypass.org/firstrun?0"]},["blocking"])
brws.webRequest.onBeforeRequest.addListener(details=>{
return {redirectUrl:brws.runtime.getURL("html/options.html#firstrun")}
},{types:["main_frame"],urls:["*://universal-bypass.org/firstrun?1"]},["blocking"])
brws.webRequest.onBeforeRequest.addListener(details=>{
let arr=details.url.substr(45).split("&referer="),url=arr[0],safe_in
arr=arr[1].split("&safe_in=")
if(arr.length>1)
{
safe_in=arr[1]
}
return encodedRedirect(url,arr[0],safe_in)
},{types:["main_frame"],urls:["*://universal-bypass.org/bypassed?target=*&referer=*"]},["blocking"])
brws.webRequest.onBeforeRequest.addListener(details=>{
countIt()
return {redirectUrl:brws.runtime.getURL("html/crowd-bypassed.html")+details.url.substr(43)}
},{types:["main_frame"],urls:["https://universal-bypass.org/crowd-bypassed?*"]},["blocking"])
brws.webRequest.onBeforeRequest.addListener(details=>{
return {redirectUrl:brws.runtime.getURL("html/options.html")+details.url.substr(36)}
},{types:["main_frame"],urls:["https://universal-bypass.org/options"]},["blocking"])
// Navigation handling including presenting referer header to destinations
var refererCache={}
2019-11-12 21:52:31 +01:00
brws.webRequest.onBeforeRequest.addListener(details=>{
let arr=details.url.substr(45).split("&referer=")
arr[0]=(new URL(decodeURIComponent(arr[0]))).toString()
if(arr.length>1)
{
2019-11-12 21:52:31 +01:00
refererCache[arr[0]]=arr[1]
}
2019-11-12 21:52:31 +01:00
return {redirectUrl:arr[0]}
},{types:["main_frame"],urls:["*://universal-bypass.org/navigate?target=*"]},["blocking"])
let infoSpec=["blocking","requestHeaders"]
if(!firefox)
{
infoSpec.push("extraHeaders")
}
brws.webRequest.onBeforeSendHeaders.addListener(details=>{
if(enabled&&details.url in refererCache)
{
details.requestHeaders.push({
name: "Referer",
2019-10-02 15:46:54 +02:00
value: decodeURIComponent(refererCache[details.url])
})
return {requestHeaders: details.requestHeaders}
}
},{types:["main_frame"],urls:["<all_urls>"]},infoSpec)
2019-11-12 21:52:31 +01:00
brws.webRequest.onBeforeRedirect.addListener(details=>{
if(enabled&&details.url in refererCache)
{
2019-11-12 21:52:31 +01:00
if(details.redirectUrl == details.url + "/")
{
refererCache[details.redirectUrl] = refererCache[details.url]
}
delete refererCache[details.url]
}
2019-11-12 21:52:31 +01:00
},{types:["main_frame"],urls:["<all_urls>"]})
brws.webRequest.onCompleted.addListener(details=>{
if(enabled&&details.url in refererCache)
{
delete refererCache[details.url]
}
},{types:["main_frame"],urls:["<all_urls>"]})
// Preflight Bypasses
const onBeforeRequest_rules = {
path_base64: details => getRedirect(atob(details.url.substr(details.url.indexOf("aHR0c")))),
path_s_encoded: details => encodedRedirect(details.url.substr(details.url.indexOf("/s/")+3)),
path_dl_base64: details => getRedirect(atob(details.url.substr(details.url.indexOf("/dl/")+4))),
query_raw: details => {
let url=new URL(details.url)
if(url.search)
{
return getRedirect(url.search.substr(1)+url.hash)
}
},
query_base64: details => getRedirect(atob((new URL(details.url)).search.replace("?",""))),
hash_base64: details => {
let url=new URL(details.url)
if(url.hash)
{
return getRedirect(atob(url.hash.replace("#","")))
}
},
param_url_general: details => {
let url=details.url.substr(details.url.indexOf("&url=")+5)
if(url.substr(0,5)=="aHR0c")
{
2019-12-21 18:54:19 +07:00
url=atob(url.split("&")[0])
}
else if(url.substr(0,13)=="http%3A%2F%2F"||url.substr(0,14)=="https%3A%2F%2F")
{
2019-12-21 18:54:19 +07:00
url=decodeURIComponent(url.split("&")[0])
}
else
{
if(url.substr(0,7)!="http://"&&url.substr(0,8)!="https://")
{
url="http://"+url
}
url+=(new URL(details.url)).hash
}
return getRedirect(url)
},
param_url_encoded: details => {
2019-02-03 20:04:53 +01:00
let url=new URL(details.url)
if(url.searchParams.has("url"))
{
return getRedirect(url.searchParams.get("url"))
}
},
param_xurl_raw_http: details => getRedirect("http"+details.url.substr(details.url.indexOf("?xurl=")+6)),
param_aurl_encoded: details => {
let url=new URL(details.url)
if(url.searchParams.has("aurl"))
{
return getRedirect(url.searchParams.get("aurl"))
}
},
param_capital_url_encoded: details => {
2019-11-23 03:35:51 +01:00
let url=new URL(details.url)
if(url.searchParams.has("URL"))
{
return getRedirect(url.searchParams.get("URL"))
}
},
param_rel_base64: details => getRedirect(atob(details.url.substr(details.url.indexOf("?rel=")+5))),
param_link_encoded: details => encodedRedirect(details.url.substr(details.url.indexOf("link=")+5)),
param_link_base64: details => getRedirect(atob(details.url.substr(details.url.indexOf("?link=")+6))),
param_link_encoded_base64: details => getRedirect(decodeURIComponent(atob(details.url.substr(details.url.indexOf("?link=")+6)))),
param_kesehatan_base64: details => getRedirect(atob(details.url.substr(details.url.indexOf("?kesehatan=")+11))),
param_wildcard_base64: details => getRedirect(atob(new URL(details.url).searchParams.values().next().value)),
param_r_base64: details => getRedirect(atob(details.url.substr(details.url.indexOf("?r=")+3))),
param_kareeI_base64_pipes: details => getRedirect(atob(details.url.substr(details.url.indexOf("?kareeI=")+8)).split("||")[0]),
param_cr_base64: details => {
2019-09-23 16:00:12 +02:00
let i=details.url.indexOf("cr=")
if(i>0)
{
2019-09-26 20:52:59 +02:00
return getRedirect(atob(details.url.substr(i+3).split("&")[0]))
2019-09-23 16:00:12 +02:00
}
},
param_a_base64: details => getRedirect(atob(details.url.substr(details.url.indexOf("?a=")+3).split("#",1)[0])),
param_url_base64: details => getRedirect(atob(details.url.substr(details.url.indexOf("?url=")+5))),
param_id_base64: details => getRedirect(atob(details.url.substr(details.url.indexOf("?id=")+4))),
param_get_base64: details => {
let arg=details.url.substr(details.url.indexOf("?get=")+5)
return getRedirect(atob(arg.substr(0,arg.length-1)))
},
param_u_base64: details => {
let url=new URL(details.url)
if(url.searchParams.has("u"))
{
return getRedirect(atob(url.searchParams.get("u"))+url.hash)
}
},
param_go_base64: details => {
2019-10-28 18:16:25 +01:00
let b64=details.url.substr(details.url.indexOf("?go=")+4).split("&")[0]
if(b64.substr(0,5)=="0OoL1")
{
b64="aHR0c"+b64.substr(5)
}
return getRedirect(atob(b64))
},
param_site_base64: details => getRedirect(atob(details.url.substr(details.url.indexOf("?site=")+6).split("&")[0])),
param_reff_base64: details => getRedirect(atob(details.url.substr(details.url.indexOf("?reff=")+6))),
param_s_encoded: details => encodedRedirect(details.url.substr(details.url.indexOf("?s=")+3),details.url),
param_dl_encoded_base64: details => encodedRedirect(atob(details.url.substr(details.url.indexOf("?dl=")+4).split("&")[0])),
param_health_encoded_base64: details => encodedRedirect(atob(details.url.substr(details.url.indexOf("?health=")+8))),
param_id_reverse_base64: details => {
2019-04-19 06:57:57 +02:00
let url=new URL(details.url)
if(url.searchParams.has("id"))
{
2019-09-22 15:47:42 +02:00
let t=atob(url.searchParams.get("id").split("").reverse().join(""))
if(t.substr(-16)=='" target="_blank')
2019-09-22 15:47:42 +02:00
{
t=t.substr(0,t.length-16)
}
return getRedirect(t)
2019-04-19 06:57:57 +02:00
}
},
param_token_base64: details => {
let url=new URL(details.url)
if(url.searchParams.has("token"))
{
return getRedirect(atob(url.searchParams.get("token")))
}
},
param_href_encoded: details => {
let url=new URL(details.url)
if(url.searchParams.has("href"))
{
return getRedirect(url.searchParams.get("href"))
}
},
param_short_encoded: details => {
2019-08-29 05:09:23 +02:00
let url=new URL(details.url)
if(url.searchParams.has("short"))
{
return getRedirect(url.searchParams.get("short"))
}
},
param_id_base64_replacements: details => {
2019-05-15 11:02:19 +02:00
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"))
}
},
param_dest_encoded: details => {
let url=new URL(details.url)
if(url.searchParams.has("dest"))
{
return getRedirect(url.searchParams.get("dest"))
}
2019-05-15 11:02:19 +02:00
}
},
onHeadersReceived_rules = {
redirect_to_post: details => {
let url = new URL(details.url)
if(url.pathname.substr(0,6)!="/post/")
{
for(let i in details.responseHeaders)
{
let header = details.responseHeaders[i]
if(header.name.toLowerCase() == "location")
{
details.responseHeaders[i].value += "#" + url.pathname.substr(1)
break
}
}
}
return {responseHeaders: details.responseHeaders}
},
redirect_path_single_letter: details => {
let url = new URL(details.url)
for(let i in details.responseHeaders)
{
let header = details.responseHeaders[i]
if(header.name.toLowerCase() == "location")
{
details.responseHeaders[i].value += "#" + url.pathname.substr(3).split("/")[0]
break
}
}
return {responseHeaders: details.responseHeaders}
},
contribute_hash: details => {
if(crowdEnabled&&details.method=="POST")
{
let url=new URL(details.url)
if(url.hash.length>1)
{
for(let i in details.responseHeaders)
{
let header=details.responseHeaders[i]
if(header.name.toLowerCase()=="location"&&isGoodLink(header.value))
{
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="+url.host+"&path="+encodeURIComponent(url.hash.substr(1))+"&target="+encodeURIComponent(header.value))
break
}
}
}
}
}
}
2019-05-15 11:02:19 +02:00
// Very Specific Preflight Bypasses
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"])
2019-09-01 12:41:03 +02:00
brws.webRequest.onBeforeRequest.addListener(details=>{
if(enabled)
{
return getRedirect(details.url.substr(details.url.substr(16).indexOf("/")+17))
}
},{types:["main_frame"],urls:["http://sh.st/st/*/*"]},["blocking"])
brws.webRequest.onBeforeRequest.addListener(details=>{
if(enabled)
{
let url=details.url
do
2019-09-01 12:41:03 +02:00
{
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)
{
return getRedirect(url)
2019-09-01 12:41:03 +02:00
}
}
},{types:["main_frame"],urls:["http://gslink.co/a/*"]},["blocking"])
2019-09-01 12:41:03 +02:00
2019-06-11 21:11:08 +02:00
brws.webRequest.onBeforeRequest.addListener(details=>{
if(enabled)
{
let url=new URL(details.url)
if(url.searchParams.has("go"))
2019-06-11 21:11:08 +02:00
{
return getRedirect("https://clickar.net/"+url.searchParams.get("go"))
2019-06-11 21:11:08 +02:00
}
}
},{types:["main_frame"],urls:["*://*.surfsees.com/?*"]},["blocking"])
2019-06-11 21:11:08 +02:00
// Ouo.io/press & lnk2.cc Crowd Bypass
2019-03-09 12:47:57 +01:00
brws.webRequest.onHeadersReceived.addListener(details=>{
if(enabled&&crowdEnabled)
2019-03-09 12:47:57 +01:00
{
let url=new URL(details.url)
2019-03-09 12:47:57 +01:00
for(let i in details.responseHeaders)
{
let header=details.responseHeaders[i]
if(header.name.toLowerCase()=="location"&&isGoodLink(header.value))
2019-03-09 12:47:57 +01:00
{
let xhr=new XMLHttpRequest(),
domain=url.hostname
if(domain=="ouo.press")
{
domain="ouo.io"
}
xhr.open("POST","https://universal-bypass.org/crowd/contribute_v1",true)
xhr.setRequestHeader("Content-Type","application/x-www-form-urlencoded")
xhr.send("domain="+domain+"&path="+encodeURIComponent(url.pathname.split("/")[2])+"&target="+encodeURIComponent(header.value))
2019-03-09 12:47:57 +01:00
break
}
}
}
},{types:["main_frame"],urls:[
"*://*.ouo.io/*/*",
2019-10-23 02:02:19 +07:00
"*://*.ouo.press/*/*",
"*://*.lnk2.cc/*/*"
2019-03-09 12:47:57 +01:00
]},["blocking","responseHeaders"])
// SoraLink Crowd Bypass
let soralink_contribute={}
brws.webRequest.onBeforeRequest.addListener(details=>{
2019-11-25 18:57:56 +07:00
if(enabled&&crowdEnabled)
{
const arg_index=details.url.indexOf("&soralink_contribute="),url=details.url.substr(0,arg_index)
soralink_contribute[url]=details.url.substr(arg_index+21)
return{redirectUrl:url}
}
},{types:["main_frame"],urls:["*://*/?*=*&soralink_contribute=*"]},["blocking"])
brws.webRequest.onHeadersReceived.addListener(details=>{
if(enabled)
{
if(crowdEnabled && details.url in soralink_contribute)
2019-11-25 18:57:56 +07:00
{
if(details.method=="POST")
2019-11-25 18:57:56 +07:00
{
for(let i in details.responseHeaders)
{
let header=details.responseHeaders[i]
if(header.name.toLowerCase()=="location"&&isGoodLink(header.value))
{
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="+(new URL(details.url)).host+"&path="+encodeURIComponent(soralink_contribute[details.url])+"&target="+encodeURIComponent(header.value))
break
}
}
2019-11-25 18:57:56 +07:00
}
delete soralink_contribute[details.url]
2019-11-25 18:57:56 +07:00
}
if(firefox)//Fixing Content-Security-Policy on Firefox because apparently extensions have no special privileges there
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
}
else
2019-01-04 21:17:38 +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)
{
2019-05-12 07:47:26 +02:00
value+=name
2018-11-09 15:00:05 +01:00
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
}
}
},{types:["main_frame"],urls:["<all_urls>"]},["blocking","responseHeaders"])
2018-10-02 19:31:00 +02:00
// Tracker Bypass using Apimon.de
2018-12-30 12:25:26 +01:00
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)
2019-10-31 01:43:40 +01:00
{
2019-04-13 09:11:13 +02:00
destination=json.destination
2019-10-31 01:43:40 +01:00
}
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-04-28 13:10:49 +02:00
if(trackerBypassEnabled&&new URL(details.url).pathname!="/")
2019-01-11 19:28:26 +01:00
{
2019-04-28 13:10:49 +02:00
let destination=resolveRedirect(details.url)
if(destination&&destination!=details.url)
2019-01-17 02:58:06 +01:00
{
return getRedirect(destination,"tracker")
2019-01-17 02:58:06 +01:00
}
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-04-28 13:10:49 +02: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-04-28 13:10:49 +02:00
let destination=resolveRedirect(details.url)
if(destination&&destination!=details.url)
2019-01-11 19:28:26 +01:00
{
return getRedirect(destination,"tracker")
2019-01-11 19:28:26 +01:00
}
}
if(blockIPLoggers)
{
2019-04-28 13:10:49 +02: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
{
2019-05-12 07:47:26 +02:00
let line=lines[i].trim()
2018-07-03 23:52:38 +02:00
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
}