Universal-Bypass/content_script.js

118 lines
4.0 KiB
JavaScript
Raw Normal View History

//If you want to add your own bypass, go to injection_script.js
2018-07-02 12:57:42 +02:00
if(document instanceof HTMLDocument)
2018-03-24 19:30:18 +01:00
{
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)
}
2019-12-06 21:32:50 +01:00
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 => {
2019-01-21 09:40:12 +01:00
if(!res.enabled)
2019-01-11 19:28:26 +01:00
{
2019-01-21 09:40:12 +01:00
return
2019-01-11 19:28:26 +01:00
}
const channel = res.channel,
observer = new MutationObserver(mutations => {
if(document.documentElement.hasAttribute(channel.stop_watching))
2019-02-17 13:15:59 +01:00
{
document.documentElement.removeAttribute(channel.stop_watching)
observer.disconnect()
2019-02-17 13:15:59 +01:00
}
else if(document.documentElement.hasAttribute(channel.crowd_referer))
{
referer=document.documentElement.getAttribute(channel.crowd_referer)
document.documentElement.removeAttribute(channel.crowd_referer)
}
else if(document.documentElement.hasAttribute(channel.crowd_path))
2019-05-30 03:24:31 +02:00
{
crowdPath=document.documentElement.getAttribute(channel.crowd_path)
document.documentElement.removeAttribute(channel.crowd_path)
2019-05-30 03:24:31 +02:00
}
else if(document.documentElement.hasAttribute(channel.crowd_query))
2019-02-17 13:15:59 +01:00
{
document.documentElement.removeAttribute(channel.crowd_query)
let port=brws.runtime.connect({name: "crowd-query"})
port.onMessage.addListener(msg=>{
if(msg=="")
2019-02-17 13:15:59 +01:00
{
document.documentElement.setAttribute(channel.crowd_queried, "")
}
else
{
location.assign("https://universal-bypass.org/crowd-bypassed?target="+encodeURIComponent(msg)+"&referer="+encodeURIComponent(referer))
//The background script will intercept the request and redirect to html/crowd-bypassed.html
2019-05-08 13:40:46 +02:00
}
port.disconnect()
})
port.postMessage({domain, crowdPath})
2019-02-17 13:15:59 +01:00
}
else if(document.documentElement.hasAttribute(channel.crowd_contribute))
2019-02-17 13:15:59 +01:00
{
const target=document.documentElement.getAttribute(channel.crowd_contribute)
document.documentElement.removeAttribute(channel.crowd_contribute)
2019-04-10 19:47:18 +02:00
brws.runtime.sendMessage({
type: "crowd-contribute",
2019-05-30 03:24:31 +02:00
data: "domain="+encodeURIComponent(domain)+"&path="+encodeURIComponent(crowdPath)+"&target="+encodeURIComponent(target)
2019-04-10 19:47:18 +02:00
})
2019-02-17 13:15:59 +01:00
}
else if(document.documentElement.hasAttribute(channel.adlinkfly_info))
2019-01-11 19:28:26 +01:00
{
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, "")
}
2018-10-15 06:55:21 +02:00
}
})
observer.observe(document.documentElement, {attributes: true})
let domain=location.hostname,
crowdPath=location.pathname.substr(1),
referer=location.href
2019-02-17 13:15:59 +01:00
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")+`,
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+`
})()`
2019-03-09 12:47:57 +01:00
script=document.documentElement.appendChild(script)
setTimeout(()=>document.documentElement.removeChild(script),10)
2018-05-28 18:27:15 +02:00
})
2018-03-24 19:30:18 +01:00
}