Skip to content

Commit

Permalink
2.2.0 - Support YAML format for card list.
Browse files Browse the repository at this point in the history
Switch from JSON to YAML since it doesn't require quotes around strings
and therefore is less confusing for cards with quotes in their names.
It's also generally more compact and easier to read. This is optional,
though. A new advanced setting was added to allow switching back to
JSON. The whole watchlist can still be edited directly in the script
manager's values section, and is saved there in JSON format. Cards now
include a rarity field. The script doesn't use it for anything but it
may help for your own organization. It also supports a notes field,
which can be used to store any extra information you want. It won't be
read aloud. There's also now an alert field, which is similar, but is
read aloud when the card is found, along with its name. So if you want
to add something to get your attention for a specific card, you can use
the alert field for that. These values are optional and won't be added
automatically when cards are selected by clicking. Also fixed some
issues with handling certain unusual pages like Boosters and Redeemable
Sets, as well as how card names are spoken on those pages. The Escape
key now closes all the script's dialogs. Finally, improve the code
comments documenting the script's settings.
  • Loading branch information
aminomancer committed May 24, 2023
1 parent 8bc040f commit fe0efce
Show file tree
Hide file tree
Showing 4 changed files with 604 additions and 287 deletions.
4 changes: 3 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@
"GM_getValue": "writable",
"GM_setValue": "writable",
"GM_addStyle": "writable",
"GM_getResourceURL": "writable",
"GM_registerMenuCommand": "writable",
"GM_unregisterMenuCommand": "writable"
"GM_unregisterMenuCommand": "writable",
"GM_addValueChangeListener": "writable"
},
"rules": {
"camelcase": [
Expand Down
30 changes: 24 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,35 @@ Automatically refresh a [GoatBots](https://www.goatbots.com) page on a set timer

## Configuration

This script lets you mark a particular GoatBots page and assign a cards list for that page. When you navigate to the page, the script will automatically reload it on a timer to check if any of the cards on your list are now in stock. When a card on your list is detected, an audio alert will speak the names of the new card(s), and the card(s) will be added to your cart. You can add as many pages as you want, and you can scan for as many cards per-page as you want. Each page in your watchlist has its own independent cards list stored in your user settings, so they can't get mixed up.
This script lets you mark a particular GoatBots page and assign a cards list for that page. When you navigate to the page, the script will automatically reload it on a timer to check if any of the cards on your list are now in stock. When a card on your list is detected, an audio alert will (optionally) speak the names of the new cards, and the cards will be added to your cart. You can add as many pages as you want, and you can scan for as many cards per-page as you want. Each page in your watchlist has its own independent cards list stored in your user settings, so they can't get mixed up.

You can access the user settings through the `Card Watcher` menu at the top of the GoatBots window, or through your script manager. [Violentmonkey](https://violentmonkey.github.io/) and the latest [Greasemonkey](https://www.greasespot.net/) versions have a toolbar button that opens a popup showing script settings for the current page. However, these are the same settings as in the Card Watcher menu, so you might as well just use the Card Watcher menu. So if you go to [www.goatbots.com](https://www.goatbots.com), you can open the menu or the popup and use the buttons in there to configure your settings. If you're not sure, there are further instructions and details in the script itself.

When you first open a GoatBots page, open the Card Watcher menu popup and click `Add page to watchlist` to make a watchlist editor appear. The top text field is the path field. This is the path for the page you want to scan, such as `https://www.goatbots.com/set/kaldheim`. It defaults to the path of the current page, but you can edit it here. If you want to still be able to use the normal GoatBots page without it constantly reloading, add a `+` at the end of the page URL (e.g., `https://www.goatbots.com/set/kaldheim+`). You can navigate to the URL just fine with a `+` at the end, and the script will correctly recognize it as a different URL. Then, the script will only activate when you explicitly navigate to the `+` version of the URL, which you can bookmark.

Then proceed to the big text area — the cards list. You can manually input the card IDs in JSON format, but since this information is not visible on the page without using devtools, it will probably be easier to click the `Select by Clicking` button at the bottom. This will allow you to add cards to the watchlist just by clicking them. Clicking a card row will toggle it on or off. Then click the `Confirm` button to return to the watchlist editor — the cards list will now be filled with the cards you selected. Then, click the `Save` button and it will store this in your script settings. They will persist even after updating the script.

When you `Select by Clicking`, the script will automatically create an object to represent the card. Since each card is actually identified by a random string of characters (the `id`), you can change a card's name to anything you want by editing the JSON. The text-to-speech alert, if it's enabled, will speak aloud the card's name, along with some other identifying information depending on what page is being watched. On a card page, there's only one card name, so it only reads the card name once. But there may be multiple versions, so it says the set and frame type (e.g. `Showcase` or `Foil`). On a set page, there's no need to read the set, but the card name and frame type are spoken aloud.

After adding a card to the watchlist, it will appear in the JSON list. It will also have a `wanted` property of `-1` by default. This allows you to choose a maximum number of copies to order. If 4 are available but you've set the card's `wanted` property to `2`, it will change the amount in cart to 2. However, GoatBots doesn't allow us to choose any quantity. It only allows you to cycle through predefined quantities, like 40, 20, 4, 3, 2, 1, etc. So, if you choose a `wanted` number that isn't allowed, it will reduce the amount in cart until it's less than or equal to the `wanted` number you've chosen. If you don't care about the quantity, and just want as many copies as are available, setting the `wanted` value to `0`, a negative value, or no value at all (e.g. by deleting the `wanted` property) will result in no quantity limit.
Then proceed to the big text area — the cards list. You can manually input the card IDs in YAML or JSON format, but since this information is not visible on the page without using devtools, it will probably be easier to click the `Select by Clicking` button at the bottom. This will allow you to add cards to the watchlist just by clicking them. Clicking a card row will toggle it on or off. Then click the `Confirm` button to return to the watchlist editor — the cards list will now be filled with the cards you selected. Then, click the `Save` button and it will store this in your script settings. They will persist even after updating the script.

When you `Select by Clicking`, the script will automatically create an object to represent the card. Since each card is actually identified by a random string of characters (the `id`), you can change a card's name to anything you want by editing it in the list editor. The text-to-speech alert, if it's enabled, will speak the card's name aloud, along with some other identifying information depending on what page is being watched. On a card page, there's only one card name, so it only reads the card name once. But there may be multiple versions, so it says the set and frame type (e.g. `Showcase` or `Foil`). On a set page, there's no need to read the set, but the card name and frame type are spoken aloud. Here's an example of how the card list for a given page might look:

```yaml
- name: Atraxa, Grand Unifier
set: ONE
frame: Showcase
rarity: Mythic Rare
notes: Borderless
wanted: -1
id: A4zDSnxvkUrgTA==
- name: Elesh Norn, Mother of Machines
set: ONE
frame: Phyrexian
rarity: Mythic Rare
wanted: -1
id: A4zDSnxvnk3mQw==
```
The `id` property is the only one that can't be changed. It's the only way to identify a card, so changing it would make it impossible to find the card again. The `name` property is generated automatically, but can be changed to anything. It is read aloud by default. The other properties can be changed as well, or even removed. There are two optional properties that are not added automatically, and are provided to make tracking cards easier. The `alert` property accepts any string, and will be read aloud along with the card's name if it's provided. The `notes` property serves a similar purpose but will not be read aloud. It's only there for your own reference.

After adding a card to the watchlist, it will appear in the list with values automatically generated. It will also have a `wanted` property of `-1` by default. This allows you to choose a maximum number of copies to order. If 4 are available but you've set the card's `wanted` property to `2`, it will change the amount in cart to 2. However, GoatBots doesn't allow us to choose any quantity. It only allows you to cycle through predefined quantities, like 40, 20, 4, 3, 2, 1, etc. So, if you choose a `wanted` number that isn't allowed, it will reduce the amount in cart until it's less than or equal to the `wanted` number you've chosen. If you don't care about the quantity, and just want as many copies as are available, setting the `wanted` value to `0`, a negative value, or no value at all (e.g. by deleting the `wanted` property) will result in no quantity limit.

By default, this will refresh the page every 10 seconds, provided the tab the page is loaded in is not active. It basically pauses refreshing while the tab is active, so that you can still use the page as normal. That way, it will only scan in the background, and alert you when it finds something. However, this pausing behavior can be disabled by setting `Refresh while active` to true in the `Advanced Settings` which can be accessed through the menu. You can set the values of any of the settings in this interface, except for the watchlist. If you need to make bulk changes to the watchlist, go to the script page in your [script manager](https://violentmonkey.github.io/) and click on the "Values" tab.

Expand Down
Loading

0 comments on commit fe0efce

Please sign in to comment.