const urlSearchParams = new URLSearchParams(window.location.search); const sourceURL = urlSearchParams.get('source'); // If no source if (!urlSearchParams.has('source') || !sourceURL) { alert(`No source provided.`); window.location.replace("index.html"); } const urlRegex = /(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig; // https://stackoverflow.com/a/8943487 function formatString(string) { if (!string) return undefined; // URLs const urlArray = string.match(urlRegex); const urlSet = [...new Set(urlArray)]; // Converting to set to remove duplicates urlSet.forEach(url => string = string.replaceAll(url, `${url}`)); // New lines return string.replaceAll("\n", "
"); } // If source is not a URL if (!sourceURL.match(urlRegex)) { alert("Invalid URL."); window.location.replace("index.html"); } // Back button document.getElementById("back")?.addEventListener("click", () => history.back(1)); // Add to AltStore banner document.getElementById("top")?.insertAdjacentHTML("afterbegin", `
altstore-icon

AltStore

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

`); function waitForAllImagesToLoad() { const allImages = document.querySelectorAll("img"); var count = 0; allImages.forEach(image => { // New img element that won't be rendered to the DOM var newImage = document.createElement("img"); // Attach load listener newImage.addEventListener("load", imageLoaded); // Set src newImage.src = image.src; }) function imageLoaded() { if (++count == allImages.length) { document.querySelector("body").classList.remove("loading"); document.getElementById("loading").remove(); } } } function setTintColor(color) { document.querySelector(':root').style.setProperty("--accent-color", `#${color}`); } function addNavigationBar(title) { document.getElementById("top").insertAdjacentHTML("beforeend", ` `); document.getElementById("back")?.addEventListener("click", () => history.back(1)); } function newsItemHTML(news, apps, minimal) { let html = `
`; if (news.url) html += ` `; html += `

${news.title}

${news.caption}

`; if (news.imageURL && !minimal) html += `
`; html += `
`; if (news.url) html += "
"; if (news.appID && !minimal) { const app = apps.find(app => app.bundleIdentifier == news.appID); if (app) html += appHeaderHTML(app); } html += "
"; return html; } function appHeaderHTML(app) { return `

${app.name}

${app.developerName}

`; }