Utilizator:Gutza/verifier lite.js
Aspect
Notă: După salvare, trebuie să treceți peste cache-ul browser-ului pentru a vedea modificările.
- Mozilla, Google Chrome, Safari, Konqueror: țineți apăsat Shift în timp ce apăsați butonul Reload (sau apăsați Ctrl-Shift-R).
- Internet Explorer: apăsați Ctrl-F5.
- Opera: apăsați F5.
/**
* WikiVerifier -- a Wikipedia utility for verifying diffs between versions
* Copyright (C) 2007 Bogdan Stăncescu a.k.a. Gutza
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
var vfStr_recent_changes_title='Schimbări recente - Wikipedia';
var vfStr_watched_pages_title='Pagini urmărite - Wikipedia';
var vfStr_compare_current_label='actuală';
var vfStr_remote_url_root='http://bogdan.stancescu.ro/personal_projects/wiki_lite';
var vfStr_ignore_space_prefix='Discu%C5%A3ie';
hookEvent('load', setupVerifier);
function setupVerifier()
{
// Start by highlighting anonymous users
verifierHighlightIPs();
var loc=new String(window.location);
// FIRST, test whether we're looking at a diff page
if (
document.title!=vfStr_recent_changes_title &&
document.title!=vfStr_watched_pages_title &&
loc.indexOf('action=history')==-1
) {
if (loc.indexOf('diff=')==-1) return false;
if (loc.indexOf('diff=0')!=-1) return false;
if (loc.indexOf('title='+vfStr_ignore_space_prefix)!=-1) return false;
var fh=document.getElementsByTagName('h1');
if (fh==undefined) {
alert("Nu găsesc titlul paginii (1)! Te rog anunţă-l pe Gutza!");
return false;
}
var ppos=loc.indexOf('?');
var param=noCurid(loc.substr(ppos+1));
fh[0].innerHTML="<img src='"+vfStr_remote_url_root+"/assigner.php?param="+escape(param)+"'> "+fh[0].innerHTML;
return false;
}
// NEXT, look for links which point to "diff" pages
var links=document.getElementsByTagName('a');
var tmp="";
for(var i=0;i<links.length;i++) {
if (links[i].href.indexOf('diff=')==-1) continue;
if (links[i].href.indexOf('diff=0')!=-1) continue;
if (links[i].innerHTML==vfStr_compare_current_label) continue;
var ppos=links[i].href.indexOf('?');
var param=noCurid(links[i].href.substr(ppos+1));
if (param.indexOf('title='+vfStr_ignore_space_prefix)!=-1) continue;
var newnode=document.createElement("span");
newnode.innerHTML="<img src='"+vfStr_remote_url_root+"/verifier.php?param="+escape(param)+"'> ";
links[i].parentNode.insertBefore(newnode,links[i]);
}
}
function noCurid(str)
{
var reg=/&curid=[0-9]+/;
var ar=reg.exec(str);
if (!ar) return str;
return str.replace(ar[0],'');
}
function verifierHighlightIPs()
{
var links=document.getElementsByTagName('a');
var re_href=/^http:\/\/ro\.wikipedia\.org\/wiki\/Special:Contributions\/[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}/;
var re_html=/[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}/;
for(var i=0;i<links.length;i++) {
if (re_href.exec(links[i].href) && re_html.exec(links[i].innerHTML)) {
links[i].style.backgroundColor='#ffccdd';
links[i].style.padding='1px';
links[i].style.borderStyle='solid';
links[i].style.borderWidth='1px';
links[i].style.borderColor='#ffaabb';
}
}
}