This commit is contained in:
Tim Speckhals 2019-01-11 23:23:44 +01:00
parent d006fb1ea5
commit a2821dff11
No known key found for this signature in database
GPG Key ID: A62ADB92F7ADEEB6
3 changed files with 77 additions and 83 deletions

View File

@ -1,42 +1,6 @@
var brws=(typeof browser=="undefined"?chrome:browser),platform=brws.runtime.getURL("").split("-")[0]
//Install & Uninstall Actions
brws.runtime.onInstalled.addListener(details=>{
if(details.reason=="install")
{
if(platform=="ms")
{
brws.windows.create({url:"https://universal-bypass.org/firstrun"})
}
else
{
window.open("https://universal-bypass.org/firstrun")
}
}
else
{
//Upgrade configuration
brws.storage.local.get(["custom_bypasses"],result=>{
if(!result||!result.custom_bypasses)
{
return
}
let customBypasses=JSON.parse(result.custom_bypasses),userscript=""
for(let name in customBypasses)
{
userscript += "// " + name + "\ndomainBypass(\"" + customBypasses[name].domains + "\", ()=>{\n" + customBypasses[name].content + "})\n\n"
}
brws.storage.local.set({
userscript: userscript
}, ()=>{
brws.storage.local.remove("custom_bypasses")
})
})
}
})
brws.runtime.setUninstallURL("https://docs.google.com/forms/d/e/1FAIpQLSdXw-Yf5IaDXZWw4fDHroZkDFOF6hgWEvVDaXT9ZADqnF2reg/viewform")
//Tracking options
//Keeping track of options
var enabled=true,instantNavigation=false,trackerBypassEnabled=true,blockIPLoggers=true,crowdEnabled=true,userscript="",
getRedirect=url=>({redirectUrl:(instantNavigation?url:brws.runtime.getURL("html/before-navigate.html")+"?target="+encodeURIComponent(url))})
encodedRedirect=url=>({redirectUrl:(instantNavigation?decodeURIComponent(url):brws.runtime.getURL("html/before-navigate.html")+"?target="+url)})
@ -92,8 +56,27 @@ chrome.runtime.onMessage.addListener((request,sender,sendResponse)=>{
}
});
//Bypasses of sites where the destination is in the request
//Internal redirects to extension URLs to bypass content script limitations
brws.webRequest.onBeforeRequest.addListener(details=>{
if(details.method=="GET"&&details.type=="main_frame")
{
if(details.url.substr(38)=="1")
return{redirectUrl:brws.runtime.getURL("html/firstrun.html")}
return{redirectUrl:brws.runtime.getURL("html/firstrun-noscript.html")}
}
},{urls:["https://universal-bypass.org/firstrun?*"]},["blocking"])
brws.webRequest.onBeforeRequest.addListener(details=>{
if(details.method=="GET"&&details.type=="main_frame")
return encodedRedirect(details.url.substr(52))
},{urls:["https://universal-bypass.org/before-navigate?target=*"]},["blocking"])
brws.webRequest.onBeforeRequest.addListener(details=>{
if(details.method=="GET"&&details.type=="main_frame")
return{redirectUrl:brws.runtime.getURL("html/crowd-bypassed.html")+details.url.substr(43)}
},{urls:["https://universal-bypass.org/crowd-bypassed?*"]},["blocking"])
//Bypasses of sites where the destination is in the request
brws.webRequest.onBeforeRequest.addListener(details=>{
if(enabled&&details.method=="GET"&&details.type=="main_frame")
return encodedRedirect(details.url.substr(details.url.indexOf("url=")+4))
@ -124,25 +107,43 @@ brws.webRequest.onBeforeRequest.addListener(details=>{
return encodedRedirect(details.url.substr(details.url.indexOf("/s/")+3))
},{urls:["*://*.gslink.co/e/*/s/*"]},["blocking"])
//Internal redirects to extension URLs to bypass content script limitations
brws.webRequest.onBeforeRequest.addListener(details=>{
if(details.method=="GET"&&details.type=="main_frame")
//Install & Uninstall Actions
brws.runtime.onInstalled.addListener(details=>{
if(details.reason=="install")
{
if(details.url.substr(38)=="1")
return{redirectUrl:brws.runtime.getURL("html/firstrun.html")}
return{redirectUrl:brws.runtime.getURL("html/firstrun-noscript.html")}
if(platform=="ms"||platform=="moz")
{
brws.windows.create({url:"https://universal-bypass.org/firstrun"})
}
else
{
setTimeout(()=>{
window.open("https://universal-bypass.org/firstrun")
},1000)
}
}
},{urls:["https://universal-bypass.org/firstrun?*"]},["blocking"])
brws.webRequest.onBeforeRequest.addListener(details=>{
if(details.method=="GET"&&details.type=="main_frame")
return encodedRedirect(details.url.substr(52))
},{urls:["https://universal-bypass.org/before-navigate?target=*"]},["blocking"])
brws.webRequest.onBeforeRequest.addListener(details=>{
if(details.method=="GET"&&details.type=="main_frame")
return{redirectUrl:brws.runtime.getURL("html/crowd-bypassed.html")+details.url.substr(43)}
},{urls:["https://universal-bypass.org/crowd-bypassed?*"]},["blocking"])
else
{
//Upgrade configuration
brws.storage.local.get(["custom_bypasses"],result=>{
if(!result||!result.custom_bypasses)
{
return
}
let customBypasses=JSON.parse(result.custom_bypasses),userscript=""
for(let name in customBypasses)
{
userscript += "// " + name + "\ndomainBypass(\"" + customBypasses[name].domains + "\", ()=>{\n" + customBypasses[name].content + "})\n\n"
}
brws.storage.local.set({
userscript: userscript
}, ()=>{
brws.storage.local.remove("custom_bypasses")
})
})
}
})
brws.runtime.setUninstallURL("https://docs.google.com/forms/d/e/1FAIpQLSdXw-Yf5IaDXZWw4fDHroZkDFOF6hgWEvVDaXT9ZADqnF2reg/viewform")
//Fixing Content-Security-Policy on Firefox because apparently extensions have no special privileges in Firefox
if(platform=="moz")

View File

@ -126,27 +126,28 @@ if(document instanceof HTMLDocument)
}
}
},
contributeAndNavigate=target=>ensureCrowdLoaded(()=>{
if(navigated||!isGoodLink(target))
contributeAndNavigate=target=>{
if(!navigated&&isGoodLink(target))
{
return
}
if(!crowdEnabled)
{
unsafelyNavigate(target)
return
}
let xhr=new XMLHttpRequest()
xhr.onreadystatechange=()=>{
if(xhr.readyState==4)
if(crowdEnabled)
{
let xhr=new XMLHttpRequest()
xhr.onreadystatechange=()=>{
if(xhr.readyState==4)
{
unsafelyNavigate(target)
}
}
xhr.open("POST","https://universal-bypass.org/crowd/contribute_v1",true)
xhr.setRequestHeader("Content-Type","application/x-www-form-urlencoded")
xhr.send("domain="+encodeURIComponent(domain)+"&path="+encodeURIComponent(location.pathname.toString().substr(1))+"&target="+encodeURIComponent(target))
}
else
{
unsafelyNavigate(target)
}
}
xhr.open("POST","https://universal-bypass.org/crowd/contribute_v1",true)
xhr.setRequestHeader("Content-Type","application/x-www-form-urlencoded")
xhr.send("domain="+encodeURIComponent(domain)+"&path="+encodeURIComponent(location.pathname.toString().substr(1))+"&target="+encodeURIComponent(target))
}),
},
domain=location.hostname,
crowdEnabled=document.documentElement.hasAttribute("data-universal-bypass-crowd-enabled")
if(crowdEnabled)
@ -257,6 +258,9 @@ if(document instanceof HTMLDocument)
if(location.pathname.length>2&&location.pathname.substr(0,6)!="/goii/")
safelyNavigate("/goii/"+location.pathname.substr(2)+"?ref="+location.hostname+location.pathname)
})
hrefBypass(/universal-bypass\\.org\\/firstrun/,()=>{
location.href="https://universal-bypass.org/firstrun?1"
})
domainBypass("cshort.org",()=>{
ODP(window,"adblock",{
value:false,
@ -423,11 +427,6 @@ if(document instanceof HTMLDocument)
{
return
}
if(location.href=="https://universal-bypass.org/firstrun")
{
location.href="https://universal-bypass.org/firstrun?1"
return
}
ensureDomLoaded(()=>{
domainBypass("adfoc.us",()=>{
let b=document.querySelector(".skip[href]")
@ -1062,12 +1061,6 @@ if(document instanceof HTMLDocument)
script.innerHTML+="\n"+response.userscript+"\n})()"
document.documentElement.setAttribute("data-universal-bypass-crowd-enabled","")
script=document.documentElement.appendChild(script)
if(location.href=="https://universal-bypass.org/firstrun")
{
setTimeout(()=>{
location.href="https://universal-bypass.org/firstrun?"+(document.documentElement.hasAttribute("data-universal-bypass-firstran")?"1":"0")
},500)
}
setTimeout(()=>document.documentElement.removeChild(script),10)
})
}

View File

@ -11,7 +11,7 @@
"name": "Universal Bypass",
"description": "__MSG_appDesc__",
"homepage_url": "https://universal-bypass.org/",
"version": "9.0",
"version": "9.0.1",
"author": "Tim \"timmyRS\" Speckhals",
"incognito": "split",
"options_ui": {