-
Notifications
You must be signed in to change notification settings - Fork 69
/
content.js
60 lines (53 loc) · 1.65 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
53
54
55
56
57
58
59
60
const defaultConfig = {
memeMode: false,
textEnabled: true,
removeBlueVerification: false,
textOptions: {
verifiedLabel: "Verified",
twitterBlueLabel: "Paid",
enableBorder: true,
},
};
async function loadVerifiedUsers() {
const url = chrome.runtime.getURL("data/verified.txt");
const response = await fetch(url);
const text = await response.text();
return text.split("\n");
}
function createSettingsDomNode(items) {
const settingsDomNode = document.createElement("div");
settingsDomNode.id = "eight-dollars-settings";
settingsDomNode.style.display = "none";
settingsDomNode.innerText = JSON.stringify(items);
document.body.appendChild(settingsDomNode);
}
function injectScript() {
const s = document.createElement("script", { id: "eight-dollars" });
s.src = chrome.runtime.getURL("script.js");
s.onload = function () {
this.remove();
};
document.head.appendChild(s);
}
function injectVerifiedUsers(verifiedUsers) {
const verifiedUsersDomNode = document.createElement("div");
verifiedUsersDomNode.id = "eight-dollars-verified-users";
verifiedUsersDomNode.style.display = "none";
verifiedUsersDomNode.innerText = JSON.stringify(verifiedUsers);
document.body.appendChild(verifiedUsersDomNode);
}
async function main() {
const verifiedUsers = await loadVerifiedUsers();
if (typeof chrome !== "undefined" && chrome.storage) {
chrome.storage.local.get(defaultConfig, function (items) {
createSettingsDomNode(items);
injectScript();
injectVerifiedUsers(verifiedUsers);
});
} else {
createSettingsDomNode(defaultConfig);
injectScript();
injectVerifiedUsers(verifiedUsers);
}
}
main();