Skip to content

Commit

Permalink
Release v2.0
Browse files Browse the repository at this point in the history
Rewrite extension to make it work properly
  • Loading branch information
wseagar committed Apr 28, 2023
1 parent b3a80a1 commit 2584c19
Show file tree
Hide file tree
Showing 5 changed files with 408,033 additions and 377 deletions.
37 changes: 30 additions & 7 deletions content.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@ const defaultConfig = {
},
};

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";
Expand All @@ -26,12 +33,28 @@ function injectScript() {
document.head.appendChild(s);
}

if (typeof chrome !== "undefined" && chrome.storage) {
chrome.storage.local.get(defaultConfig, function (items) {
createSettingsDomNode(items);
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();
});
} else {
createSettingsDomNode(defaultConfig);
injectScript();
injectVerifiedUsers(verifiedUsers);
}
}

main();
Loading

0 comments on commit 2584c19

Please sign in to comment.