forked from webtaculars/Universal-Bypass
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontent_script.js
139 lines (137 loc) · 4.77 KB
/
content_script.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
//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 simplifyDomain=domain=>{
if(domain.substr(0,4)=="www.")
{
domain=domain.substr(4)
}
return domain
}
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.count_it))
{
document.documentElement.removeAttribute(channel.count_it)
brws.runtime.sendMessage({type:"count-it"})
}
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_domain))
{
domain=simplifyDomain(document.documentElement.getAttribute(channel.crowd_domain))
document.documentElement.removeAttribute(channel.crowd_domain)
}
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 port=brws.runtime.connect({name: "crowd-query"})
port.onMessage.addListener(msg=>{
if(msg=="")
{
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
}
port.disconnect()
})
port.postMessage({domain, 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, "")
}
}
else if(document.documentElement.hasAttribute(channel.bypass_clipboard))
{
const clipboard=document.documentElement.getAttribute(channel.bypass_clipboard)
document.documentElement.removeAttribute(channel.bypass_clipboard)
brws.runtime.sendMessage({
type: "bypass-clipboard",
data: clipboard
})
}
})
observer.observe(document.documentElement, {attributes: true})
let domain=simplifyDomain(location.hostname),
crowdPath=location.pathname.substr(1),
referer=location.href
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+`
})()`
script=document.documentElement.appendChild(script)
setTimeout(()=>document.documentElement.removeChild(script),10)
})
}