MCPcopy Create free account
hub / github.com/Useful-Scripts-Extension/useful-script / checkForUpdate

Function checkForUpdate

popup/helpers/checkForUpdate.js:8–40  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

6const updateBtn = document.querySelector("#update-btn");
7
8export async function checkForUpdate() {
9 try {
10 const currentVer = (await chrome.runtime.getManifest()).version;
11 versionSpan.innerHTML = "v" + currentVer;
12
13 const { version_check, source_code } = config;
14 const lastestVer = (await (await fetch(version_check)).json()).version;
15 if (lastestVer > currentVer) {
16 updateBtn.style.display = "inline-block";
17 updateBtn.innerHTML = t({
18 vi: "cập nhật v" + lastestVer,
19 en: "update v" + lastestVer,
20 });
21 updateBtn.setAttribute(
22 "data-tooltip",
23 t({
24 vi: "Đã có phiên bản mới v" + lastestVer,
25 en: "Update available v" + lastestVer,
26 })
27 );
28 updateBtn.setAttribute("data-flow", "bottom");
29 updateBtn.onclick = () => {
30 trackEvent("CHECK-FOR-UPDATE");
31 window.open(source_code);
32 };
33 } else {
34 updateBtn.style.display = "none";
35 versionSpan.innerHTML += t({ vi: " (mới nhất)", en: " (lastest)" });
36 }
37 } catch (e) {
38 console.warn("Check for update failed", e);
39 }
40}

Callers 2

initSettingsFunction · 0.90
index.jsFile · 0.90

Calls 2

tFunction · 0.90
trackEventFunction · 0.90

Tested by

no test coverage detected