I want to display the stock of items in a video game, from either of two websites, https://growagarden.gg/stocks or https://vulcanvalues.com/grow-a-garden/stock (whichever is more convenient) but I need help…
I want it to be sort of in the formation of
“Gear Stock:
Watering Can x2
Favorite Tool x1” (etc.) for the categories gear stock, egg stock, and seed stock, but I can’t figure out how to get the data from the website into my widget. I also need it to refresh every 5 minutes (10:00, 10:05, 10:10, etc.) and I also have no clue how to get that done.
Sorry for talking so much, but to wrap it up, I’m on Scriptable on iOS, I have a PC but I don’t have Scriptable on it. I alsos have iOS Shortcuts, if that is also something I could use, but any help would be appreciated.
P.S: I tried asking AI to make something for Scriptable, and it gave me the following stuff, but the widget says “not found” for all the items.
// Define the URL of the new stock page
let url = "https://growagardenvalues.com/stock/stocks.php";
let req = new Request(url);
let html = await req.loadString();
// Function to extract stock information for a given category
function extractStock(category) {
let pattern = new RegExp(`<h2>${category}</h2>[\\s\\S]*?<ul>([\\s\\S]*?)</ul>`, "i");
let match = html.match(pattern);
if (!match) return `${category}: Not found`;
let listHTML = match[1];
let listItems = listHTML.match(/<li>(.*?)<\/li>/g);
let cleanedList = listItems
? listItems.map(i => i.replace(/<[^>]+>/g, '')).join(', ')
: 'No data';
return `${category}:\n${cleanedList}`;
}
// Extract stock information for each category
let seeds = extractStock("Seeds");
let gear = extractStock("Gear");
let eggs = extractStock("Eggs");
// Create the widget
let widget = new ListWidget();
widget.addText("🌱 Grow a Garden Stock").font = Font.boldSystemFont(14);
widget.addSpacer(6);
let font = Font.systemFont(10);
widget.addText(seeds).font = font;
widget.addSpacer(4);
widget.addText(gear).font = font;
widget.addSpacer(4);
widget.addText(eggs).font = font;
// Set the widget's refresh interval to every 5 minutes
if (config.runsInWidget) {
let now = new Date();
let refreshDate = new Date(now.getTime() + 5 * 60000); // 5 minutes later
widget.refreshAfterDate = refreshDate;
Script.setWidget(widget);
} else {
widget.presentMedium();
}
Script.complete();
Please help, I’m lost (@sylumer if you’re reading this PLEASE HELP MEEEEE)