Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.
Just wondering if the Stocks widget could be fixed using the method used in the iOS StocksX tweak.
I don't know, I haven't looked at the StocksX source code. I'm not going to have time to look into this I'm afraid.

lso curious if the rest of the internet-requiring widgets could be fixed by fixing the urls being requested
This would only work if the new URL provided data in the exact same format as the original URL. Because this doesn't happen, fixing widgets generally requires actually rewriting all of the data parsing code, not just changing the URL.
 
  • Like
Reactions: GalacticStag
I don't know, I haven't looked at the StocksX source code. I'm not going to have time to look into this I'm afraid.


This would only work if the new URL provided data in the exact same format as the original URL. Because this doesn't happen, fixing widgets generally requires actually rewriting all of the data parsing code, not just changing the URL.
the original widget seems to be using a plain old yahoo finance url
the stocksx tweak also uses yahoo finance, not with a url, but rather using the yfinance module in python, which connects to yahoo finance through python
 
ok so i did some modifications on the stocks parser javascript file, and a developer of stocksx is hosting an instance at weatherx.yzu.moe/dgw. i modified the script to use that url. i also modified some other things in the xml request to spoof an ios 4.1 device. however, it is still not working and charles is giving me 500 internal server error. i went into the stocks app on my ios 4.1 ipod touch and the stocks works just fine. the exclamation points in charles are connections from the mac. others are connections from the pod. i even added some charles rewrite rules to spoof the headers for the request, but still no luck. the request for the mac and the ipod are pretty much identical, so i dont know why im not getting a response from the server on a mac. attached below is my charles session file and my modified parser js. i am making a little bit of progress, however. instead of infinitely spinning, the widget now tells me that there was an error retrieving the chart.

EDIT: the charles file is for weather.skyglow.es:5002/dgw which is another instance, i set up a rewrite rule to redirect yzu.moe to skyglow.es, but both are basically identical, with some minor differences.
 

Attachments

  • StocksXSkyglow.chls.zip
    2.7 KB · Views: 19
  • stocksParser.js.zip
    4 KB · Views: 18
guess what? i managed to get the stocks widget (chart and adding new stocks only for now) working! i have attached my stocksParser.js below, it should work. move the js into /system/library/widgetresources/.parsers. enjoy!
 

Attachments

  • Screen Shot 2025-04-23 at 15.55.51.png
    Screen Shot 2025-04-23 at 15.55.51.png
    84.1 KB · Views: 29
  • stocksParser Fixed.js.zip
    4 KB · Views: 22
  • Love
Reactions: Wowfunhappy
guess what? i managed to get the stocks widget (chart only for now) working! i have attached my stocksParser.js below, it should work. move the js into /system/library/widgetresources/.parsers. enjoy!
Awesome work!!! You should be able to edit the path to stocksParser.js inside index.html so that it looks for a local copy inside the widget, and no one has to edit /System/.
 
Awesome work!!! You should be able to edit the path to stocksParser.js inside index.html so that it looks for a local copy inside the widget, and no one has to edit /System/.
idk if you saw but i just edited my message with a new js, this time including adding new symbols functionality (i accidentally put in getchart instead of getsymbol, we all make mistakes)
 
may i ask, how do i edit the path lol
edit: nvm i figured it out
Sorry for being vague, I was on my phone at the time.

You almost got it! There are actually multiple locations where a user could install the widget (namely Library vs /Library), so you don't want to use the absolute path.

Instead of

Code:
<script type='text/javascript' src="file:///Library/Widgets/Stocks.wdgt/stocksParser.js" charset='utf-8'></script>

Do:

Code:
<script type="text/javascript" src="stocksParser.js" charset="utf-8"></script>

It seems you tried this and commented it out? But it works fine!
 
Sorry for being vague, I was on my phone at the time.

You almost got it! There are actually multiple locations where a user could install the widget (namely Library vs /Library), so you don't want to use the absolute path.

Instead of

Code:
<script type='text/javascript' src="file:///Library/Widgets/Stocks.wdgt/stocksParser.js" charset='utf-8'></script>

Do:

Code:
<script type="text/javascript" src="stocksParser.js" charset="utf-8"></script>

It seems you tried this and commented it out? But it works fine!
yes, i updated it again to just use "stocksParser.js" instead of file:///Library/Widgets etc
 
  • Like
Reactions: Wowfunhappy
Sorry for being vague, I was on my phone at the time.

You almost got it! There are actually multiple locations where a user could install the widget (namely Library vs /Library), so you don't want to use the absolute path.

Instead of

Code:
<script type='text/javascript' src="file:///Library/Widgets/Stocks.wdgt/stocksParser.js" charset='utf-8'></script>

Do:

Code:
<script type="text/javascript" src="stocksParser.js" charset="utf-8"></script>

It seems you tried this and commented it out? But it works fine!
i changed it to stocksParser.js and the comment underneath was there by default, wasnt written by me
 
