I work with open source and free software technologies and
specialise in C, scripting and PHP.
I live with my partner, Tina, in the New Forest, England.
I use iii.co.uk for my investments, and have been eternally miffed
by the way they reserve the "option" of sensibly laying out their
portfolio page for paying users, leaving the rest of us to look at
a layout that breaks up the information over 2 lines. Stupid and
cheap, if you ask me. So I wrote a Greasemonkey script to sort it
out.
It changes the normal layout:
to this:
Since their HTML is horrible - embedded tables in tables, no classes
on most of the elements, etc. - it's a hack. Doing it properly with
XSLT is out of the question. So if they change their HTML it'll break.
But hopefully it'll get anyone who knows what they're doing most of
the way to a proper solution.
// ==UserScript==
// @name iii_rearrange
// @namespace http://www.derekfountain.org
// @include http://www.iii.co.uk/*
// ==/UserScript==
var equityLines =
document.evaluate("//table[contains(@id, 'streamingTable_')]/tbody/tr",
document,
null,
XPathResult.ANY_TYPE,
null);
var deleteIndex = 0;
var deleteStack = [];
var equityNameIndex = 0;
var equityNames = [];
var equityBidIndex = 0;
var equityBids = [];
var equityLine = equityLines.iterateNext();
while (equityLine) {
var nameLines =
document.evaluate("td/table[@width='100%']/tbody/tr/td/a",
equityLine,
null,
XPathResult.ANY_TYPE,
null);
var nameLine = nameLines.iterateNext();
if ( nameLine != null ) {
equityNames[equityNameIndex++] = nameLine.textContent;
deleteStack[deleteIndex++] = equityLine;
var detailRow = equityLine.nextSibling.nextSibling;
var bidCells =
document.evaluate("td/span[@class='symbol-val-bid']",
detailRow,
null,
XPathResult.ANY_TYPE,
null);
equityBids[equityBidIndex++] = bidCells.iterateNext();
}
equityLine = equityLines.iterateNext();
}
for (var i=0; i<equityNames.length; i++) {
equityBids[i].textContent = equityNames[i];
equityBids[i].setAttribute("style", "font-weight: bold");
}
for (var i=0; i<deleteStack.length; i++) {
deleteStack[i].parentNode.removeChild(deleteStack[i]);
}
Site and content Copyright 2005 Derek Fountain -
All Rights Reserved