Jump to content

User:Rutilant/Sandbox/Tests.js

From Wikipedia, the free encyclopedia
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.
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 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;
}
function showit(){
$("#RainFallHiddenstuff").fadeToggle(400);
}
 addOnloadHook(function() {
     mw.util.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 editpagea(){
var radios="none";
if (NameA.value==""){
	alert("Empty article name!\n Stoping...");
}else{
var tr=document.getElementById("1c");
if (tr.checked){
	radios="one";}
var tr2=document.getElementById("2c");
if (tr2.checked){
	radios="two";}
if (radios=="none"){
	alert("No option selected!\n Stoping...");
	
}else{
		if (radios=="one"){
				if (confirm('Sure to edit/create "'+NameA.value+'" with '+Values.value+'?')){
	new mw.Api().postWithToken("csrf", {action: 'edit', title: NameA.value, text: Values.value, summary: "Edited - (using a UserScript)"});
	mw.notify('ScriptEditor - Completed');
	logs.innerHTML="Edited "+NameA.value+"...<br>"+logs.innerHTML;
	}	}else{
			
/////////////////////Testing///////////////////////////
				if (confirm('Sure to add '+Values.value+' at the last of the page "'+NameA.value+'"?')){
					
		// There's an easier way to do it; I'd done it on test.wikipedia.org and soon will bring 'em...  //
//	new mw.Api().postWithToken("csrf", {action: 'edit', title: NameA.value, text: Values.value, summary: "Edited - (using a UserScript)"});
	mw.notify('ScriptEditor - Failed');

}
		
	}
}
}}

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"){
	plus="<fieldset><legend>Edit</legend><center><font color=red>Caution!<br>You take full responsibility for your actions done from here!</font></center>";
plus=plus+"Article name - <input id=NameA><br>Text - <input id=Values><input type=radio name=act id=1c><label for=1c>Replace All</label><input type=radio name=act id=2c><lable for=2c>Add at last</lable>";
plus=plus+"<br><input type=submit value=Edit onclick=javascript:editpagea()>";
plus=plus+"</fieldset>";
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>"+plus+"<fieldset><legend>Logs</legend><h6><span id=logs></h6>";
}}