Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save Silvyre/f0decf2503ca18510ffc636deff6ef22 to your computer and use it in GitHub Desktop.
Save Silvyre/f0decf2503ca18510ffc636deff6ef22 to your computer and use it in GitHub Desktop.
Automates Dominion Online table configuration. To be used via Tampermonkey. Please see: https://greasyfork.org/en/scripts/407793-dominion-games-automated-table-setup
// ==UserScript==
// @name dominion.games Automated Table Setup
// @description Click on the 'New Table' button to trigger the script
// @version 0.2
// @author Rafi_
// @match https://dominion.games/
// @namespace http://tampermonkey.net/
// @require https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js
// @require https://greasyfork.org/scripts/6250-waitforkeyelements/code/waitForKeyElements.js?version=23756
// @grant GM_addStyle
// @grant GM.getValue
// ==/UserScript==
// @grant none
// global waitForKeyElements
'use strict';
// Bypass the option to load an old game
waitForKeyElements('div.window.new-table', () => $('button:contains("Create Table")').click(), true);
// Configure 'Basic Options'
waitForKeyElements('div.window.my-table', () => {
/* Set max. players to 6 */
let maxPlayers = $('select[ng-model="$ctrl.tableRules.maxPlayers"]');
maxPlayers.val('number:6');
angular.element(maxPlayers).triggerHandler('change');
/* Open 'Advanced Options' */
$('button:contains("Advanced Options")').click();
}, true);
// Configure 'Advanced Options'
waitForKeyElements('div.rules-checkboxes', () => {
/* Uncheck 'Show VP counter' */
$('div.rules-checkboxes > input:nth-child(9)').click();
/* Open 'Select Kingdom Cards' view */
$('button:contains("Select Kingdom Cards")').click();
}, true);
// Configure 'Select Kingdom Cards' view options
waitForKeyElements('div.kingdom-selection-window', () => {
/* Turn on Colonies */
_.times(2, () => $('button:contains("Colonies")').click());
/* Add third and fourth landscape slots */
_.times(2, () => $('landscape-plus-slot > div > div').click());
/* Set first landscape slot to always be a Way */
let ls = $('landscape-slot');
[...'NPEL'].forEach(type => ls[0].firstChild.querySelector(`.type-${type}`).click());
/* Set second landscape slot to always be either an Event or a Landmark */
[...'NP'].forEach(type => ls[1].firstChild.querySelector(`.type-${type}`).click());
/* Set third and fourth landscape slots to be either be an Event or a Project */
[2, 3].forEach(n => ls[n].firstChild.querySelector('.type-L').click());
/* Select 'Done' */
$('.lobby-button.close').click();
}, true);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment