-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMercado Livre Hide Delivered.js
More file actions
58 lines (42 loc) · 1.7 KB
/
Mercado Livre Hide Delivered.js
File metadata and controls
58 lines (42 loc) · 1.7 KB
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
// ==UserScript==
// @name Mercado Livre hide delivered
// @description Hide delivered items in order list
// @match https://myaccount.mercadolivre.com.br/my_purchases/list
// @run-at document-end
// ==/UserScript==
(function(){
let qs = (q) => document.querySelector(q)
let qsa = (q, x) => [...(x || document).querySelectorAll(q)]
let hide = (e) => {
e.preventDefault();
qsa("div.list-item__product > div.list-item__data > p.list-item__intro > span")
.filter(x => x.innerText == "Entregue")
.map(x => x.closest(".list-item"))
.forEach(x => x.style.display = "none")
qsa("div.list-item-grouper")
.filter(x => qsa(".list-item", x).every(x => x.style.display == "none"))
.forEach(x => x.style.display = "none")
}
const addButton = () => {
let container = qs(".list-header__subtitles")
if (container && qs(".hide-delivered-btn")) return;
let a = document.createElement("a")
a.appendChild(document.createTextNode("Hide delivered"))
a.className = "andes-button bf-ui-button andes-button--medium andes-button--loud hide-delivered-btn"
a.href = "#"
a.onclick = hide
container.appendChild(a)
}
addButton()
const mo1 = new MutationObserver(addButton)
mo1.observe(document.body, { childList: true, subtree: true });
// dismiss le annoy recurring hint
const closers = () => {
const btn = document.evaluate(`//span[@class='andes-button__content' and contains(text(),'OK, entendi')]`,
document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue
if (btn) btn.click()
}
closers()
const mo2 = new MutationObserver(closers)
mo2.observe(document.body, { childList: true, subtree: true });
})()