User:Ioaxxere/archiver.js

if (document.getElementById("ca-nstab-main") || document.getElementsByClassName("minerva__tab selected")[0]) { if (document.querySelector("body.skin-vector-2022")) { document.querySelector("header").style.zIndex = 0; // otherwise it doesn't go under the popup }

let content_bar = (document.getElementById("ca-nstab-main") || document.getElementsByClassName("minerva__tab selected")[0]).parentElement; let archiver = document.createElement("li"); let popup = document.createElement("div");

content_bar.appendChild(archiver); archiver.className = "mw-list-item mw-list-item-js vector-tab-noicon minerva__tab"; // the kitchen sink... archiver.innerHTML = "Archive a page";

document.body.appendChild(popup); popup.style = "width: 100%; height: 100%; left: 0px; top: 0px; background: rgba(0, 0, 0, 0.5); position: fixed; display: none"; popup.innerHTML = " Enter the URL:❌  Archive  ";

let popup_button = archiver.firstChild; let close_popup_button = popup.querySelector("span"); let URL_form = popup.querySelector("textarea"); let submit_button = popup.querySelector("button");

// Open popup. popup_button.addEventListener("click", => {		popup.style.display = "block";	});

// Close popup. [popup, close_popup_button].forEach(elem => elem.addEventListener("click", => { URL_form.value = ""; popup.style.display = "none"; }));	popup.firstChild.addEventListener("click", event => event.stopPropagation);

// Archive URL. submit_button.addEventListener("click", => {		if (URL_form.value) {			archive_window = window.open("https://archive.ph/submit/?anyway=1&url=" + URL_form.value);		}	}); }