forked from hant0508-zz/usescripts
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathEtarg ad remover.user.js
46 lines (39 loc) · 1.29 KB
/
Etarg ad remover.user.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
// ==UserScript==
// @name Etarg ad remover
// @namespace http://tampermonkey.net/
// @version 0.3
// @description Removes etarg and traforet ad banners (use with Ublock Origin or Adblock Plus)
// @author hant0508
// @include *
// @grant none
// ==/UserScript==
var snapResults;
var tries = 0;
function rem()
{
for (var i = snapResults1.snapshotLength - 1; i >= 0; i--)
{
var elm = snapResults1.snapshotItem(i);
elm.parentNode.removeChild(elm);
}
for (var i = snapResults2.snapshotLength - 1; i >= 0; i--)
{
var elm = snapResults2.snapshotItem(i);
elm.parentNode.removeChild(elm);
}
}
function xpath()
{
var regex1 = "/html/body//div[@onclick and ./table/tr/td/a[contains(@href, 'et-code.ru')]]";
var regex2 = "/html/body//div[a[@class=\"traforet-br-logo\" and contains(@href, 'traforet.com')]]";
snapResults1 = document.evaluate(regex1, document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
snapResults2 = document.evaluate(regex2, document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
if (tries <= 20)
{
window.setTimeout(xpath,100);
if (snapResults1.snapshotLength || snapResults2.snapshotLength) tries = 0;
tries++;
}
rem();
}
xpath();