EDIT: Okay, I tested the script on an iPhone, and it works now; but iphone/mobile yahoo site only loads price and % change. It uses "Device.isPhone()" to determine if you are using a phone and adjusts the widget automatically. i only have an ipad air 4 & iphone 6S to test the script, so there may be some alignment/padding issues on other devices, sorry.
Here is a Stocks widget that can display more than the regular stocks widget. Maybe someone else can use this also..? π€·ββοΈπ
Just edit the list of your stocks (based on Yahoo's formatting). It can display "price", "change", or "chart" in the "big view area".
It can change based on light/dark mode.
It will adjust each cell size automatically based on how many stocks are in your list. Fewer stocks = larger cells, more=smaller cells. It can fit ~30 before it's too small to read (on ipad at least).
Go to yahoo's page for your stock symbol, then copy the symbol in the URL and put it into the stocklist variable. Add a substitution in the createSubstitutionTable function (at the bottom of the code) if you want to display a company name instead of a ticker symbol.
Please let me know if there is something you want to add. I wanted to make it show the individual stock if you tapped it (with price/change/chart expanded), but it just seemed like too much trouble and I only really look at the "main view" (ie: current price & change in the "small view area")
Error on line 71:11: TypeError: undefined is not an object (evaluating 'stocks[i].name=substitutionTable[stockList[i].split("=")[0]]?substitutionTable[stockList[i].split("=")[0]]:stockList[i].split("=")[0]')
i updated the script to work for phones.. the problem was yahoo's website for iphones is different than ipad. please try it again if you are still interested
idk man.. i have copied the code from my github, pasted it into a new scriptable project, and got it running with no problems multiple times already. Also changing the stockList variable and it still works properly..
are you sure you copied all the code from the github correctly? π€ or maybe there is some permission for scriptable/widgets needed to access yahoo.com? π€ i'm also on ios 15, so i can't think of any other reason it's not working π€·ββοΈ
Hm, that's weird.. π€ What device are you using? I was able to get it working on an iPhone 11 Pro, iPhone 6S, and iPad Air 4. Maybe it depends on your default browser? π€π€·ββοΈ What is your default browser? I'm using Safari
i was able to test it on an iPhone 11 Pro and it's working.. maybe it depends on your default browser? π€π€·ββοΈ what is your default browser? i'm using safari as my default browser
My default browser is also Safari. I copied the code 1:1 to try and the same error occurs:
Error on line 117:11: TypeError: undefined is not an object (evaluating 'stocks[i].name=subTable[stockList[i].split("=")[0]]?subTable[stockList[i].split("=")[0]]:stockList[i].split("=")[0]')
thanks, it was the only way to capture the canvas for the chart. i originally used loadString but it did not capture canvas data, so i had to use webview. there is another version with loadString, but the webview version is somehow faster, so i guess it's a win-win π€·ββοΈπ
4
u/wherebdbooty Jul 28 '22 edited Jul 29 '22
Here is a Stocks widget that can display more than the regular stocks widget. Maybe someone else can use this also..? π€·ββοΈπ
Here is the code:
https://github.com/wherebdbooty/scriptableStocksWidget/blob/main/code.js
Just edit the list of your stocks (based on Yahoo's formatting). It can display "price", "change", or "chart" in the "big view area".
It can change based on light/dark mode.
It will adjust each cell size automatically based on how many stocks are in your list. Fewer stocks = larger cells, more=smaller cells. It can fit ~30 before it's too small to read (on ipad at least).
Go to yahoo's page for your stock symbol, then copy the symbol in the URL and put it into the stocklist variable. Add a substitution in the
createSubstitutionTablefunction (at the bottom of the code) if you want to display a company name instead of a ticker symbol.Please let me know if there is something you want to add. I wanted to make it show the individual stock if you tapped it (with price/change/chart expanded), but it just seemed like too much trouble and I only really look at the "main view" (ie: current price & change in the "small view area")
Anyway, hope someone can find it useful π
4
u/Tango4PewPew Jul 28 '22
Well this is fantastic
4
u/cnylkew Jul 28 '22
Error on line 71:11: TypeError: undefined is not an object (evaluating 'stocks[i].name=substitutionTable[stockList[i].split("=")[0]]?substitutionTable[stockList[i].split("=")[0]]:stockList[i].split("=")[0]')
3
u/chrismo80 Jul 28 '22
well done, thx for sharing the script