-
Notifications
You must be signed in to change notification settings - Fork 0
/
ui_hook.js
37 lines (35 loc) · 1.51 KB
/
ui_hook.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
function pollContactsHeader() {
let root_el = ""
try {
root_el = document.querySelector("[aria-label=\"Thread list\"]").childNodes[0].childNodes[0].childNodes[0].childNodes[1]
} catch (error) {
setTimeout(pollContactsHeader, 100)
return
}
root_el.style.flexDirection = 'row'
root_el.style.alignItems = 'center'
let ui_el = document.createElement("div")
ui_el.classList.add("x78zum5", "x2lah0s")
ui_el.innerHTML = "<button type=\"button\" id=\"set_compact_btn\">Compact</button>\
<button type=\"button\" id=\"reload_btn\">Normal</button>"
root_el.insertBefore(ui_el, root_el.children[0])
window.compactMode.get().then(response => {
if (response == true) {
document.querySelector("#set_compact_btn").classList.toggle("hidden")
} else {
document.querySelector("#reload_btn").classList.toggle("hidden")
}
})
document.querySelector("#set_compact_btn").addEventListener('click', function (e) {
document.querySelector("#reload_btn").classList.toggle("hidden")
document.querySelector("#set_compact_btn").classList.toggle("hidden")
window.compactMode.enable()
})
document.querySelector("#reload_btn").addEventListener('click', function (e) {
document.querySelector("#reload_btn").classList.toggle("hidden")
document.querySelector("#set_compact_btn").classList.toggle("hidden")
window.compactMode.disable()
})
console.log("UI hooked")
}
pollContactsHeader()