User:Eejit43/scripts/deletion-finder.js

// // Note: This script was compiled and minified from TypeScript. For a more readable version, see https://github.com/Eejit43/wikipedia-scripts/blob/main/scripts/deletion-finder.ts

"use strict";mw.loader.using(["mediawiki.util"],async=>{if(mw.config.get("wgNamespaceNumber")!==0||mw.config.get("wgAction")!=="view"||mw.config.get("wgPageName")==="Main_Page")return;mw.util.addCSS(` .deletion-finder-link { display: inline-block; margin-left: 5px; font-size: 12px; }

.deletion-finder-link::before { display: inline-block; transform: translateY(2px); margin-right: 3px; }

color: #dd3333; }
 * 1) deletion-finder-previously-deleted {

content: url("data:image/svg+xml,%3Csvg xmlns=%22http://www.w3.org/2000/svg%22 width=%2212%22 height=%2212%22 fill=%22%23dd3333%22 viewBox=%220 0 20 20%22%3E%3Ctitle%3E trash %3C/title%3E%3Cpath d=%22M17 2h-3.5l-1-1h-5l-1 1H3v2h14zM4 17a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V5H4z%22/%3E%3C/svg%3E"); }
 * 1) deletion-finder-previously-deleted::before {

color: #3366cc; }
 * 1) deletion-finder-previous-afd {

content: url("data:image/svg+xml,%3Csvg xmlns=%22http://www.w3.org/2000/svg%22 width=%2215%22 height=%2215%22 fill=%22%233366cc%22 viewBox=%220 0 20 20%22%3E%3Ctitle%3E info %3C/title%3E%3Cpath d=%22M4 10a6 6 0 1 0 12 0 6 6 0 0 0-12 0m6-8a8 8 0 1 1 0 16 8 8 0 0 1 0-16m1 7v5H9V9zm0-1V6H9v2z%22/%3E%3C/svg%3E"); }`);const t=document.querySelector("#firstHeading");if(!t)return mw.notify("Could not find title element",{type:"error"});if((await new mw.Api.get({action:"query",leaction:"delete/delete",lelimit:1,letitle:mw.config.get("wgPageName"),list:"logevents"})).query.logevents.length>0){const e=document.createElement("a");e.id="deletion-finder-previously-deleted",e.classList.add("deletion-finder-link"),e.href=mw.util.getUrl("Special:Log/delete",{page:mw.config.get("wgPageName").replaceAll("_"," "),subtype:"delete"}),e.target="_blank",e.textContent="Previously deleted",t.append(e)}if(!(await new mw.Api.get({action:"query",formatversion:"2",titles:`Wikipedia:Articles_for_deletion/${mw.config.get("wgPageName")}`})).query.pages[0].missing){const e=document.createElement("a");e.id="deletion-finder-previous-afd",e.classList.add("deletion-finder-link"),e.href=mw.util.getUrl("Special:AllPages",{from:`Articles for deletion/${mw.config.get("wgPageName").replaceAll("_"," ")}`,to:`Articles for deletion/${mw.config.get("wgPageName").replaceAll("_"," ")} (9z)`,namespace:"4"}),e.target="_blank",e.textContent="Previously at AfD",t.append(e)}});
 * 1) deletion-finder-previous-afd::before {

// //# sourceMappingURL=data:application/json;base64,ewogICJ2ZXJzaW9uIjogMywKICAic291cmNlcyI6IFsiLi4vLi4vc2NyaXB0cy9kZWxldGlvbi1maW5kZXIudHMiXSwKICAic291cmNlc0NvbnRlbnQiOiBbImltcG9ydCB7IEFwaVF1ZXJ5TG9nRXZlbnRzUGFyYW1zLCBBcGlRdWVyeVBhcmFtcyB9IGZyb20gJ3R5cGVzLW1lZGlhd2lraS9hcGlfcGFyYW1zJztcblxubXcubG9hZGVyLnVzaW5nKFsnbWVkaWF3aWtpLnV0aWwnXSwgYXN5bmMgKCkgPT4ge1xuICAgIGlmIChtdy5jb25maWcuZ2V0KCd3Z05hbWVzcGFjZU51bWJlcicpICE9PSAwKSByZXR1cm47XG4gICAgaWYgKG13LmNvbmZpZy5nZXQoJ3dnQWN0aW9uJykgIT09ICd2aWV3JykgcmV0dXJuO1xuICAgIGlmIChtdy5jb25maWcuZ2V0KCd3Z1BhZ2VOYW1lJykgPT09ICdNYWluX1BhZ2UnKSByZXR1cm47XG5cbiAgICBtdy51dGlsLmFkZENTUyhgXG4uZGVsZXRpb24tZmluZGVyLWxpbmsge1xuICAgIGRpc3BsYXk6IGlubGluZS1ibG9jaztcbiAgICBtYXJnaW4tbGVmdDogNXB4O1xuICAgIGZvbnQtc2l6ZTogMTJweDtcbn1cblxuLmRlbGV0aW9uLWZpbmRlci1saW5rOjpiZWZvcmUge1xuICA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