Skip to content

Instantly share code, notes, and snippets.

@RichardHan
Created June 20, 2017 00:36
Show Gist options
  • Save RichardHan/352f1ab78b586f2b4b9d3a5d0712e556 to your computer and use it in GitHub Desktop.
Save RichardHan/352f1ab78b586f2b4b9d3a5d0712e556 to your computer and use it in GitHub Desktop.
histock.tw dividend - warrant helper
/*
The script only effect on https://histock.tw/stock/dividend.aspx
add warrant link below the financial link.
*/
for (r = 0; r < document.getElementsByClassName('tb-msci').length; r++) {
var table = document.getElementsByClassName('tb-msci')[r];
for (i = 0; i < table.rows.length; i++) {
if (table.rows[i].cells[2]) {
//before https://histock.tw/stock/financial.aspx?no=0056&t=2
//after https://histock.tw/stock/warrant.aspx?no=0056
var rawHtml = table.rows[i].cells[2].innerHTML;
var warrant = rawHtml.replace('financial', 'warrant');
var ind = warrant.indexOf('>') + 1;
warrant = warrant.slice(0, ind) + "權證" + warrant.slice(ind);
table.rows[i].cells[2].innerHTML = rawHtml + "<br/>" + warrant;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment