Wikipedista:Jklamo/monobook.js
Poznámka: Po uložení musíte vyprázdnit mezipaměť vašeho prohlížeče, jinak změny neuvidíte.
$(function ($) {
var lang = mw.config.get('wgPageContentLanguage'),
links = {},
pages = [];
$("#mw-content-text")
.find("a:not(.image):not([href^=\"#\"]):not(.extiw):not(.external):not(.internal):not(.mw-redirect):not(.mw-userlink):not(.mw-usertoollinks)")
.each(function(){
try{
var title = decodeURI( this.href.split("title=")[1].split("&")[0].replace(/_/g, ' ') );
if( links[ title ] ){
links[ title ].push( this );
} else {
links[ title ] = [ this ];
pages.push( title );
}
} catch (e) { }
});
for( ; pages.length; ){
$.ajax({
url: '//www.wikidata.org/w/api.php',
data: {
'format': 'json',
'action': 'wbgetentities',
'sites': mw.config.get('wgDBname'),
'titles': pages.splice(0, 50).join("|"),
'props': 'labels',
'languages': lang
},
dataType: 'jsonp',
success: function (data) {
if (data.success) {
for (var ent = data.entities, i = -1; ent[ i ]; i--) {
var plinks = links[ ent[ i ].title ];
if( ! plinks ) { continue; }
for( var ii = plinks.length; ii-- ; ){
plinks[ ii ].style.backgroundColor = "#E0E0FF";
}
}
}
}
});
}
})