User:Eejit43/scripts/deletion-finder.js

Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
// <nowiki>
// 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;
}

#deletion-finder-previously-deleted {
    color: #d33;
}

#deletion-finder-previously-deleted::before {
    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");
}

#deletion-finder-previous-afd {
    color: #36c;
}

#deletion-finder-previous-afd::before {
    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");
}`);let 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){let 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){let 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)}});})();

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