diff --git a/js/debug.js b/js/debug.js index c308903..4a04499 100644 --- a/js/debug.js +++ b/js/debug.js @@ -79,16 +79,6 @@ function CheckForUpdates() { return response.json() }) .then(data => { - /* - const Result = document.createElement('span') - if (data.version === Version || Math.floor((data.version - Version) * 10) === 0) { - Result.innerText = 'No updates available' - } else { - Result.innerText = Math.floor((data.version - Version) * 10) + ' updates available' - } - CheckForUpdatesButton.parentElement.insertBefore(Result, CheckForUpdatesButton) - CheckForUpdatesButton.remove() - */ if (data.version === Version || Math.floor((data.version - Version) * 10) === 0) { CheckForUpdatesButton.innerText = 'No updates available' } else { diff --git a/settings.html b/settings.html index e5f16fb..7b9565f 100755 --- a/settings.html +++ b/settings.html @@ -546,7 +546,13 @@ -

made by Index

+ diff --git a/settings.js b/settings.js index 7b820e8..41eafba 100755 --- a/settings.js +++ b/settings.js @@ -315,4 +315,36 @@ function LoadFile(path, callback) { xhr.onload = function () { return callback(this.responseText); } xhr.open("GET", path, true); xhr.send(); -} \ No newline at end of file +} + +const Manifest = chrome.runtime.getManifest() +let BuildType = "Stable" +if (Manifest.version_name !== undefined) {BuildType = "Pre-Release"} + +const FooterText = document.getElementById('footer-text') +FooterText.children[0].innerHTML = `Version: v${Manifest.version} | Build Type: ${BuildType}` + +const CheckForUpdatesButton = document.getElementById('check-for-updates') +function CheckForUpdates() { + CheckForUpdatesButton.removeEventListener('click', CheckForUpdates) + CheckForUpdatesButton.disabled = true + fetch('https://polyplus.vercel.app/data/version.json') + .then(response => { + if (!response.ok) { + throw new Error('Network not ok') + } + return response.json() + }) + .then(data => { + if (data.version === Manifest.version || Math.floor((data.version - Manifest.version) * 10) === 0) { + CheckForUpdatesButton.innerHTML = 'No updates available' + alert('No updates available') + } else { + const NumberOfUpdatesAvailable = Math.floor((data.version - Version) * 10) + CheckForUpdatesButton.innerHTML = ''+NumberOfUpdatesAvailable+' update(s) available' + alert(NumberOfUpdatesAvailable + ' updates available') + } + }) + .catch(error => {console.log(error)}); +} +CheckForUpdatesButton.addEventListener('click', CheckForUpdates) \ No newline at end of file