User:R3m0t/pplmark.js
Appearance
Code that you insert on this page could contain malicious content capable of compromising your account. If you import a script from another page with "importScript", "mw.loader.load", "iusc", or "lusc", take note that this causes you to dynamically load a remote script, which could be changed by others. Editors are responsible for all edits and actions they perform, including by scripts. User scripts are not centrally supported and may malfunction or become inoperable due to software changes. A guide to help you find broken scripts is available. If you are unsure whether code you are adding to this page is safe, you can ask at the appropriate village pump. This code will be executed when previewing this page. |
Documentation for this user script can be added at User:R3m0t/pplmark. |
function in_array(the_needle, the_haystack){
var the_hay = the_haystack.toString();
if(the_hay == ''){
return false;
}
var the_pattern = new RegExp(the_needle, 'g');
var matched = the_pattern.test(the_haystack);
return matched;
}
function markpeople() {
Links = document.getElementsByTagName('a');
users = 0; dryRun = false;
for (var i = 0; i < Links.length; i++) {
link = Links[i];
if (!link.href) { continue; }
if (link.title == 'View the user page [alt-c]') { continue; }
addr = link.href;
if (!/http:\/\/en.wikipedia.org\/wiki\/User:[^/#]+$/.test(addr) && !/http:\/\/en.wikipedia.org\/w\/index.php\?title=Special:Contributions&target=/.test(addr) && !/http:\/\/en.wikipedia.org\/w\/index.php\?title=User:[^/]*&action=edit/.test(addr)) { continue; } //not user page
if (dryRun) { link.setAttribute('onMouseover', "javascript:return marklink(this);"); continue; }
user = addr.replace(/http:\/\/en.wikipedia.org\/wiki\/User:/, '');
user = user.replace(/http:\/\/en.wikipedia.org\/w\/index.php\?title=Special:Contributions&target=/, '');
user = user.replace(/http:\/\/en.wikipedia.org\/w\/index.php\?title=User:/, '');
user = user.replace(/&.*$/, '');
user = user.replace(/_/, ' ');
themark = document.createElement('sub');
usertype = '?'; themark.style.cssText = 'color: #000; font-size: small';
if (MP_adminslist.indexOf('\n' + user + '\n') != -1) { usertype = 'a'; themark.style.cssText = 'color: #090'; }
else {
users++;
if (MP_whitelist.indexOf('\n' + user + '\n') != -1) { usertype = 'w'; themark.style.cssText = 'color: #066'; }
if (MP_blacklist.indexOf('\n' + user + '\n') != -1) { usertype = '!'; themark.style.cssText = 'color: #C00'; }
if (/^[0-9.]+$/.test(user)) { if (MP_blacklistIP.indexOf('\n' + user + '\n') != -1) { usertype = '!'; themark.style.cssText = 'color: #C00'; } }
}
themark.appendChild(document.createTextNode(usertype));
link.parentNode.insertBefore(themark, link);
if (users == 100) { dryRun = true; }
}
}
function marklink(link) {
if (!link.href) { alert('o'); return; }
if (link.title == 'View the user page [alt-c]') { alert('oddd'); return; }
addr = link.href;
if (!/http:\/\/en.wikipedia.org\/wiki\/User:[^/#]+$/.test(addr) && !/http:\/\/en.wikipedia.org\/w\/index.php\?title=Special:Contributions&target=/.test(addr) && !/http:\/\/en.wikipedia.org\/w\/index.php\?title=User:[^/]*&action=edit/.test(addr)) { alert('oSS'); return; } //not user page
users++;
user = addr.replace(/http:\/\/en.wikipedia.org\/wiki\/User:/, '');
user = user.replace(/http:\/\/en.wikipedia.org\/w\/index.php\?title=Special:Contributions&target=/, '');
user = user.replace(/http:\/\/en.wikipedia.org\/w\/index.php\?title=User:/, '');
user = user.replace(/&.*$/, '');
user = user.replace(/_/, ' ');
themark = document.createElement('sub');
usertype = '?'; themark.style.cssText = 'color: #000; font-size: small';
if (MP_adminslist.indexOf('\n' + user + '\n') != -1) { usertype = 'a'; themark.style.cssText = 'color: #090'; }
else {
if (MP_whitelist.indexOf('\n' + user + '\n') != -1) { usertype = 'w'; themark.style.cssText = 'color: #066'; }
if (MP_blacklist.indexOf('\n' + user + '\n') != -1) { usertype = '!'; themark.style.cssText = 'color: #C00'; }
if (/^[0-9.]+$/.test(user)) { if (MP_blacklistIP.indexOf('\n' + user + '\n') != -1) { usertype = '!'; themark.style.cssText = 'color: #C00'; } }
}
themark.appendChild(document.createTextNode(usertype));
link.parentNode.insertBefore(themark, link);
link.setAttribute('onMouseover', "javascript:return true;"); //don't do anything on next mouseover
return true;
}
document.write('<script type="text/javascript"' +
'src="http://en.wikipedia.org/w/index.php?title=User:R3m0t/pplmark.data.js' +
'&action=raw&ctype=text/javascript&dontcountme=s&maxage=86400"></script>');
if (window.addEventListener) window.addEventListener("load",markpeople,false);
else if (window.attachEvent) window.attachEvent("onload",markpeople);