var f=function(e){
var zone = document.getElementById('wikiPreview');
if(!zone){return 0};
var whitelist;
var blacklist;
$('#wpPreview').before('<button id=wpCheckSpamListInPrev type="button">Проверка СЛ</button>');
var pushit=document.getElementById('wpCheckSpamListInPrev');
pushit.onclick=function(e){
var ch=0;
if(!whitelist){
    // Получаем наш и глобальный СЛ
    pushit.innerHTML="<span style='color:grey'>Загрузка СЛ...</span>";
	$.ajax({
        type: "GET", // request type ( GET or POST )
        url: mw.util.wikiScript('api'), // the URL to which the request is sent           
        data: { 'action':'query', 'format':'json',
                'titles':'MediaWiki:Spam-whitelist|MediaWiki:Spam-blacklist',
                'prop':'revisions','rvprop':'content'
        },
        dataType: 'json', // the type of data that you're expecting back from the server
        success: function( whl ){ //function to be called if the request succeeds
         for (var a in whl.query.pages ){
         var b = whl.query.pages[a].revisions[0]['*'];
         if (whl.query.pages[a].title=='MediaWiki:Spam-whitelist'){
           whitelist =new RegExp (b.replace(/^(?:\s*(?:\#[^\n]*)?\n)+|(?:\s*(?:\#[^\n]*)\n)*(?:\#[^\n]*)?\n*$/g,'').replace(/(?:\s*(?:\#[^\n]*)?\n)+/ig,'|'))
         }else{
           blacklist =b.replace(/^(?:\s*(?:\#[^\n]*)?\n)+|(?:\s*(?:\#[^\n]*)\n)*(?:\#[^\n]*)?\n*$/g,'').replace(/(?:\s*(?:\#[^\n]*)?\n)+/ig,'|');
           $.ajax({
        type: "GET", // request type ( GET or POST )
        url: 'http://meta.wikimedia.org/w/api.php', // the URL to which the request is sent           
        data: { 'action':'query', 'format':'json',
                'titles':'Spam_blacklist',
                'prop':'revisions','rvprop':'content'
        },
        dataType: 'json', // the type of data that you're expecting back from the server
        success: function( gbl ){ //function to be called if the request succeeds
              for (var a in gbl.query.pages ){
                var b = gbl.query.pages[a].revisions[0]['*'];
                blacklist += b.replace(/^(?:\s*(?:\#[^\n]*)?\n)+|(?:\s*(?:\#[^\n]*)\n)*(?:\#[^\n]*)?\n*$/g,'').replace(/(?:\s*(?:\#[^\n]*)?\n)+/ig,'|');
                blacklist = new RegExp(blacklist);
                pushit.innerHTML='Проверка СЛ';
                pushit.onclick(e);
              }//for
            }//function(gbl)
           });//ajax 2
         }//else
         }//for
      }//function (whl)
    });//ajax 1
    return 0
};//if( !whitelist )
for (var a in zone.getElementsByTagName('A')){
 if( blacklist.test(a.href) ){
  if( !whitelist.test(a.href) ){
   a.style.background = 'black';a.style.color='red';ch=1
  }
 }
};
if(ch){pushit.style.color='red';pushit.title='Внимание! Некоторые ссылки попадают в спам-лист!'
}else{pushit.style.color='black';pushit.title='Ссылок из спам-листа не обнаружено'};
};//pushit.onclick
};//f
if ( mw.config.get('wgNamespaceNumber') >= 0 && mw.config.get('wgUserName') ) addOnloadHook( f );