-
Notifications
You must be signed in to change notification settings - Fork 0
/
content-script.js
91 lines (77 loc) · 2.21 KB
/
content-script.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
function hideTweetMetrics() {
const tweetElements = document.querySelectorAll("article");
tweetElements.forEach((tweet) => {
const likesElement = tweet.querySelectorAll(
'span[data-testid="app-text-transition-container"] > span > span',
);
const timelineElement = tweet.querySelector(
'div[aria-label="Timeline: Trending now"]',
);
const relevantPeopleElement = tweet.querySelector(
'aside[aria-label="Relevant people"]',
);
if (likesElement) {
likesElement.forEach((like) => {
like.style.display = "none";
});
}
if (timelineElement) {
timeline.style.display = "none";
}
if (relevantPeopleElement) {
relevantPerson.style.display = "none";
}
});
const replyMetricWhenMediaOpen = document.querySelectorAll(
'span[data-testid="app-text-transition-container"] > span > span',
);
if (replyMetricWhenMediaOpen) {
replyMetricWhenMediaOpen.forEach((reply) => {
reply.style.display = "none";
});
}
}
function hideSkeetMetrics() {
const likeElements = document.querySelectorAll(
'div[data-testid="likeCount"]',
);
const repostElements = document.querySelectorAll(
'div[data-testid="repostCount"]',
);
const commentElements = document.querySelectorAll(
'button[data-testid="replyBtn"] > div',
);
const repostInPostElements = document.querySelector(
'div[data-testid="repostCount-expanded"] > span',
);
const likesInPostElements = document.querySelector(
'div[data-testid="likeCount-expanded"] > span',
);
likeElements.forEach((skeet) => {
skeet.style.display = "none";
});
repostElements.forEach((skeet) => {
skeet.style.display = "none";
});
commentElements.forEach((skeet) => {
skeet.style.display = "none";
});
repostInPostElements.style.display = "none";
likesInPostElements.style.display = "none";
}
function hideMetricsOnTwitterBluesky() {
if (window.location.href.startsWith("https://bsky.app/")) {
hideSkeetMetrics();
}
if (window.location.href.startsWith("https://x.com/")) {
hideTweetMetrics();
}
}
hideMetricsOnTwitterBluesky();
// Listen for new tweets/skeets and hide their metrics
const observer = new MutationObserver(hideMetricsOnTwitterBluesky);
observer.observe(document.body, {
childList: true,
subtree: true,
characterData: true,
});