const urlSearchParams = new URLSearchParams(window.location.search); const sourceURL = urlSearchParams.get('source'); // https://stackoverflow.com/a/8943487 const urlRegex = /(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig; (function (global) { var apps; global.setApps = array => apps = array; global.getAppWithBundleId = bundleId => apps?.find(app => app.bundleIdentifier == bundleId) ?? undefined; setUpBackButton(); })(this); const newsItemHTML = (news, minimal = false) => `
${news.url ? "" : ""}

${news.title}

${news.caption}

${news.imageURL && !minimal ? "
" + "" + "
" : ""}
${news.url ? "
" : ""} ${news.appID && !minimal ? appHeaderHTML(getAppWithBundleId(news.appID)) ?? "" : ""}
`; const appHeaderHTML = app => app ? `

${app.name}

${app.developerName}

` : undefined; function insertAddToAltStoreBanner() { document.getElementById("top")?.insertAdjacentHTML("afterbegin", `
altstore-icon

AltStore

Add this source to AltStore to receive app updates (requires AltStore beta)

`); } function insertNavigationBar(title) { document.getElementById("top")?.insertAdjacentHTML("beforeend", ` `); setUpBackButton(); } // https://stackoverflow.com/a/43467144/19227228 function isValidHTTPURL(string) { var url; try { url = new URL(string); } catch (error) { console.error("An error occurred.", error); return false; } return url.protocol == "http:" || url.protocol == "https:"; } function formatString(string) { if (!string) return undefined; // URLs const urlArray = string.match(urlRegex); // const urlSet = [...new Set(urlArray)]; // Converting to set to remove duplicates var result = ""; urlArray.forEach(url => { string = string.replace(url, `${url}`) // Remove formatted substring so it won't get formatted again (prevents tag within the href attribute another tag) let endIndexOfClosingTag = string.indexOf("") + 4; let formattedSubstring = string.substring(0, endIndexOfClosingTag); result += formattedSubstring; string = string.replace(formattedSubstring, ""); }); // New lines return result.replaceAll("\n", "
");; } function setTintColor(color) { document.querySelector(':root')?.style.setProperty("--accent-color", `#${color}`); } function setUpBackButton() { document.getElementById("back")?.addEventListener("click", () => history.back(1)); } function search() { window.location.replace("search.html"); } const $ = selector => selector.startsWith("#") && !selector.includes(".") && !selector.includes(" ") ? document.getElementById(selector.substring(1)) : document.querySelectorAll(selector);