Your script has a small bug, if there are no entries in the watchlist it fails. Below is a minimal patch.
Edit: The smilies seem to be being replaced in the code block, but you can see what needs to be done there anyway.
--- memorius-ipredict-portfolio-greasemonkey-b65ad4b/ipredict-portfolio.js 2009-11-11 04:52:48.000000000 +1300
+++ patched-ipredict-portfolio.js 2009-12-01 17:26:02.000000000 +1300
@@ -308,11 +308,11 @@
var watchListTable = findTable("watch-list");
var activeOrdersBodyRows = getBodyRows(activeOrdersTable);
var stockIOwnBodyRows = getBodyRows(stockIOwnTable);
var shortedStockBodyRows = getBodyRows(shortedStockTable);
- var watchListBodyRows = getBodyRows(watchListTable);
+ var watchListBodyRows = watchListTable ? getBodyRows(watchListTable) : [ ];
var holdings = [];
var activeSellOrders = [];
var activeBuyOrders = [];
@@ -416,11 +416,12 @@
addHoldingsColumn(tr, 2, stockName, holdings, "Short");
addHoldingsAverageCostColumn(tr, 3, stockName, holdings);
addNotesColumn(tr, 11, noteKey);
}
}
-
+ if(watchListTable)
+ {
// Add columns to the Watch List table showing holdings and orders
addHeaderColumn(watchListTable, 1, "Long", "align-right");
addHeaderColumn(watchListTable, 2, "Short", "align-right");
addHeaderColumn(watchListTable, 3, "Avg. Cost", "align-center");
addHeaderColumn(watchListTable, 4, "Buy", "align-right");
@@ -438,10 +439,11 @@
addOrdersColumn(tr, 4, stockName, activeBuyOrders, holdings);
addOrdersColumn(tr, 5, stockName, activeSellOrders, holdings);
addNotesColumn(tr, 10, noteKey);
}
}
+ }
// Ensures that old notes (for cleared positions / deleted orders or watches)
// don't reappear with misleading values if a new position / order or watch
// is recreated
removeUnusedNotes(noteKeysPresentOnScreen);
]]>