Удзельнік:Zedlik/deletereason.js
Заўвага: каб пабачыць зьмены пасьля публікацыі, Вам можа спатрэбіцца ачысьціць кэш Вашага браўзэра.
- Firefox / Safari: трымайце Shift і націсьніце Reload, ці націсьніце Ctrl-F5 ці Ctrl-R (⌘-R на Mac)
- Google Chrome: націсьніце Ctrl-Shift-R (⌘-Shift-R на Mac)
- Internet Explorer / Edge: трымайце Ctrl і націсьніце Refresh, ці націсьніце Ctrl-F5
- Opera: націсьніце Ctrl-F5.
function getElementsByClassNameA(classname, node) {
if(!node) node = document.getElementsByTagName("body")[0];
var a = [];
var re = new RegExp('\\b' + classname + '\\b');
var els = node.getElementsByTagName("*");
for(var i=0,j=els.length; i<j; i++)
if(re.test(els[i].className))a.push(els[i]);
return a;
}
function URLDecodeA(utftext)
{
var string = "";
var i = 0;
var c = c1 = c2 = 0;
while ( i < utftext.length ) {
c = utftext.charCodeAt(i);
if (c < 128) {
string += String.fromCharCode(c);
i++;
}
else if((c > 191) && (c < 224)) {
c2 = utftext.charCodeAt(i+1);
string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
i += 2;
}
else {
c2 = utftext.charCodeAt(i+1);
c3 = utftext.charCodeAt(i+2);
string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
i += 3;
}
}
return string;
}
$(function() {
var reason = "";
if (document.getElementById('ca-delete') && document.getElementById('delete-reason')) {
reason = document.getElementById('delete-reason').innerHTML;
}
else if (document.getElementById('contentSub')) {
var el = getElementsByClassNameA('redirectText', document);
if (el && el[0]) {
var redirectLink = el[0].getElementsByTagName('A')[0];
var linkURL = redirectLink.href;
linkURL = linkURL.replace("https://secure.wikimedia.org/wikipedia/be-x-old/wiki/", "");
linkURL = linkURL.replace("http://be-x-old.wikipedia.org/wiki/", "");
linkURL = linkURL.replace("https://be-x-old.wikipedia.org/wiki/", "");
reason = "Памылка ў назьве; старонка перанесеная ў [[" + URLDecodeA(linkURL) + "]]";
}
}
if (reason) {
var link = document.getElementById('ca-delete').getElementsByTagName('A')[0];
link.setAttribute('href', link.getAttribute('href') + '&wpReason=' + reason);
}
});