-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
77 lines (67 loc) · 2.06 KB
/
index.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
// ==UserScript==
// @name Hide your twitter info
// @namespace https://github.com/KazooTTT/hide-your-twitter-info
// @version 0.6
// @description Hide your Twitter information. Prevent others from seeing your ID, nickname, and profile picture in public places.
// @author KazooTTT
// @match https://twitter.com/*
// @match https://x.com/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=twitter.com
// @license MIT
// @grant GM_getValue
// @grant GM_setValue
// @grant GM_registerMenuCommand
// @grant GM_unregisterMenuCommand
// ==/UserScript==
const insertStylesBySelector = (selector) => {
const style = document.createElement("style");
style.textContent = `
${selector} {
display:none
}
`;
const head = document.querySelector("head");
head.append(style);
};
(function () {
"use strict";
function useOption(key, title, defaultValue) {
if (typeof GM_getValue === 'undefined') {
return {
value: defaultValue,
}
}
let value = GM_getValue(key, defaultValue)
const ref = {
get value() {
return value
},
set value(v) {
value = v
GM_setValue(key, v)
location.reload()
},
}
GM_registerMenuCommand(`${title}: ${value ? '✅' : '❌'}`, () => {
ref.value = !value
})
return ref
}
const hideTwitterInfo = useOption('hideTwitterInfoTab', 'Hide Twitter Info', true)
if(hideTwitterInfo.value){
insertStylesBySelector(`[data-testid="SideNav_AccountSwitcher_Button"] > div:nth-child(1)`);
insertStylesBySelector(`[data-testid="SideNav_AccountSwitcher_Button"] > div:nth-child(2)`);
const timer = setInterval(() => {
const accountEl = document.querySelector(
'a[data-testid="AppTabBar_Profile_Link"]'
);
if (accountEl) {
const accountId = accountEl.href.split("/").pop();
insertStylesBySelector(
`div[data-testid="UserAvatar-Container-${accountId}"]`
);
clearInterval(timer);
}
}, 1500);
}
})();