Universal-Bypass/content_script.js
2019-12-20 14:32:55 +01:00

117 lines
4.2 KiB
JavaScript

//If you want to add your own bypass, go to injection_script.js
if(document instanceof HTMLDocument)
{
let clipboardIndex=location.hash.indexOf("#bypassClipboard="),ignoreCrowdBypass=false,bypassClipboard=""
if(location.hash.substr(-18)=="#ignoreCrowdBypass")
{
ignoreCrowdBypass=true
location.hash=location.hash.substr(0,location.hash.length-18)
}
if(clipboardIndex!=-1)
{
bypassClipboard=location.hash.substr(clipboardIndex+17)
location.hash=location.hash.substr(0,location.hash.length-bypassClipboard.length-17)
}
if(location.hash.substr(-18)=="#ignoreCrowdBypass")
{
ignoreCrowdBypass=true
location.hash=location.hash.substr(0,location.hash.length-18)
}
const brws=(typeof browser=="undefined"?chrome:browser)
brws.runtime.sendMessage({type: "content"}, res => {
if(!res.enabled)
{
return
}
const channel = res.channel,
observer = new MutationObserver(mutations => {
if(document.documentElement.hasAttribute(channel.stop_watching))
{
document.documentElement.removeAttribute(channel.stop_watching)
observer.disconnect()
}
else if(document.documentElement.hasAttribute(channel.crowd_path))
{
crowdPath=document.documentElement.getAttribute(channel.crowd_path)
document.documentElement.removeAttribute(channel.crowd_path)
}
else if(document.documentElement.hasAttribute(channel.crowd_query))
{
document.documentElement.removeAttribute(channel.crowd_query)
let xhr=new XMLHttpRequest()
xhr.onreadystatechange=()=>{
if(xhr.readyState==4)
{
if(xhr.status==200&&xhr.responseText!="")
{
location.assign("https://universal-bypass.org/crowd-bypassed?target="+encodeURIComponent(xhr.responseText)+"&referer="+encodeURIComponent(!bypassClipboard||["linegee.net", "sweetlantern.com", "intercelestial.com"].indexOf(domain)<0?location.href:"https://pahe.in/?dd1fa7bc42="+bypassClipboard))
//The background script will intercept the request and redirect to html/crowd-bypassed.html
}
else
{
document.documentElement.setAttribute(channel.crowd_queried,"")
}
}
}
xhr.open("POST","https://universal-bypass.org/crowd/query_v1",true)
xhr.setRequestHeader("Content-Type","application/x-www-form-urlencoded")
xhr.send("domain="+encodeURIComponent(domain)+"&path="+encodeURIComponent(crowdPath))
}
else if(document.documentElement.hasAttribute(channel.crowd_contribute))
{
const target=document.documentElement.getAttribute(channel.crowd_contribute)
document.documentElement.removeAttribute(channel.crowd_contribute)
brws.runtime.sendMessage({
type: "crowd-contribute",
data: "domain="+encodeURIComponent(domain)+"&path="+encodeURIComponent(crowdPath)+"&target="+encodeURIComponent(target)
})
}
else if(document.documentElement.hasAttribute(channel.adlinkfly_info))
{
document.documentElement.removeAttribute(channel.adlinkfly_info)
if(crowdPath==location.pathname.substr(1))
{
let port=brws.runtime.connect({name: "adlinkfly-info"})
port.onMessage.addListener(msg => {
document.documentElement.setAttribute(channel.adlinkfly_target, msg)
port.disconnect()
})
port.postMessage(location.href)
}
else
{
document.documentElement.setAttribute(channel.adlinkfly_target, "")
}
}
})
observer.observe(document.documentElement, {attributes: true})
let domain=location.hostname,
crowdPath=location.pathname.substr(1)
if(domain.substr(0,4)=="www.")
{
domain=domain.substr(4)
}
if(domain=="api.rurafs.me")
{
return
}
let script=document.createElement("script")
script.innerHTML=`(()=>{
const crowdEnabled=`+(res.crowdEnabled?"true":"false")+`,
infoBoxEnabled=`+(res.infoBoxEnabled?"true":"false")+`,
ignoreCrowdBypass=`+(ignoreCrowdBypass?"true":"false")+`,
bypassClipboard="`+bypassClipboard.split("\\").join("\\\\").split("\"").join("\\\"")+`"
if(location.href=="https://universal-bypass.org/firstrun")
{
location.replace("https://universal-bypass.org/firstrun?1")
return
}
`+res.injectionScript+`
})()`
script=document.documentElement.appendChild(script)
setTimeout(()=>document.documentElement.removeChild(script),10)
})
}