-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
94 lines (87 loc) · 2.86 KB
/
main.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
const DATA_ARRAY = {
sites: [
{
url: "https://funpay.ru/users/1333773/",
deleted: [
".offer", ".bg-light-color"
],
},
{
url: /^https:\/\/funpay.ru\/orders\/\?.*/,
deleted: [
"#content > div > div > div.tc.tc-finance.table-hover.table-clickable.dyn-table.orders-table"
],
append: [
{".page-content-full": '<p class="lead">Пусто.</p>'}
]
},
{
url: /^https:\/\/funpay.ru\/orders\/$/g,
deleted: [
"#content > div > div > div.tc.tc-finance.table-hover.table-clickable.dyn-table.orders-table > div.dyn-table-body > a:nth-child(1)",
],
deleteMultiply: 4,
},
{
url: /https:\/\/funpay.ru\/orders\/trade.*/g,
deleted: [
"#content > div > div > div.tc.tc-finance.table-hover.table-clickable.dyn-table.orders-table"
],
append: [
{".page-content-full": '<p class="lead">Пусто.</p>'}
]
},
{
url: /https:\/\/funpay.ru\/chat.*/g,
deleted: [
"#content > div > div > div > div.chat-contacts > div.contact-list.custom-scroll > a:nth-child(1)"
],
deleteMultiply: 29,
// "changed": [
// {"": ""}
// ]
},
]
}
const currentUrl = window.location.href
selectCurrentSite()
function selectCurrentSite() {
let urlMatch = DATA_ARRAY.sites.find(element => {
if (currentUrl.match(element.url)) {
dbg(element, currentUrl, element.url)
return true
}
})
if (urlMatch) {
if (urlMatch.deleted) removeElement(urlMatch.deleted, urlMatch.deleteMultiply)
if (urlMatch.append) appendElement(urlMatch.append)
}
}
function appendElement(elements) {
elements.forEach((element) => {
let DOMpreloader = setInterval(function () {
let changeObject = document.querySelector(Object.keys(element)[0])
if (changeObject !== null) {
clearInterval(DOMpreloader);
if (changeObject.lastChild.outerHTML != Object.values(element)[0]) {
changeObject.insertAdjacentHTML('beforeend', Object.values(element)[0])
}
}
}, 10);
})
}
function removeElement(elements, delM = 1) {
for (let i = 0; i < delM; i++) {
elements.forEach((element) => {
let DOMpreloader = setInterval(function () {
if (document.querySelector(element) !== null) {
clearInterval(DOMpreloader);
document.querySelector(element).remove()
}
}, 10);
})
}
}
function dbg(...msg) {
console.log(...msg)
}