Commit 34779ff7 authored by Vildravn's avatar Vildravn
Browse files

Merge branch 'master' into 'beta'

Master

See merge request !3
parents ceb92605 05d8b083
......@@ -3,7 +3,7 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
## [1.2.0] - 2020-12-11
## [1.2.0] - 2020-12-15
### Added
* Added links to elements other than M+, the elements can be tapped now to open a link in the browser
* Callings - Wowhead Callings guide
......@@ -11,6 +11,12 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
* World Boss - Loot table of the specific world boss
* Widget (Empty space) - World quest map for the region
### Changed
* Widget is now configured via widgetParameters, default region is EU
### Removed
* Removed the FACTION setting as it serves no purpose currently
## [1.1.0] - 2020-12-11
### Changed
* Made some changes to hopefully reduce the memory usage by the widget
......@@ -27,4 +33,4 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
* The two active Torghast wings
* Current weekly Mythic+ affixes
* The current weekly Shadowlands world boss
* scriptable-require.js dependency
\ No newline at end of file
* scriptable-require.js dependency
# Today in WoW - Widget for Scriptable for iOS
![Today in WoW Widget screenshot](https://widgets.vildravn.dev/home/tiw.jpeg)
This is a script for [Scriptable](https://scriptable.app) for iOS that parses data from Wowhead's Today in WoW section and displays it on the home screen in a configurable widget.
Today in WoW parses the [Today in WoW section on wowhead.com](https://www.wowhead.com/#tiw-switcher-region) and displays the data as a configurable widget.
* The widget displays:
* Three current Shadowlands Covenant calling quests
* The two active Torghast wings
* Current weekly Mythic+ affixes
* The current weekly Shadowlands world boss
The widget displays:
* Active/available Shadowlands Covenant calling quests
* Active Torghast wings
* Current weekly Mythic+ affixes
* Current weekly Shadowlands world boss
All elements can be tapped to open the browser to read more information. Tapping on an empty space on the widget will bring up Wowhead's world quest map.
The individual elements can also be tapped for more information, leading either to a wowhead guide when tapping on the Calling quests and Torghast wings, the wowhead page of the tapped affix or the world boss' loot table. Tapping on an empty space on the widget brings up a map of current world quests for your region.
## Installation
### Installation
1. Install [Scriptable](https://apps.apple.com/us/app/scriptable/id1405459188?uo=4)
1. Place `Today in WoW.js` and `cheerio.js` in the `Scriptable` folder on your iCloud Drive
1. (Optional) Edit the `Today in WoW.js` script to configure it (See the Configuration section below)
1. Add a Scriptable widget to the home screen and while still in edit mode, tap on the widget to configure it
1. In the widget configuration, select the `Today in WoW` script, the `When interacting` and `Parameter` fields aren't important
1. Tap away from the widget configuration modal
#### Cheerio
## Configuration
The Today in WoW widget is dependent on a module called Cheerio. You will need to install this module first, for the widget to work.
Edit the `Today in WoW.js` script to adjust the configuration of the widget. Currently supports region and faction, and defaults to EU Horde.
[![Download with ScriptDude](https://scriptdu.de/download.svg)](https://scriptdu.de/?name=cheerio&source=https%3A%2F%2Fgitlab.com%2Fvildravn%2Ftoday-in-wow-widget%2F-%2Fraw%2Fmaster%2Fcheerio.js&docs=https%3A%2F%2Fwidgets.vildravn.dev%2F%23tiw#generator)
## Screenshot
or
![Screenshot of the widget](https://i.imgur.com/eG6qX3q.png)
\ No newline at end of file
Download Cheerio from [GitLab](https://gitlab.com/vildravn/today-in-wow-widget/-/raw/master/cheerio.js) and place it into the Scriptable folder on your iCloud Drive.
#### Today in WoW
After cheerio is installed in Scriptable, you can install the Today in WoW widget script.
[![Download with ScriptDude](https://scriptdu.de/download.svg)](https://scriptdu.de/?name=Today-in-WoW&source=https%3A%2F%2Fgitlab.com%2Fvildravn%2Ftoday-in-wow-widget%2F-%2Fraw%2Fmaster%2FToday%2520in%2520WoW.js&docs=https%3A%2F%2Fwidgets.vildravn.dev%2F%23tiw#generator)
or
Download Today in WoW from [GitLab](https://gitlab.com/vildravn/today-in-wow-widget/-/raw/master/Today%20in%20WoW.js) and place it into the Scriptable folder on your iCloud Drive.
After the script is installed within Scriptable:
1. Add a new Scriptable widget to your Home Screen (**Medium size only, for now**)
1. Tap on the added widget and select **Today in WoW** in the **Script** field. You can leave **When Interacting** as-is.
1. Configure the **Parameter** field:
* Enter your region, the field accepts EU or US (<a href="" target="_blank">click for screenshot</a>)
* If the field is left empty, or is set improperly, the widget will default to displaying EU data
1. Tap away from the Widget configuration modal
1. You may need to wait a bit for iOS to update the widget
[Changelog](https://gitlab.com/vildravn/today-in-wow-widget/-/blob/master/CHANGELOG.md)
\ No newline at end of file
......@@ -14,15 +14,6 @@
In case something breaks, open an issue at: https://gitlab.com/vildravn/today-in-wow-widget/-/issues
*/
/*
Widget Configuration
REGION - The region you want to show data of; Accepts 'EU' or 'US'
FACTION - What faction's data you want to show; Accepts 'alliance' or 'horde'
*/
const REGION = 'EU';
const FACTION = 'horde';
/*
Colors
*/
......@@ -67,6 +58,7 @@ const slBosses = {
}
// -----------------------------
const REGION = (args.widgetParameter.toUpperCase() == 'US' ? 'US' : 'EU');
const cheerio = importModule('cheerio');
let $ = undefined;
......@@ -100,39 +92,45 @@ async function createWidget(size) {
widget.backgroundColor = colors.bg;
if (size == 'medium') {
widget.url = REGION == 'EU' ? 'https://www.wowhead.com/world-quests/sl/eu' : 'https://www.wowhead.com/world-quests/sl/na';
let whData = await fetchData("https://www.wowhead.com", "loadString");
$ = cheerio.load(whData);
let data = undefined;
whData = undefined;
delete(whData);
const wrapperStack = widget.addStack();
wrapperStack.layoutHorizontally();
widget.addSpacer();
const leftColumn = wrapperStack.addStack();
leftColumn.layoutVertically();
data = await parseTextGroup(`#${REGION}-group-calling-quests`, `.tiw-region[data-region="${REGION}"]`);
await buildTextDisplay(leftColumn, "calling quests", data, 'https://www.wowhead.com/guides/covenant-callings-shadowlands');
leftColumn.addSpacer(20);
data = await parseTextGroup(`#${REGION}-group-torghast-wings`, `.tiw-region[data-region="${REGION}"]`);
await buildTextDisplay(leftColumn, "torghast wings", data, 'https://www.wowhead.com/guides/torghast-tower-of-the-damned-overview');
wrapperStack.addSpacer();
const rightColumn = wrapperStack.addStack();
rightColumn.layoutVertically();
data = await parseImageGroup(`#${REGION}-group-mythicaffix`, `.tiw-region[data-region="${REGION}"]`);
await buildAffixDisplay(rightColumn, data);
rightColumn.addSpacer(20);
data = await parseTextGroup(`#${REGION}-group-epiceliteworldsl`, `.tiw-region[data-region="${REGION}"]`);
await buildTextDisplay(rightColumn, "world boss", data, slBosses[data[0]]);
$ = undefined;
delete($);
if (REGION) {
widget.url = (REGION == 'US' ? 'https://www.wowhead.com/world-quests/sl/na' : 'https://www.wowhead.com/world-quests/sl/eu');
let whData = await fetchData("https://www.wowhead.com", "loadString");
$ = cheerio.load(whData);
let data = undefined;
whData = undefined;
delete (whData);
const wrapperStack = widget.addStack();
wrapperStack.layoutHorizontally();
widget.addSpacer();
const leftColumn = wrapperStack.addStack();
leftColumn.layoutVertically();
data = await parseTextGroup(`#${REGION}-group-calling-quests`, `.tiw-region[data-region="${REGION}"]`);
await buildTextDisplay(leftColumn, "calling quests", data, 'https://www.wowhead.com/guides/covenant-callings-shadowlands');
leftColumn.addSpacer(20);
data = await parseTextGroup(`#${REGION}-group-torghast-wings`, `.tiw-region[data-region="${REGION}"]`);
await buildTextDisplay(leftColumn, "torghast wings", data, 'https://www.wowhead.com/guides/torghast-tower-of-the-damned-overview');
wrapperStack.addSpacer();
const rightColumn = wrapperStack.addStack();
rightColumn.layoutVertically();
data = await parseImageGroup(`#${REGION}-group-mythicaffix`, `.tiw-region[data-region="${REGION}"]`);
await buildAffixDisplay(rightColumn, data);
rightColumn.addSpacer(20);
data = await parseTextGroup(`#${REGION}-group-epiceliteworldsl`, `.tiw-region[data-region="${REGION}"]`);
await buildTextDisplay(rightColumn, "world boss", data, slBosses[data[0]]);
$ = undefined;
delete ($);
} else {
const text = widget.addText('The widget is not configured correctly.');
text.textColor = textStyles.header.color;
text.font = textStyles.header.font;
}
} else {
const text = widget.addText(`${size} widget is currently not supported.`);
text.textColor = textStyles.header.color;
......@@ -149,7 +147,7 @@ async function buildAffixDisplay(parent, affixes) {
affix.text = levels[i];
}
await buildImageDisplay(parent, "mythic+ affixes", affixes);
}
......@@ -157,7 +155,7 @@ async function buildTextDisplay(parent, heading, data, url) {
const contentStack = parent.addStack();
contentStack.layoutVertically();
contentStack.url = url;
const header = contentStack.addText(heading.toUpperCase());
header.textColor = textStyles.header.color;
header.font = textStyles.header.font;
......@@ -172,11 +170,11 @@ async function buildTextDisplay(parent, heading, data, url) {
async function buildImageDisplay(parent, heading, data) {
const contentStack = parent.addStack();
contentStack.layoutVertically();
const header = contentStack.addText(heading.toUpperCase());
header.textColor = textStyles.header.color;
header.font = textStyles.header.font;
const horizontalStack = contentStack.addStack();
horizontalStack.layoutHorizontally();
......@@ -198,7 +196,7 @@ function buildImageItem(parent, image, item) {
icon.cornerRadius = 4;
icon.imageSize = new Size(34, 34);
icon.borderColor = colors.faction[item.side || "both"];
if (item.urlFragment) {
icon.url = `https://wowhead.com${item.urlFragment}`;
}
......@@ -274,4 +272,4 @@ async function fetchData(url, type = 'loadJSON') {
const req = new Request(url);
const resp = await req[type]();
return resp;
}
\ No newline at end of file
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment