Code that you insert on this page could contain malicious content capable of compromising your account. If you import a script from another page with "importScript", "mw.loader.load", "iusc", or "lusc", take note that this causes you to dynamically load a remote script, which could be changed by others. Editors are responsible for all edits and actions they perform, including by scripts. User scripts are not centrally supported and may malfunction or become inoperable due to software changes. A guide to help you find broken scripts is available. If you are unsure whether code you are adding to this page is safe, you can ask at the appropriate village pump. This code will be executed when previewing this page.
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.
$(function(){pageTitle=mw.config.values.wgCanonicalNamespace+":"+mw.config.values.wgTitle;// [APPEARANCE] Custom styles for my userpageif(pageTitle.split("/")[0]==="User:BEANS X2"){varstylesheets=["User:BEANS X2/Userpage/index.css","User:BEANS_X2/Userpage/mdl.css"];$("#beans").css("display","block");stylesheets.forEach(function(style){$.ajax({url:"https://en.wikipedia.org/w/index.php?title="+style.replace("_"," ")+"&action=raw"}).done(function(data){mw.util.addCSS(data);});});}// [UTILITY] Alt+click page title to fill it into Search$("#firstHeading").on("click",function(ctx){if(ctx.altKey){$("#searchInput").val(pageTitle).focus();}});// [BETA] Enable bracket matchingmw.config.values.wgCodeMirrorEnableBracketMatching=true;// [APPEARANCE] Make the "edit saved" popup a snackbarif(mw.config.values.wgPostEdit=="saved"){$(".postedit").hide();// Hide the classic popupvarundoLastEdit=function(){// Adapted from [[User:Enterprisey/undo-last-edit.js]]varapi=newmw.Api();api.get({prop:'revisions',rvprop:'content',rvlimit:2,titles:mw.config.get("wgPageName")}).done(function(data){if(!data.query||!data.query.pages)return;varpageid=Object.getOwnPropertyNames(data.query.pages)[0],text=data.query.pages[pageid].revisions[1]["*"];api.postWithToken("csrf",{action:"edit",title:mw.config.get("wgPageName"),summary:"Undoing my last edit [semi-automated]",text:text}).done(function(data){if(data&&data.edit&&data.edit.result&&data.edit.result=='Success'){console.log("Edit undone")document.___location.reload(true);}});});}waitForRW=setInterval(function(){try{varsnackbarContainer=document.querySelector('#rw-toast');vardata={message:'Edit saved',timeout:5000,actionHandler:undoLastEdit,actionText:'Undo'};snackbarContainer.MaterialSnackbar.showSnackbar(data);clearInterval(waitForRW)}catch(err){null}},500)}// [UTILITY] Get the RPM easilymw.util.addPortletLink('p-tb','#0','View RPM').innerHTML="<a href='#0' id='rpm-link'>↩️ View RPM</a>"$("#rpm-link").on("click",function(ctx){$.getJSON("https://redwarn.toolforge.org/tools/rpmInfo.php").done(function(data){mw.notify("Reverts per minute: "+data[0].totalRPM)})})// [UTILITY] "Silent pages" - Add a blacklist of pages to not be added to your watchlist.varsilentPages=["Project:Sandbox"]varallowedActions=["edit","submit"]if(silentPages.includes(pageTitle)&&allowedActions.includes(wgAction)){$("#wpWatchthis").prop('checked',false);}console.log("Hello from user JS!");});