Jump to content

User:Eejit43/scripts/null-edit.js

From Wikipedia, the free encyclopedia
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/null-edit.ts

"use strict";(()=>{mw.loader.using(["mediawiki.util"],()=>{if(mw.config.get("wgNamespaceNumber")<0||!mw.config.get("wgIsProbablyEditable"))return;mw.util.addPortletLink(mw.config.get("skin")==="minerva"?"p-tb":"p-cactions","#","Null edit","null-edit").addEventListener("click",async t=>{t.preventDefault(),mw.notify("Null editing page...",{tag:"null-edit-notification"});try{await new mw.Api().edit(mw.config.get("wgPageName"),e=>({text:e.content,summary:"Null edit- if you see this, something went wrong!",minor:!0}))}catch(e){return console.error(e),mw.notify("An error occurred when null editing this page!",{type:"error",tag:"null-edit-notification"})}mw.notify("Successfully null edited page, reloading...",{type:"success",tag:"null-edit-notification"}),window.location.reload()})});})();

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