libredirect/src/pages/options/spotify/spotify.js

34 lines
1.3 KiB
JavaScript
Raw Normal View History

2022-03-16 17:58:55 +01:00
import spotifyHelper from "../../../assets/javascripts/helpers/spotify.js";
import commonHelper from "../../../assets/javascripts/helpers/common.js";
let disableSpotifyElement = document.getElementById("disable-spotify");
browser.storage.local.get(
[
"disableSpotifyTargets",
],
r => {
disableSpotifyElement.checked = !r.disableSpotifyTargets;
2022-03-16 17:58:55 +01:00
}
)
2022-03-16 17:58:55 +01:00
commonHelper.processDefaultCustomInstances('spotify', 'soju', 'normal', document);
2022-04-17 14:27:21 +02:00
let latencyElement = document.getElementById("latency");
let latencyLabel = document.getElementById("latency-label");
latencyElement.addEventListener("click",
async () => {
let reloadWindow = () => location.reload();
latencyElement.addEventListener("click", reloadWindow);
await spotifyHelper.init();
let redirects = spotifyHelper.getRedirects();
const oldHtml = latencyLabel.innerHTML;
latencyLabel.innerHTML = '...';
commonHelper.testLatency(latencyLabel, redirects.soju.normal).then(r => {
browser.storage.local.set({ sojuLatency: r });
latencyLabel.innerHTML = oldHtml;
commonHelper.processDefaultCustomInstances('spotify', 'soju', 'normal', document);
2022-04-17 14:27:21 +02:00
latencyElement.removeEventListener("click", reloadWindow)
});
}
);