Rommel
04-29-2007, 06:51 AM
I have this script that works fine in Firefox but now I need it to work in IE and I am having the hardest time trying to make it work, ultra newb I am. It is meant to work on a page like THIS (http://powdod.hlstatsx.com/ingame.php), reading the ID number at the end of a url and adding the specified text if it matches.
The script (barebones, it's long I cut it to two, it is repetitious so if you notice a way to make it more efficient I'm all ears.)
var links
links = document.evaluate('//a[@href]',document,null,XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,null);
var re_hello = new RegExp("=1$");
var re_doom = new RegExp("=2$");
for (var i = 0; i < links.snapshotLength; i++) {
a = links.snapshotItem(i);
if(a.href.match(re_hello)) {
span = document.createElement('span') ;
a.parentNode.insertBefore(span, a.nextSibling) ;
span.innerHTML = " - Hello World"
}
if(a.href.match(re_doom)) {
span = document.createElement('span') ;
a.parentNode.insertBefore(span, a.nextSibling) ;
span.innerHTML = " - Doom"
}
}
The script (barebones, it's long I cut it to two, it is repetitious so if you notice a way to make it more efficient I'm all ears.)
var links
links = document.evaluate('//a[@href]',document,null,XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,null);
var re_hello = new RegExp("=1$");
var re_doom = new RegExp("=2$");
for (var i = 0; i < links.snapshotLength; i++) {
a = links.snapshotItem(i);
if(a.href.match(re_hello)) {
span = document.createElement('span') ;
a.parentNode.insertBefore(span, a.nextSibling) ;
span.innerHTML = " - Hello World"
}
if(a.href.match(re_doom)) {
span = document.createElement('span') ;
a.parentNode.insertBefore(span, a.nextSibling) ;
span.innerHTML = " - Doom"
}
}