-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathutils.js
executable file
·165 lines (151 loc) · 7.37 KB
/
utils.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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
// sets logging level
var VERBOSE = false
if (typeof NON_ENGLISH_LOCALE === 'undefined') {
var NON_ENGLISH_LOCALE = false
}
// return whether the container is already covered
function alreadyCovered(container) {
return (container.find(".KAB_adBlockerCover").length > 0)
}
// true if we want to overlay non-ads as well
var showNonAd = false;
// return whether the container is already covered by the same type
// of container. That is, if there is already an ad or non-ad container
// we don't want to ad a container of a new type, but if an adchoices
// icon has been added and it changed from non-ad to ad, we do want
// to update.
function alreadyCoveredSameType(container, newCoverIsAd) {
var alreadyCovered = (container.find(".KAB_adBlockerCover").length > 0)
var alreadyAd = (container.find(".KAB_isAnAd").length > 0)
return alreadyCovered && (alreadyAd || !newCoverIsAd)
}
// Add a cover with "THIS IS AN AD" and the "Sponsored" text in the given
// locale's language (if non-english).
// container is the container to cover.
// coverText is the text to show on the cover
// matchingText only has a value if we are on Facebook in a non-english locale.
// deepestOnly is true if we only want to include the deepest cover for this
// area.
// isAd is true if it is an ad
// hasInterval is true if there is an interval check associated with this cover
// intervalID is the id of that interval
function coverContainer(container, coverText, matchingText, deepestOnly, isAd, hasInterval, intervalID) {
// if we aren't doing anything to non-ads and this isn't an ad, do nothing.
if (!isAd && !showNonAd) {
return false
}
// don't cover if this container is already covered;
if (alreadyCoveredSameType(container, false)) {
return false
}
// remove any existing covers (if we are moving from non-ad to ad)
container.find(".KAB_adBlockerCover").remove()
// vary the color and classes based on whether this is an ad or not.
var color
var classes = "KAB_adBlockerCover"
if (isAd) {
if (showNonAd) {
color = "rgba(255, 0, 0, 0.8)"
} else {
color = "rgba(255, 255, 255, 0.8)"
}
classes += " KAB_isAnAd"
} else {
color = "rgba(255, 255, 255, 0.8)"
}
// some google ads have a height of 0 and then everything in overflow,
// so if that is the case set the height of the cover to be the overflow
// height.
var setHeight
var containerHeight = container.height()
var containerScrollHeight = container.prop('scrollHeight')
if (containerHeight == 0 && containerScrollHeight > 0) {
setHeight = containerScrollHeight + "px"
} else {
setHeight = "100%"
}
//Kemono images
var imageSrcs = [
"https://pbs.twimg.com/media/C46fOL7VcAAM4H-.jpg",
"https://pbs.twimg.com/media/C5cdRXyUoAEQ8HK.jpg",
"https://pbs.twimg.com/media/C7rkymbVwAAE11F.jpg",
"https://pbs.twimg.com/media/C7HmZy4VAAETPGR.jpg",
"https://pbs.twimg.com/media/C7Hmew-UwAEOBox.jpg",
"https://pbs.twimg.com/media/C6ispvmVwAAKLvZ.jpg",
"https://pbs.twimg.com/media/C6issRcV0AIXjll.jpg",
"https://pbs.twimg.com/media/C5-jiooUsAAmOJy.jpg",
"https://pbs.twimg.com/media/C5-jlo2UYAAIVcT.jpg",
"https://pbs.twimg.com/media/C5atYAoUwAAoEBz.jpg",
"https://pbs.twimg.com/media/C5atflpUYAADBbS.jpg",
"https://pbs.twimg.com/media/C5atg0BUoAA_zNu.jpg",
"https://pbs.twimg.com/media/C42iwUAUoAAY8HV.jpg",
"https://pbs.twimg.com/media/C42iyZtUcAAof4R.jpg",
"https://pbs.twimg.com/media/C42i0tqUEAEOffq.jpg",
"https://pbs.twimg.com/media/C4nf2a-VcAMGy-3.jpg",
"https://pbs.twimg.com/media/C3t7WvCVcAAsBoo.jpg",
"https://pbs.twimg.com/media/C3t7a5LVYAAl2Kd.jpg",
"https://pbs.twimg.com/media/C3KH9iQVMAIIgda.jpg",
"https://pbs.twimg.com/media/C2h5KX4UcAID-Fe.jpg",
"https://pbs.twimg.com/media/C2h5WoJUcAA-qF_.jpg",
"https://pbs.twimg.com/media/C2h5XxQUQAALHkl.jpg"
];
imgSrc = imageSrcs[Math.floor(Math.random() * imageSrcs.length)]
// create the cover to prepend.
var prepend = "<div class=\"" + classes + "\" style=\"height: " + setHeight + ";position: absolute;width: 100%; color:white; background-color: " + color + " !important; opacity: 0.95; z-index: 100; visibility: visible; display:flex; display:flex; flex-direction:column; justify-content:center; align-items:center; flex-wrap:nowrap; overflow: hidden;\">"
prepend += "<div id=\"KAB_filter\" style=\"position: absolute;height:100%; width:100%; background-image: url(" + imgSrc + "); background-position: center; background-size:cover; background-color:rgba(0,0,0,0.3); display:flex;\">"
prepend += "</div>"
prepend += "<style>#KAB_filter{filter:brightness(0.9);} #KAB_filter:hover{opacity:0.7;filter:blur(7px) brightness(0.4);}</style>"
prepend += "<div class=\"KAB_closeButton\" style=\"position: absolute; right: 5px; top: 5px; cursor: pointer; padding: 0px 3px; border: 1px solid black; border-radius: 5px\">"
prepend += "<strong>"
prepend += "X"
prepend += "</strong>"
prepend += "</div>"
prepend += "<div style=\"position: absolute; width: 100%; text-align:center;\">"
prepend += "<span style=\"font-size:40px; text-shadow: -1px 0 black, 0 1px black, 1px 0 black, 0 -1px black !important;\">"
prepend += "わーい!廣告!"
prepend += "</span>"
prepend += "<br/>"
// if we have "Sponsored" text in another language, add it below "THIS IS AN AD"
if (NON_ENGLISH_LOCALE && matchingText !== "") {
if (matchingText == "贊助") {
prepend += "<br/>"
prepend += "<span style=\"font-size:30px; font-weight:bold; letter-spacing: 30px; text-shadow: -1px 0 black, 0 1px black, 1px 0 black, 0 -1px black !important; \">"
prepend += "提供"
prepend += "</span>"
prepend += "<br/>"
prepend += "<br/>"
prepend += "<span style=\"font-size:30px; text-shadow: -1px 0 black, 0 1px black, 1px 0 black, 0 -1px black !important; \">"
prepend += "Facebook 粉絲專頁贊助"
prepend += "</span>"
} else {
prepend += "<br/>"
prepend += "<span style=\"font-size:40px; letter-spacing: 15px; text-shadow: -1px 0 black, 0 1px black, 1px 0 black, 0 -1px black;\">"
prepend += matchingText
prepend += "</span>"
}
}
prepend += "</div>"
prepend += "</div>"
var myPrepend = prepend
// if we only want the deepest, remove any above this
if (deepestOnly) {
container.parents().each(function(index) {
$(this).children(".KAB_adBlockerCover").remove()
})
}
// if we only want the deepest covers and there is a cover within
// this container already, don't ad this cover.
if (!deepestOnly || !(container.find(".KAB_adBlockerCover").length > 0)) {
// prepend the cover
container.css("position", "relative")
container.prepend(myPrepend)
// make sure the close button closes the cover
container.children().children(".KAB_closeButton").on("click", function() {
container.children(".KAB_adBlockerCover").css("visibility", "hidden")
});
}
// if this is an ad and we have an interval, stop the search for ads.
if (hasInterval && isAd) {
clearInterval(intervalID)
}
}