From Wikipedia, the free encyclopedia
Now available for IE7 users!!
This is a simple script that adds an extra link to any page that contains anon IPs' that lead to a WHOIS search, making things a lot quicker when you need to work out who someone is.
There are now two versions of this script available. One for Mozilla-based browsers and one for IE7 (probably works on IE6 using gm4ie, but I haven't tested it). It should however work on all Wiki sites, and on all pages.
If you would like to install it, you can either copy and paste the code below, or get it from;
[edit] IE7 (requires IE7 Pro. Get it here)
http://www.iescripts.org/view-scripts-189p1.htm
[edit] Mozilla-based browsers (requires Greasemonkey)
http://userscripts.org/scripts/show/13393.
(Note - if you use the code from below, make sure the last edit to this page was by Arendedwinter, as someone may have altered it. If in doubt, use the link provided above this notice and install the script directly.)
- Current Version 1.4 - Changed IP regex to match on octets of 0.
Version 1.3 - Filters out external links. I noticed that certain articles contain text similar to IPs' (eg: anything that has an Enzyme Commission code). If the href doesn't link to Wikipedia, we don't want a WHOIS for it.
version 1.2 - Fixed Special Contribs links (when text was shown as textContent)
Version 1.1 - Fixed a bug with User talk links. Shouldn't include text in URL now.
IE7 Code
// ==UserScript==
// @name Wiki WHOIS linker
// @author Arendedwinter
// @include *.wikipedia.org/*
// @description Creates a link next to each anon IP for easy WHOIS searches. Should work on all language Wikis
// ==/UserScript==
(function(){
/* Feel free to try and readd this if you want it. I couldn't get it to work in IE
// NOTIFICATION TEXT : REMOVE IF YOU DON'T WANT IT
var Notify = document.createElement("p");
var txt = "WHOIS lookup enabled";
var newT = document.createTextNode(txt);
Notify.appendChild(newT);
Notify.setAttribute("style", "position: fixed; z-index: 99; left: 0; bottom: 0; font-size: 7pt; background-color: #E9E9E9; color: #000000;");
var AppendSwitcher = document.getElementsByTagName('body')[0];
AppendSwitcher.appendChild(Notify);
*/
//--DON'T REMOVE BELOW HERE--
//SET SOME VARIABLES
var Link = document.getElementsByTagName('a');
var IPFilter = /^.*([0-9]{0,2})+\.([0-9]{0,2})+\.([0-9]{0,2})+\.([0-9]{0,2})+$/;
var ExtraLinkURL = 'http://ip-lookup.net/index.php?';
var ExtraLinkTarget = '_blank';
var ExtraLinkTitle = 'WHOIS this IP';
var ExtraLinkText = ' <font size="1"><font color="black">(</font><u><font color="#CC0000">WHOIS</font></u><font color="black">)</font></font>';
//DO STUFF!
for (var i = 0; i < Link.length; i++){
//Filter out external links (eg: Enzyme Commission codes are the same format as an IP)
var InWikipedia = /wikipedia/.test(Link[i].href);
if (InWikipedia == true){
if (Link[i].innerText.match(IPFilter)){
ExtraLinkSpan = document.createElement('span');
if (Link[i].innerText.match(/\:/g)){
var NewLink = Link[i].innerText.split(/\:/g);
NewLink = NewLink[1];
if (NewLink.match(/\//g)){
var NewLink = Link[i].innerText.split(/\//g);
NewLink = NewLink[1];
}
}else{
var NewLink = Link[i].innerText;
}
ExtraLink = '<a href="' + ExtraLinkURL + NewLink + '" target="' + ExtraLinkTarget + '" title="' + ExtraLinkTitle + '">' + ' ' + ExtraLinkText + '</a>';
ExtraLinkSpan.innerHTML = ExtraLink;
Link[i].parentNode.insertBefore(ExtraLinkSpan, Link[i].nextSibling);
}
}
}
})();
|
|
|
Mozilla-based code
// ==UserScript==
// @name Wiki WHOIS linker
// @author Arendedwinter
// @namespace (none)
// @include *.wikipedia.org/*
// @description Creates a link next to each anon IP for easy WHOIS searches. Should work on all language Wikis
// ==/UserScript==
// NOTIFICATION TEXT : REMOVE IF YOU DON'T WANT IT
var Notify = document.createElement("p");
var txt = "WHOIS lookup enabled";
var newT = document.createTextNode(txt);
Notify.appendChild(newT);
Notify.setAttribute("style", "position: fixed; z-index: 99; left: 0; bottom: 0; font-size: 7pt; background-color: #E9E9E9; color: #000000;");
var AppendSwitcher = document.getElementsByTagName('body')[0];
AppendSwitcher.appendChild(Notify);
//--DON'T REMOVE BELOW HERE--
//SET SOME VARIABLES
var Link = document.getElementsByTagName('a');
var IPFilter = /^.*([0-9]{0,2})+\.([0-9]{0,2})+\.([0-9]{0,2})+\.([0-9]{0,2})+$/;
var ExtraLinkURL = 'http://ip-lookup.net/index.php?';
var ExtraLinkTarget = '_blank';
var ExtraLinkTitle = 'WHOIS this IP';
var ExtraLinkText = ' <font size="1"><font color="black">(</font><u><font color="#CC0000">WHOIS</font></u><font color="black">)</font></font>';
//DO STUFF!
//Yes I'm aware this can be written better...
for (var i = 0; i < Link.length; i++){
//Filter out external links (eg: Enzyme Commission codes are the same format as an IP)
var InWikipedia = /wikipedia/.test(Link[i].href);
if (InWikipedia == true){
if (Link[i].textContent.match(IPFilter)){
ExtraLinkSpan = document.createElement('span');
if (Link[i].textContent.match(/\:/g)){
var NewLink = Link[i].textContent.split(/\:/g);
NewLink = NewLink[1];
if (NewLink.match(/\//g)){
var NewLink = Link[i].textContent.split(/\//g);
NewLink = NewLink[1];
}
}else{
var NewLink = Link[i].textContent;
}
ExtraLink = '<a href="' + ExtraLinkURL + NewLink + '" target="' + ExtraLinkTarget + '" title="' + ExtraLinkTitle + '">' + ExtraLinkText + '</a>';
ExtraLinkSpan.innerHTML = ExtraLink;
Link[i].parentNode.insertBefore(ExtraLinkSpan, Link[i].nextSibling);
}
}
}
|
|
|