User:Rutilant/Sandbox/Tests.js
Appearance
< User:Rutilant | Sandbox
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. |
![]() | Documentation for this user script can be added at User:Rutilant/Sandbox/Tests. |
function showit(){
$("#RainFallHiddenstuff").fadeToggle(400);
}
function purgeUserpage(){
new mw.Api().postWithToken("csrf", {action: 'edit', title: 'User:RainFall', text: '', summary: "Auto purge"});
logs.innerHTML="Re-adding content in 5 secs... <br> Clearing userpage...<br>"+logs.innerHTML;
setTimeout('continuePurge()',5000);}
function continuePurge(){
new mw.Api().postWithToken("csrf", {action: 'edit', title: 'User:RainFall', text: '{{Statustop}}\n{{/StatusPage}}\n{{/Userpage}}', summary: "Auto purge"});
logs.innerHTML="Content added.<br>"+logs.innerHTML;
}
addOnloadHook(function() {
addPortletLink("p-cactions", "javascript:showit()", "Show stuffs");
});
function clearSandbox(){
value="{{Please leave this line alone (sandbox heading)}}<!--\n* Welcome to the sandbox! *\n* Please leave this part alone *\n* The page is cleared regularly *\n* Feel free to try your editing skills below *\n■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■-->";
new mw.Api().postWithToken("csrf", {action: 'edit', title: 'Wikipedia:Sandbox', text: value, summary: "Clearing the sandbox ([[WP:US|UserScript]])"});
logs.innerHTML="Sandbox cleared!<br>"+logs.innerHTML;
}
function UpdateNew(whatnew){
status(whatnew);
logs.innerHTML="Status updated - "+whatnew+"<br>"+logs.innerHTML;
}
if (location.href=="https://en.wikipedia.org/wiki/User:RainFall/Sandbox/ScriptArea"){
if (wgUserName=="RainFall"){
Texts.innerHTML="Welcome RainFall!<br><fieldset><legend>Status</legend><input id=nwstatus><input type=submit value=Update onclick=javascript:UpdateNew(nwstatus.value)></fieldset><fieldset><legend>Other</legend><input type=submit value='Clear sandbox' onclick=javscript:clearSandbox()><input type=submit value='Purge Userpage' onclick=javscript:purgeUserpage()></fieldset><fieldset><legend>Logs</legend><h6><span id=logs></h6>";
}}
////////////////////////////////////////////////////////////TIMEUPDATESCRIPT///////////////////////////////////////////////////
function edit(){
function editPages( info ) {
$.ajax({
url: mw.util.wikiScript( 'api' ),
type: 'POST',
dataType: 'json',
data: {
format: 'json',
action: 'edit',
title: info.title,
text: info.text,
summary: info.summary,
token: mw.user.tokens.get( 'editToken' )
}
})
.done (function( data ) {
if ( data && data.edit && data.edit.result && data.edit.result == 'Success' ) {
mw.notify( 'Updated' );
mw.notify( 'Re updating in 1 min' );
setTimeout('edit()',20000);
} else {
alert( 'Failed, try again.' );
}
})
.fail ( function() {
alert( 'Failed, try again.' );
});
}
editPages({
title: wgPageName,
text: "{{"+"subst:Currentdate"+"}}",
summary: 'Updating time'
});
}
addOnloadHook(function() {
if (document.editform) {
addPortletLink("p-cactions", "javascript:edits()", "run");
}
});
function edits(){
if (confirm('Replace whole content with current date and time?')){
edit();
}}