${news.title}
${news.caption}
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", `
${news.caption}