added a UI for a user to see if the api is online or offline

This commit is contained in:
thereaper90917 committed 2021-12-21 04:09:34 +02:00
1 parent b56350bd10
commit c5d3f024ad
19 files changed
+467 -140

No files matched your search

+26 -8
View File
@@ -9,8 +9,8 @@ const config = {
website: "https://returnyoutubedislike.com",
github: "https://github.com/Anarios/return-youtube-dislike",
discord: "https://discord.gg/mYnESY4Md5",
donate: 'https://returnyoutubedislike.com/donate',
faq: 'https://returnyoutubedislike.com/faq'
donate: "https://returnyoutubedislike.com/donate",
faq: "https://returnyoutubedislike.com/faq",
},
};
@@ -35,10 +35,11 @@ document.getElementById("link_donate").addEventListener("click", () => {
chrome.tabs.create({ url: config.links.donate });
});
document.getElementById("disable_vote_submission").addEventListener("click", (ev) => {
chrome.storage.sync.set({ disableVoteSubmission: ev.target.checked });
});
document
.getElementById("disable_vote_submission")
.addEventListener("click", (ev) => {
chrome.storage.sync.set({ disableVoteSubmission: ev.target.checked });
});
/* Advanced Toggle */
const advancedToggle = document.getElementById("advancedToggle");
@@ -62,7 +63,7 @@ function initConfig() {
}
function initializeDisableVoteSubmission() {
chrome.storage.sync.get(['disableVoteSubmission'], (res) => {
chrome.storage.sync.get(["disableVoteSubmission"], (res) => {
handleDisableVoteSubmissionChangeEvent(res.disableVoteSubmission);
});
}
@@ -71,7 +72,9 @@ chrome.storage.onChanged.addListener(storageChangeHandler);
function storageChangeHandler(changes, area) {
if (changes.disableVoteSubmission !== undefined) {
handleDisableVoteSubmissionChangeEvent(changes.disableVoteSubmission.newValue);
handleDisableVoteSubmissionChangeEvent(
changes.disableVoteSubmission.newValue
);
}
}
@@ -80,6 +83,21 @@ function handleDisableVoteSubmissionChangeEvent(value) {
document.getElementById("disable_vote_submission").checked = value;
}
(async function getStatus() {
let status = document.getElementById("status");
let resp = await fetch(
"https://returnyoutubedislikeapi.com/votes?videoId=YbJOTdZBX1g"
);
let result = await resp.status;
if (result === 200) {
status.innerText = "Online";
status.style.color = "green";
} else {
status.innerText = "Offline";
status.style.color = "red";
}
})();
/* popup-script.js
document.querySelector('#login')
.addEventListener('click', function () {