User:Bryan/Scripts/Poty anon.js
< User:Bryan | Scripts
Note: After saving, you have to bypass your browser's cache to see the changes. Internet Explorer: press Ctrl-F5, Mozilla: hold down Shift while clicking Reload (or press Ctrl-Shift-R), Opera/Konqueror: press F5, Safari: hold down Shift + Alt while clicking Reload, Chrome: hold down Shift while clicking Reload.
Documentation for this user script can be added at User:Bryan/Scripts/Poty anon. |
var msg = '';
//For anons
if (wgUserName == null) msg = msg + '<div><p style="font-size: 150%; color: red; font-weight: bold;">Did you read the instructions?</p><p>You are currently voting as an anonymous user. ';
msg = msg + 'We require anonymous users or users with less than 100 edits to identify themselves as a user from an other Wikimedia project. You can do that by adding a diff to your vote. See for example: <a href="http://en.wikipedia.org/w/index.php?title=User_talk%3ABryan_Tong_Minh&diff=109360427&oldid=106024269" class="external">diff</a>. For more information, see <a href="http://commons.wikimedia.org/wiki/Commons:Picture_of_the_Year/2006#How_to_vote">How to vote</a>. For specific instructions, please see <a href="http://commons.wikimedia.org/wiki/User:Bryan/Diffmaking">Diffmaking</a>.</p>\n';
msg = msg + '<p style="color: red; font-weight: bold;">Anonymous votes will not be considered!</p></div>';
function EditCount() {
req = sajax_init_object();
req.open('GET', '/w/api.php?action=query&list=usercontribs&uclimit=100&format=json&ucuser=' + encodeURIComponent(wgUserName), false);
req.send(null);
contribs = eval('(' + req.responseText + ')');
return contribs['query']['usercontribs'].length;
}
if (wgPageName == "Commons:Picture_of_the_Year/2006/Voting_phase_2") {
addOnloadHook(function () {
if (wgUserName != null) { if (EditCount() < 100) {
msg = '<div><p style="color: red; font-size: 150%; font-weight: bold;">You have less than 100 edits!</p><p>' + msg;
} else { return; }}
var p = document.getElementById("wikiPreview");
if (p) {
if (!p.innerHTML) p.innerHTML = msg; //Only add message in edit form
}
});
}