Skip to content

Commit

Permalink
2.1.0 - change storage format.
Browse files Browse the repository at this point in the history
allow setting a max quantity.
we still can't set a max price unfortunately.
add eslint/prettier setup.
update readme.
  • Loading branch information
aminomancer committed May 22, 2023
1 parent dbbae02 commit 8bc040f
Show file tree
Hide file tree
Showing 11 changed files with 4,558 additions and 355 deletions.
16 changes: 16 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
root = true

[*]
charset = utf-8
end_of_line = lf
indent_style = space
indent_size = 2
insert_final_newline = true
trim_trailing_whitespace = true

[*.md]
trim_trailing_whitespace = false

[*.yml]
indent_style = space
indent_size = 2
79 changes: 79 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
{
"env": { "browser": true, "es2021": true, "greasemonkey": true },
"extends": [
"eslint:recommended",
"airbnb-base",
"plugin:prettier/recommended"
],
"parserOptions": { "ecmaVersion": "latest", "sourceType": "script" },
"globals": {
"GM_getValue": "writable",
"GM_setValue": "writable",
"GM_addStyle": "writable",
"GM_registerMenuCommand": "writable",
"GM_unregisterMenuCommand": "writable"
},
"rules": {
"camelcase": [
"error",
{
"ignoreDestructuring": false,
"ignoreGlobals": true,
"ignoreImports": true,
"properties": "always"
}
],
"class-methods-use-this": "off",
"curly": [
// You're not supposed to use this rule with prettier, but in my experience
// it works just fine with prettier-eslint and the following settings:
"error",
"multi-line",
"consistent"
],
"default-param-last": "off",
"eqeqeq": ["error", "smart"],
"indent": "off",
"max-classes-per-file": "off",
"max-len": "off",
"new-cap": ["error", { "capIsNew": false }],
"no-alert": "off",
"no-cond-assign": ["error", "except-parens"],
"no-confusing-arrow": ["error", { "allowParens": false }],
"no-console": "off",
"no-continue": "off",
"no-empty": ["error", { "allowEmptyCatch": true }],
"no-eval": "error",
"no-fallthrough": [
"error",
{
// The eslint rule doesn't allow for case-insensitive regex option.
// The following pattern allows for a dash between "fall through" as
// well as alternate spelling of "fall thru". The pattern also allows
// for an optional "s" at the end of "fall" ("falls through").
"commentPattern": "[Ff][Aa][Ll][Ll][Ss]?[\\s-]?([Tt][Hh][Rr][Oo][Uu][Gg][Hh]|[Tt][Hh][Rr][Uu])"
}
],
"no-implied-eval": "error",
"no-param-reassign": "off",
"no-plusplus": "off",
"no-promise-executor-return": "off",
"no-restricted-syntax": ["error", "SequenceExpression"],
"no-return-assign": "off",
"no-shadow": "off",
"no-underscore-dangle": "off",
"no-unused-expressions": [
"error",
{ "allowTaggedTemplates": true, "allowTernary": true }
],
"no-unused-vars": ["error", { "args": "after-used", "vars": "local" }],
"no-use-before-define": ["error", { "classes": false, "functions": false }],
"prefer-destructuring": "off",
"prettier/prettier": ["error", {}, { "usePrettierrc": true }],
"quotes": [
"error",
"double",
{ "allowTemplateLiterals": false, "avoidEscape": true }
]
}
}
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Auto detect text files and perform LF normalization
* text=auto eol=lf
24 changes: 24 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Node modules
node_modules/

.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
!.vscode/*.code-snippets

# Local History for Visual Studio Code
.history/

# Built Visual Studio Code Extensions
*.vsix

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional stylelint cache
.stylelintcache
14 changes: 14 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"endOfLine": "lf",
"arrowParens": "avoid",
"printWidth": 80,
"tabWidth": 2,
"useTabs": false,
"semi": true,
"singleQuote": false,
"trailingComma": "es5",
"quoteProps": "as-needed",
"bracketSameLine": true,
"bracketSpacing": true,
"embeddedLanguageFormatting": "auto"
}
24 changes: 24 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"eslint.validate": ["javascript"],
"prettier.printWidth": 80,
"rewrap.wrappingColumn": 80,
"editor.rulers": [72, 80],
"[git-commit]": { "editor.rulers": [50, 72], "rewrap.wrappingColumn": 72 },
"editor.formatOnPaste": false,
"editor.formatOnType": false,
"editor.formatOnSave": true,
"editor.formatOnSaveMode": "file",
"[javascript][javascriptreact][typescript][typescriptreact]": {
"editor.defaultFormatter": "rvest.vs-code-prettier-eslint",
"editor.codeActionsOnSave": {}
},
"[json][jsonc]": {
"editor.defaultFormatter": "rvest.vs-code-prettier-eslint"
},
"[html]": { "editor.defaultFormatter": "rvest.vs-code-prettier-eslint" },
"[yaml]": { "editor.defaultFormatter": "rvest.vs-code-prettier-eslint" },
"[css][sass][scss][less]": {
"editor.defaultFormatter": "rvest.vs-code-prettier-eslint"
},
"[markdown]": { "editor.defaultFormatter": "rvest.vs-code-prettier-eslint" }
}
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ When you first open a GoatBots page, open the Card Watcher menu popup and click

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 assign each card a name, like `Thalia, Guardian of Thraben (MUL Showcase)`. However, since each card is actually identified by a random string of characters, you can change a card's name to anything you want, by editing the JSON. The name is what will be spoken aloud by the text-to-speech alert (if enabled).
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.

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 All @@ -27,4 +29,4 @@ If you're using Firefox and you want the text-to-speech alerts, make sure the pr

Before the synthesized speech or voice audio plays, the script will also trigger a little alert sound. This is done so that the alert will be more noticeable in the event that you're listening to dialogue when the alert goes off. The synthesized speech may not be as noticeable if there are other voices playing in the background, so I added a little "ding" noise to play at the same time. It's the same sound that plays when you get a notification in MTGO. This sound can also be changed. Again, it's a base64-encoded audio file, so use the same encoder as above. Aside from that, there are a few other speech/audio settings.

<sub>I am not affiliated with <a href="https://company.wizards.com">Wizards of the Coast</a> or <a href="https://www.goatbots.com">GoatBots</a>. Magic: The Gathering, MTGO, its corresponding symbols, and illustrations are trademarked by Wizards of the Coast. GoatBots and its corresponding symbols and illustrations are trademarked by GoatBots.</sub>
<sub>I am not affiliated with <a href="https://company.wizards.com">Wizards of the Coast</a> or <a href="https://www.goatbots.com">GoatBots</a>. Magic: The Gathering, MTGO, its corresponding symbols, and illustrations are trademarked by Wizards of the Coast. GoatBots and its corresponding symbols and illustrations are trademarked by GoatBots.</sub>
Loading

0 comments on commit 8bc040f

Please sign in to comment.