Create a folder named yahoo_finance_data and add the following manifest.json and yahoo_finance_data.js files to this folder.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"manifest_version": 2, | |
"name": "Yahoo Finance Data", | |
"version": "1.0", | |
"description": "Adds additional data to Yahoo Finance quote page - Percentage Changes from Day's and 52 Week's Lows and Highs.", | |
"content_scripts": [ | |
{ | |
"matches": ["*://finance.yahoo.com/quote/*"], | |
"js": ["yahoo_finance_data.js"] | |
} | |
] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
try{ | |
doc_price = document.querySelectorAll("[data-reactid='35']")[1].innerHTML.replace(",", ""); | |
doc_day = document.querySelectorAll("[data-test='DAYS_RANGE-value']")[0].innerHTML.split("-"); | |
doc_52wk = document.querySelectorAll("[data-test='FIFTY_TWO_WK_RANGE-value']")[0].innerHTML.split("-"); | |
var pdayl = Math.round(100 * 100 * (parseFloat(doc_price) - parseFloat(doc_day[0].replace(",", "")))/parseFloat(doc_price))/100; | |
var pdayh = Math.round(100 * 100 * (parseFloat(doc_price) - parseFloat(doc_day[1].replace(",", "")))/parseFloat(doc_price))/100; | |
var p52wkl = Math.round(100 * 100 * (parseFloat(doc_price) - parseFloat(doc_52wk[0].replace(",", "")))/parseFloat(doc_price))/100; | |
var p52wkh = Math.round(100 * 100 * (parseFloat(doc_price) - parseFloat(doc_52wk[1].replace(",", "")))/parseFloat(doc_price))/100; | |
doc_day = document.querySelectorAll("[data-test='DAYS_RANGE-value']")[0]; | |
doc_52wk = document.querySelectorAll("[data-test='FIFTY_TWO_WK_RANGE-value']")[0]; | |
var textnode1 = document.createTextNode(" : " + p52wkl + "%, " + p52wkh + "%"); | |
doc_52wk.appendChild(textnode1); | |
var textnode2 = document.createTextNode(" : " + pdayl + "%, " + pdayh + "%"); | |
doc_day.appendChild(textnode2); | |
} | |
catch(err){ | |
} |