Jump to content

User:Rutilant/Sandbox/Tests.js

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Rutilant (talk | contribs) at 04:08, 3 September 2016 (cleaning monobook;). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
(diff) ← Previous revision | Latest revision (diff) | Newer revision → (diff)
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 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();
}}