User:Sewil/MarkForDeletionRemix.js

/*if (mediaWiki.config.get("wgAction") === "view" && mediaWiki.config.get("wgNamespaceNumber") !== -1 && mediaWiki.config.get("wgUserName") !== null) { (function ($, mw, window, document) {       "use strict";		var wgServer = mw.config.get("wgServer"),			wgPageNameEncoded = window.encodeURIComponent(mw.config.get("wgPageName"));		function setDeleteNotice(deleteReason) {			var xhr = new XMLHttpRequest,				summary = "marked for deletion: " + deleteReason,				content = "",				editToken = mw.user.tokens.get("editToken"),				url = wgServer + "/api.php?action=edit&title=" + wgPageNameEncoded + "&summary=" + window.encodeURIComponent(summary) + "&format=json&prependtext=" + window.encodeURIComponent(content) + "&token=" + window.encodeURIComponent(editToken);			xhr.open("POST", url);			xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");			xhr.onreadystatechange = function  {				if (this.readyState === 4) {					window.location.reload;				}			};			xhr.send;		}        function setNewFileNotice(newFile) {			var xhr = new XMLHttpRequest, summary = "replaced by PNG: " + newFile, content = "🇵🇬", editToken = mw.user.tokens.get("editToken"), url = wgServer + "/api.php?action=edit&title=" + wgPageNameEncoded + "&summary=" + window.encodeURIComponent(summary) + "&format=json&prependtext=" + window.encodeURIComponent(content) + "&token=" + window.encodeURIComponent(editToken); xhr.open("POST", url); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function { if (this.readyState === 4) { window.location.reload; }			};			xhr.send; }		// adds a "Mark for deletion" button to the user's toolbar function initDeleteNoticeButton { var $button, toolbar, $mytoolsLI, $customizeLI; // don't create duplicate buttons if (document.getElementById("mark-for-deletion-link") !== null) { return; }			// create button $button = $('Mark for deletion'); $button.click(function deleteNoticeButtonClickHandler {				var promptedDeleteReason = "spam";				if (typeof window.MarkForDeletion === "object" && window.MarkForDeletion !== null && typeof window.MarkForDeletion.promptedDeleteReason === "string") {					promptedDeleteReason = window.MarkForDeletion.promptedDeleteReason;				}				var deleteReason = window.prompt("Enter delete reason to quickly mark this page for deletion:", promptedDeleteReason);				if (typeof deleteReason === "string" && deleteReason.length > 0) {					setDeleteNotice(deleteReason);				}			}); $buttonPng = $('Mark for PNGified'); $buttonPng.click(function deleteNoticeButtonClickHandler {				var promptedDeleteReason = "spam";				if (typeof window.MarkForDeletion === "object" && window.MarkForDeletion !== null && typeof window.MarkForDeletion.promptedDeleteReason === "string") {					promptedDeleteReason = window.MarkForDeletion.promptedDeleteReason;				}				var newFile = window.prompt("Enter the new file:", promptedNewFile);				if (typeof newFile === "string" && newFile.length > 0) {					setNewFileNotice(newFile);				}			}); // add button to toolbar toolbar = document.getElementById("WikiaBarWrapper"); if (toolbar !== null) { // oasis $mytoolsLI = $(toolbar).find("li.mytools"); if ($mytoolsLI.length > 0) { // insert link before My Tools $mytoolsLI.before($button); $mytoolsLI.before($buttonPng); } else { // try to insert link before Customize $customizeLI = $(toolbar).find("a.tools-customize").parent; $customizeLI.before($button); $customizeLI.before($buttonPng); }			} else { // monobook toolbar = document.getElementById("p-tb"); if (toolbar !== null) { $(toolbar).find("ul").append($button); $(toolbar).find("ul").append($buttonPng); }			}		}		// add button on DOMReady $(initDeleteNoticeButton); }(jQuery, mediaWiki, window, document)); } /* __NOWYSIWYG__ */