User:つがる/UISU.js
Appearance
< User:つがる
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:つがる/UISU. |
//modified from [[User:Abelmoschus Esculentus/UISU.js]]
//<nowiki>
$(document).ready(uisu_init);
function uisu_init()
{
if(mw.config.get("wgCanonicalNamespace") == "User" || mw.config.get("wgCanonicalNamespace") == "User_talk")
{
mw.util.addPortletLink("p-cactions", "#", "Username Shared", "ca-uisu", null, null);
$('#ca-uisu').click(function() {
var message = "[[File:Information.svg|25px|alt=Information icon]] Hi there and [[WP:WELCOME|Welcome to Wikipedia]]! I noticed that your username '[[User:{{<includeonly>safesubst:</includeonly>BASEPAGENAME}}|{{<includeonly>safesubst:</includeonly>BASEPAGENAME}}]]' may imply shared use, please note that Wikipedia accounts can only be used by one person,and promotional editing is not acceptable regardless of the username you choose. If you think I made a mistake, please leave a note explaining why, otherwise you may read about how to request a username change [[WP:CHANGEUSERNAME|here.]] Thanks! ~~~~";
var data = {
format : 'json',
action : 'edit',
minor : false,
title : uisu_getURL(),
text : message,
section : 'new',
sectiontitle : 'Shared Username Warning',
watchlist : 'nochange',
token : mw.user.tokens.get('editToken')
};
$.ajax({
url : mw.util.wikiScript('api'),
type : 'POST',
dataType : 'json',
data : data,
success : function(data) {
if(data && data.edit && data.edit.result && data.edit.result === 'Success') {
window.location.href = "https://en.wikipedia.org/wiki/User_talk:" + mw.config.get("wgTitle");
} else {
$("#"+id).attr("title", 'There was an error requesting the page edit. Code: ' + data.error.code + '": ' + data.error.info).tipsy("show");
}
},
error : function() {
$("#"+id).attr("title", 'There was an error using AJAX to edit the page.').tipsy("show");
}
});
});
}
}
function uisu_getURL()
{
var url;
var slashLocation = mw.config.get("wgTitle").indexOf("/");
if(slashLocation > 0)
{
url = "User_talk:" + mw.config.get("wgTitle").substring(0, mw.config.get("wgTitle").indexOf("/"));
}
else
{
url = "User_talk:" + mw.config.get("wgTitle");
}
return url;
}
//</nowiki>