-
Notifications
You must be signed in to change notification settings - Fork 0
/
hiq_reklama_svg.js
246 lines (152 loc) · 7.19 KB
/
hiq_reklama_svg.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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
// ==UserScript==
// @name FB remove ads me SVG
// @namespace example.org
// @version 0.5
// @description FB remove ads me SVG
// @author You
// @match https://www.facebook.com/*
// @grant none
// ==/UserScript==
//make the ads DIV opactity 0.1
var css = '.reklama_me_hover{opacity:0.01; } .reklama_me_hover:hover{ opacity: 1 !important }';
var style = document.createElement('style');
style.appendChild(document.createTextNode(css));
document.getElementsByTagName('head')[0].appendChild(style);
var sa_reklama_jane_hequr = 1;
//show the tooltip when ad is removed
var stili_extra = document.createElement('style')
stili_extra.innerText = '.reklama_tooltip_container, .drink_water_container { text-align: center;position: fixed;z-index: 9999999;font-size: 20px;color: white ;background-color: red ;padding: 10px;bottom: 20px;width: 200px;left: calc(50% - 100px); } .drink_water_container {position: relative; left: auto;width: 100%;margin-top: 40px;box-sizing: border-box; } '
document.querySelector('body').appendChild ( stili_extra )
function remove_tooltipin (){
document.querySelector('.reklama_tooltip_container').remove();
}
function shto_tooltip(){
sa_reklama_jane_hequr++;
var teksti = document.createElement('div')
teksti.setAttribute('class','reklama_tooltip_container')
teksti.innerText = 'Reklama u hoq ' ;
document.querySelector('body').appendChild(teksti)
}
function is_element_in_viewport(element) {
const rect = element.getBoundingClientRect();
return (
rect.top >= 0 &&
rect.left >= 0 &&
rect.bottom <= (window.innerHeight || document.documentElement.clientHeight) &&
rect.right <= (window.innerWidth || document.documentElement.clientWidth)
);
}
function remove_ads(el) {
//IF-i me poshte eshte per rastet kur SPONSORED eshte text i paster
if(document.querySelector('span span span a[aria-label="Sponsored"] span')){
//document.querySelector('span span span a[aria-label="Sponsored"] span').parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.style.display = 'none';
document.querySelector('span span span a[aria-label="Sponsored"] span').parentNode.parentNode.parentNode.parentNode.parentNode.parentNode
.parentNode.parentNode.parentNode.parentNode.parentNode
.innerHTML = '<h3 class="drink_water_container">Drink water '+ sa_reklama_jane_hequr +'</h3>'
//.remove()
}
var all_chars = []
var kot = document.querySelectorAll(' span svg use ').forEach(function(main_span_sponsored){
if(!is_element_in_viewport ( main_span_sponsored ) ) {
return ;
}
// console.log('kalledss')
//if we have already added the reklama_me_hover class , bail out
//if(main_span_sponsored.closest('div[data-pagelet]').classList.contains('reklama_me_hover') ) {
// console.log('No run, has reklama_me_hover already')
// return true;
// }
// console.log(main_span_sponsored.getAttribute('xlink:href'));
var link_text_id = main_span_sponsored.getAttribute('xlink:href').replace('#','');
// console.log(link_text_id);
var is_text_value_Sponsored = document.querySelectorAll('svg text#'+ link_text_id )[0].innerHTML;
// console.log("ID to Text " , is_text_value_Sponsored);
if( is_text_value_Sponsored == 'Sponsored') {
// console.log('found sponsoreddddddddddd');
//main_span_sponsored.closest('div[data-pagelet]').classList.add('reklama_me_hover');
main_span_sponsored
.parentElement.parentElement.parentElement.parentElement.parentElement
.parentElement.parentElement.parentElement.parentElement.parentElement
.parentElement.parentElement.parentElement.parentElement.parentElement
.parentElement.parentElement.parentElement.parentElement.parentElement
.parentElement.parentElement.parentElement.parentElement.parentElement
// .classList.add('reklama_me_hover')
// .remove() ;
.innerHTML = '<h3 class="drink_water_container">Drink water '+ sa_reklama_jane_hequr +'</h3>'
// shto_tooltip()
sa_reklama_jane_hequr++;
//setTimeout(function() {
// document.querySelector('.reklama_tooltip_container').remove();
//}, 1000); // <-- time in milliseconds
//window.setTimeOut( 'remove_tooltipin', 300 );
}
is_text_value_Sponsored = '';
all_chars = []
})
}
//remove the ads on sidebar
function remove_ads_sidebar(){
var a_ka_ad = document.querySelectorAll('div[role="complementary"] div div div div div div div div div div h3 span') ;
[...a_ka_ad].forEach(function(single_span ){
//console.log( single_span.innerText )
if( single_span.innerText == 'Sponsored' ){
console.log('removed sidebar ads ')
single_span
.parentElement.parentElement.parentElement.parentElement.parentElement
.parentElement.parentElement.parentElement.parentElement.parentElement
.remove();
}
})
}
const removeFbclid = (href) => {
const fbclidURL = new URL(href)
//fbclidURL.searchParams.delete("fbclid")
if (fbclidURL.host === "l.facebook.com" && fbclidURL.searchParams.get("u")) {
href = decodeURI(fbclidURL.searchParams.get("u"))
//href.searchParams.delete("fbclid")
// console.log("decided")
// console.log(href )
} else {
fbclidURL.searchParams.delete("fbclid")
href = fbclidURL.href
}
return href
}
const deleteFbclidLink = () => {
const fbclidLinkList = document.querySelectorAll('a[href*="fbclid"]')
if (!fbclidLinkList || fbclidLinkList.length === 0) {
return
}
// console.log(fbclidLinkList);
for (const fbclidLink of fbclidLinkList) {
// console.log(fbclidLink.href)
fbclidLink.addEventListener("click",
function (event) {
event.preventDefault()
window.open(removeFbclid(this.href))
},
false)
fbclidLink.href = removeFbclid(fbclidLink.href)
}
}
const excute = () => {
//remove fcb click ID
window.addEventListener("DOMSubtreeModified", deleteFbclidLink)
window.addEventListener("scroll", deleteFbclidLink)
window.addEventListener("click", deleteFbclidLink)
window.addEventListener("hover", deleteFbclidLink)
window.addEventListener("contextmenu", deleteFbclidLink)
//window.addEventListener("DOMSubtreeModified", remove_ads)
window.addEventListener("scroll", remove_ads)
window.addEventListener("DOMContentLoaded", remove_ads)
// window.addEventListener("click", remove_ads)
// window.addEventListener("hover", remove_ads)
// window.addEventListener("contextmenu", remove_ads)
//remove the sidebar ads
window.addEventListener("scroll", remove_ads_sidebar)
window.addEventListener("DOMContentLoaded", remove_ads_sidebar)
}
(function() {
'use strict';
excute()
})();