So, where can I download the updated copy of the widget? The one that was uploaded a few posts back doesn't display data in the green info cards and chart parameters at the bottom.
 
Last edited:
  • Like
Reactions: iPodNano3
So, where can I download the updated copy of the widget? The one that was posted a few posts back doesn't display the data in the green info cards and chart parameters at the bottom.
i havent implemented those so far, and afaik, the server doesnt support the green info cards (because the server uses yfinance in python, which is partially broken rn)
 
Last edited:
i genuinely have no idea how to get the details page to display information, so if anyone wants to give it a go, youre welcome to try. heres the current js file. i am able to get a 200 ok proper response from the server, but its not able to display it.
 

Attachments

  • stocksParser.js.zip
    4.1 KB · Views: 28
Hello,
I finally obtained my DeepL API key, followed your instructions to the T, but the Translation widget won't translate. I copied it to the Widgets dir of my home Library because Squid doesn't run for the other accounts on my machine (I tested it by switching the Guest account). No dice. The Console won't show anything related either. However, the CURL method works.

A small note, though. On 10.7, there's no translationParser.js. Instead, it's called parser.js. I didn't completely replace the three original files (one HTML and two JS). I made them invisible, renaming translationParser.js to parser.js in the process. I noticed that the latter's code doesn't fully match the former.
 
Hello,
I finally obtained my DeepL API key, followed your instructions to the T, but the Translation widget won't translate. I copied it to the Widgets dir of my home Library because Squid doesn't run for the other accounts on my machine (I tested it by switching the Guest account). No dice. The Console won't show anything related either. However, the CURL method works.

A small note, though. On 10.7, there's no translationParser.js. Instead, it's called parser.js. I didn't completely replace the three original files (one HTML and two JS). I made them invisible, renaming translationParser.js to parser.js in the process. I noticed that the latter's code doesn't fully match the former.
The original translationParser.js is in the /System/ folder. Because I don't want users to have to modify /System/, I edited the html to reference a local copy of translationParser.js instead of the System version.

Other than that I'm not sure what's wrong, however.
 
The catch is that the JS code produces no output, even errors. I confirmed this by running it in JSFiddle, an online code testing platform. I changed the request headers to expect deepl-Auth-Key as authorisation and return "application/json", and the method to "POST", but that, too, made no difference.




In the Terminal:


 
The catch is that the JS code produces no output, even errors. I confirmed this by running it in JSFiddle, an online code testing platform. I changed the request headers to expect deepl-Auth-Key as authorisation and return "application/json", and the method to "POST", but that, too, made no difference.


View attachment 2511151

In the Terminal:


View attachment 2511161
You mean you put the contents of TranslationParser.js into JSFiddle and nothing happened? Well, yeah, all the code is in functions, nothing will happen unless you call one of the functions. The functions are called by Translation.js.
 
Oops, I slipped up. Once again, you learn from your mistakes: it turned out the offender was a relative reference in the Translation.html. Once I renamed translationParser.js to parser.js inside its contents, the widget instantly made a DeepL connection and translated text.
I think that I got flummoxed over the part where you said that the three files in question were meant to be replaced, and the parser files weren't named identically.

To think of it, I even made an Xcode project with a WebView to experiment with your JS code (since Lion lacks built-in tools to run and debug JS) and took in a lot of new stuff while building it 😀
 
  • Haha
Reactions: iPodNano3
ok so i realized the server was returning <sname>Apple Inc.</sname> instead of <name>Apple Inc.</name> like the parser script was expecting. i just added this one letter and it fixed the details page as well as the red/green tiles. news still doesnt work and company names in the back of the widget do not show up yet. i also dont know if theres a way to abbreviate the market cap number, since it is so large the number goes offscreen. for example, instead of 3000000000000000 or whatever i want it to say 3T.

update: i got news and company names working properly! i think the only thing left to do is fix the formatting for market cap.
 

Attachments

  • Stocks.zip
    864.5 KB · Views: 9
Last edited:
for some weird reason it gets stuck after adding new symbols and you need to exit the dashboard and re-open it for it to update the data for the new symbol
 
ok so i realized the server was returning <sname>Apple Inc.</sname> instead of <name>Apple Inc.</name> like the parser script was expecting. i just added this one letter and it fixed the details page as well as the red/green tiles. news still doesnt work and company names in the back of the widget do not show up yet. i also dont know if theres a way to abbreviate the market cap number, since it is so large the number goes offscreen. for example, instead of 3000000000000000 or whatever i want it to say 3T.

update: i got news and company names working properly! i think the only thing left to do is fix the formatting for market cap.
Hey, is this an issue caused by me not installing the widget properly or something that's not yet fixed?
 

Attachments

  • Captura de pantalla 2025-05-29 a las 08.41.50.png
    Captura de pantalla 2025-05-29 a las 08.41.50.png
    38 KB · Views: 19
  • Captura de pantalla 2025-05-29 a las 08.41.57.png
    Captura de pantalla 2025-05-29 a las 08.41.57.png
    7.6 KB · Views: 18
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.