forked from rachitnigam/mastodon-clean-boost
-
Notifications
You must be signed in to change notification settings - Fork 0
/
content.js
52 lines (45 loc) · 1.69 KB
/
content.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
/* This runs after a web page loads */
function handleArtile(node) {
// Remove status info
let status = node.querySelector(".status__info__icons");
if (status) {
status.parentNode.removeChild(status);
}
// Move the time information next to the name
let time = node.querySelector(".status__relative-time");
let displayName = node.querySelector(".display-name");
displayName.appendChild(time)
// Move prepend stuff into the info
let prepend = node.querySelector(".status__prepend")
if (prepend) {
// Define a new div to contain the display-name information and status information
let div = document.createElement("div");
div.appendChild(prepend);
div.appendChild(node.querySelector(".display-name"));
let info = node.querySelector(".status__info__account")
info.appendChild(div);
}
// Wrap each button in a div
let statusBar = node.querySelector(".status__action-bar")
if (statusBar) {
statusBar.querySelectorAll("button").forEach((el) => {
let div = document.createElement("div");
el.parentNode.insertBefore(div, el);
div.appendChild(el);
})
}
}
function addMutationObserver() {
const observer = new MutationObserver(function (mutations) {
mutations.forEach(function (mutation) {
// Remove status info icons
mutation.target.querySelectorAll("article").forEach(handleArtile);
// Fix the margin around the status prepend
/* mutation.target.querySelectorAll(".status__prepend").forEach((node) => {
node.style["margin-bottom"] = 0
}); */
});
});
observer.observe(document.body, { subtree: true, childList: true });
}
addMutationObserver()