Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- DBF EXCHANGE WEEK PERCENT CHANGE IN STOCK PRICE EXTRACTOR AND CALCULATOR
- This is the content of a bookmarklet that will see if you are on the correct
- page for stock retrieval, and either extracts two closing prices and determines
- the week's percent change if you're on the correct page, or redirects you to the
- correct page for the weekly stock prices of the market and company of your
- choice. For an unknown reason, the bookmarklet cannot both redirect you and
- extract closing price data despite being coded to do both.
- To use it, create a new bookmark, copy the code below into the "location" field
- of the bookmark, and then click that bookmark whenever you want to get the
- week's percent change of closing price from the Google Finance site.
- */
- javascript:var%20defaultExchange%20=%20"NYSE:LMT";%20var%20prevCloseString%20=%20"Last%20week's%20closing%20price%20is:%20%20";%20var%20nextCloseString%20=%20"This%20week's%20closing%20price%20is:%20%20";%20var%20changeString%20=%20"Percent%20change:%20%20";%20var%20resultString;%20var%20priceDiv;%20var%20priceTable;%20var%20prevClose,%20nextClose;%20var%20change,%20percentChange;%20%20function%20getPrices()%20{%20priceDiv%20=%20document.getElementById("prices");%20priceTable%20=%20priceDiv.childNodes[1];%20%20prevClose%20=%20priceTable.rows[2].cells[4].innerHTML;%20nextClose%20=%20priceTable.rows[1].cells[4].innerHTML;%20change%20=%20(nextClose%20-%20prevClose)%20/%20prevClose;%20percentChange%20=%20100%20*%20change;%20%20resultString%20=%20percentChange.toFixed(2);%20%20alert(prevCloseString%20+%20prevClose%20+%20"\n"%20+%20nextCloseString%20+%20nextClose%20+%20"\n\n"%20+%20changeString%20+%20resultString);%20}%20%20if(window.location.hostname%20!=%20"www.google.com"%20||%20window.location.pathname%20!=%20"/finance/historical")%20{%20var%20exchange%20=%20prompt("Are%20you%20sure%20you're%20on%20the%20right%20page?\nType%20your%20desired%20market%20and%20company:%20",%20defaultExchange);%20window.location.assign("http://www.google.com/finance/historical?q="%20+%20exchange%20+%20"&histperiod=weekly&num=2");%20}%20%20getPrices();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement