-
-
Notifications
You must be signed in to change notification settings - Fork 7
/
index.js
53 lines (53 loc) · 1.87 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
const textElements = [
get("shortBlurb"),
get("download"),
get("totalUsers"),
];
const translator = new Translator(lang, langs);
async function index() {
document.documentElement.lang = lang;
if (isArScript)
document.dir = "rtl";
else
document.dir = "ltr";
await translator.initialize();
textElements.forEach((element) => {
element.innerHTML = translator.get(element.id);
});
}
function specifics() {
switch (lang) {
case ar: {
textElements.forEach((element) => {
element.style.fontFamily = arFont;
element.style.lineHeight = "1.3em";
});
break;
}
case fa: {
textElements.forEach((element) => {
element.style.fontFamily = faFont;
element.style.lineHeight = "1.3em";
});
break;
}
default: {
break;
}
}
}
async function displayTotalUsers() {
const chromeResponse = await (await fetch(`https://api.allorigins.win/get?url=${encodeURIComponent("https://chrome.google.com/webstore/detail/wudooh/nigfaloeeeakmmgndbdcijjegolpjfhn")}`)).json();
const chromeUsers = parseInt(("" + chromeResponse.contents.match(/<span class="e-f-ih" title="([\d]*?) users">([\d]*?) users<\/span>/)).split(",")[2]);
const firefoxResponse = await (await fetch(`https://api.allorigins.win/get?url=${encodeURIComponent("https://addons.mozilla.org/en-US/firefox/addon/wudooh/")}`)).json();
const firefoxUsers = parseInt(("" + firefoxResponse.contents.match(/<dd class="MetadataCard-content">([\d]*?)<\/dd>/)).match(/\d+/g)[0]);
const totalUsers = chromeUsers + firefoxUsers;
let text = "...";
if (isNaN(totalUsers))
displayTotalUsers();
else
text = totalUsers.toString();
get("numUsers").innerHTML = text;
}
specifics();
index();