· 5 years ago · Aug 13, 2020, 02:42 PM
1// ==UserScript==
2// @name yandex mail advert
3// @version 1
4// @match *://*.yandex.ru/*
5// @match *://yandex.ru/*
6// @grant none
7// @run-at document-idle
8// ==/UserScript==
9
10
11var ooo = /^ns-view-[a-z]{4,10} ns-view-id-[0-9]{1,3}$/;
12
13document.addEventListener("DOMNodeInserted", myFunction);
14
15function myFunction() {
16 var sub = document.getElementsByClassName("mail-Layout-Content");
17
18 if (sub.length > 0)
19 {
20 for (var i = 0; i < sub[0].children.length; i++)
21 {
22 if (sub[0].children[i].className.match(ooo))
23 {
24 sub[0].children[i].remove();
25 };
26 };
27 };
28
29 var lft = document.getElementsByClassName("ns-view-left-box");
30
31 if (lft.length > 0)
32 {
33 for (var i = 0; i < lft[0].children.length; i++)
34 {
35 if (lft[0].children[i].className.match(ooo))
36 {
37// alert(i + " - " + lft[0].children[i].className);
38 lft[0].children[i].remove();
39 };
40 };
41 };
42
43};
44
45
46
47var tst = document.getElementsByClassName("ns-view-mail-pro-left-column-button");
48if (tst.length > 0)
49{
50 tst[0].children[0].children[0].children[0].innerText = 'Сами жрите свою рекламу';
51};
52
53
54
55//Trying yandex.direct
56
57var sub = document.querySelectorAll("a[href^='https://direct.yandex.ru/']");
58
59if (sub.length > 0)
60{
61 for (var i = 0; i < sub.length; i++)
62 {
63 sub[i].parentNode.parentNode.remove();
64 };
65};
66
67
68