User:Ricordisamoa/DashesInSignature.js
Jump to navigation
Jump to search
Note: After publishing, you may have to bypass your browser's cache to see the changes.
- Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
- Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
- Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5.
/* <nowiki>
*
* DashesInSignature.js by [[User:Ricordisamoa]]
* tells whether a user has one or more dashes in his/her signature (nickname)
*
*/
$.get(
mw.util.wikiScript("api"),
{
action:"parse",
prop:"text",
format:"json",
title:"Wikidata:Requests for deletions",
text:mw.user.options.values.nickname
},
function(data){
var text=$("<div>").html(data.parse.text["*"]).text().replace(/\n+/g,"");// parse the rendered text from the HTML code
var preAlert="Your signature/nickname renders as the following text:\n"+text+"\n";
if(text.substr(0,2)==="--") alert(preAlert+"You have two or more dashes in your signature.");
else if(text.substr(0,1)==="-") alert(preAlert+"You have one dash in your signature.");
else alert(preAlert+"You don't have dashes in your signature.");
}
);
// </nowiki>