diff --git a/src/content/features/click-match-room-veto-maps.js b/src/content/features/click-match-room-veto-maps.js index 8b5ed74c..453cd089 100644 --- a/src/content/features/click-match-room-veto-maps.js +++ b/src/content/features/click-match-room-veto-maps.js @@ -48,7 +48,11 @@ export default async parentElement => { const { matchRoomAutoVetoMapItems, matchRoomAutoVetoMapsShuffle: shuffleMaps, - matchRoomAutoVetoMapsShuffleAmount: shuffleMapsAmount + matchRoomAutoVetoMapsShuffleAmount: shuffleMapsAmount, + + // Auto veto limit variables. + matchRoomAutoVetoMapsLimit: vetoMapsLimit, + matchRoomAutoVetoMapsLimitAmount: vetoMapsLimitAmount } = await storage.getAll() let autoVetoItems = matchRoomAutoVetoMapItems.map(m => maps.csgo[m] || m) @@ -72,6 +76,8 @@ export default async parentElement => { setFeatureAttribute(FEATURE_ATTRIBUTE, votingListElement) + let vetoMapCounter = 0 + const autoVeto = () => { const isVetoTurn = select.exists('button', votingListElement) @@ -86,7 +92,27 @@ export default async parentElement => { ) if (vetoButtonElement) { setTimeout(() => { - vetoButtonElement.click() + /* + * Added Auto Veto Limit: + * + * Default: vetoMapsLimit = false (No Limit on Veto) + * vetoMapsLimitAmount = 4 (Maximum a team can veto) + * vetoMapCounter = 1-4 (Keep a check on number of maps veteod) + * + * Logic: If vetoMapsLimit = false, auto veto maximum possible maps + * else check + * if counter <= set_value (default=4) + * auto veto and increment counter + * else just wait for player to veto. + */ + if (vetoMapsLimit) { + if (vetoMapCounter < vetoMapsLimitAmount) { + vetoButtonElement.click() + vetoMapCounter += 1 + } + } else { + vetoButtonElement.click() + } }, VETO_DELAY) } return Boolean(vetoButtonElement) diff --git a/src/popup/sections/veto-preferences.js b/src/popup/sections/veto-preferences.js index 371319f2..a3d40c4c 100644 --- a/src/popup/sections/veto-preferences.js +++ b/src/popup/sections/veto-preferences.js @@ -45,6 +45,19 @@ export default ({ getMenuProps, getSortableProps, getSwitchProps }) => ( mapOption={option => `First ${option}`} {...getMenuProps('matchRoomAutoVetoMapsShuffleAmount')} /> + + index % 2 === 0 + ).map((_, index) => index + 1)} + mapOption={option => `First ${option}`} + {...getMenuProps('matchRoomAutoVetoMapsLimitAmount')} + /> diff --git a/src/shared/settings.js b/src/shared/settings.js index 29a4a908..12f073aa 100644 --- a/src/shared/settings.js +++ b/src/shared/settings.js @@ -37,6 +37,8 @@ export const DEFAULTS = { matchRoomAutoVetoMaps: false, matchRoomAutoVetoMapsShuffle: false, matchRoomAutoVetoMapsShuffleAmount: 3, + matchRoomAutoVetoMapsLimit: false, + matchRoomAutoVetoMapsLimitAmount: 4, matchRoomAutoVetoMapItems: MATCH_ROOM_VETO_MAP_ITEMS, matchRoomFocusMode: false, matchRoomLastConnectToServer: '',