User:Dominic/common.js: Difference between revisions
Jump to navigation
Jump to search
Content deleted Content added
Created page with "// Diblok if(mw.config.get("wgRelevantUserName")){ var username = mw.config.get("wgRelevantUserName"); var link = mw.util.addPortletLink( 'p-personal', '#',..." |
(No difference)
|
Latest revision as of 04:22, 16 May 2018
// Diblok
if(mw.config.get("wgRelevantUserName")){
var username = mw.config.get("wgRelevantUserName");
var link = mw.util.addPortletLink(
'p-personal',
'#',
'Diblok4',
'pt-diblok4link',
'Add tag diblok4'
);
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: 'Add Welcome User',
nocreate: 1,
appendtext: '\n\n{{subst:' + 'Diblok4}}',
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: 'Welcome to User: ' + username,
create: 1,
text: '{{subst:' + 'welcome}}',
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 ) );
});
}