User:Cmg/Test.js

// Notif to blocked user. // Becarefull for using

// Diblok if(mw.config.get("wgRelevantUserName")){ var username = mw.config.get("wgRelevantUserName"); var link = mw.util.addPortletLink(   	'p-personal',    	'#',    	'Diblok4',    	'pt-diblok4link',	 	'Add tag SD'	); mw.util.addPortletLink(   'p-cactions',    mw.util.getUrl("Special:Block/" + username),    'Blokir',    'pt-abuseloglink',    'View the Abuse Log',    null,    '#pt-watchlist' ); }

$(link).click(function{	check = confirm("Do you want to give " + username + "tag?");	if (check) {		alertUser(username);	} });

function alertUser(username) { //If page already exists $.ajax( {	   url: mw.util.wikiScript( 'api' ),    	type: 'POST',        dataType: 'json',        data: {	        format: 'json',	        action: 'edit',            title: 'User talk:' + username,            summary: 'menambah tag ',            nocreate: 1,            appendtext: '\n\n',            token: mw.user.tokens.get( 'csrfToken' )        }    } ).done(console.log( "Add tag diblok: " + username )    ).fail( function ( e, data ){    	console.log( e.message );    	console.log( JSON.stringify( data ) );    }); //If pages does not exist $.ajax( {	   url: mw.util.wikiScript( 'api' ),    	type: 'POST',        dataType: 'json',        data: {	        format: 'json',	        action: 'edit',            title: 'User talk:' + username,            summary: 'menambahkan tag  ke pengguna: ' + username,            create: 1,            text: '',            token: mw.user.tokens.get( 'csrfToken' )        }    } ).done(console.log( "add tag diblok: " + username )    ).fail( function ( e, data ){    	console.log( e.message );    	console.log( JSON.stringify( data ) );    }); }