[GC] - Snow Wars enhancements

Press enter to continue after a move. See score calculations above the game. Hide non-essential images to declutter.

// ==UserScript==
// @name         [GC] - Snow Wars enhancements
// @namespace    https://greasyfork.org/en/users/1225524-kaitlin
// @match        https://www.grundos.cafe/games/snowwars/*
// @version      1.0
// @license      MIT
// @description  Press enter to continue after a move. See score calculations above the game. Hide non-essential images to declutter.
// @author       Cupkait
// @icon         https://i.imgur.com/4Hm2e6z.png
// ==/UserScript==
 
  if ((window.location.href.endsWith("/snowwars/")) || (window.location.href.endsWith("/snowwars/?"))) {

const hitArray = [
  '/snowwars/2_1.gif',
  '/snowwars/2_2.gif',
  '/snowwars/2_3.gif',
  '/snowwars/2_4.gif',
  '/snowwars/3_1.gif',
  '/snowwars/4_1.gif',
  '/snowwars/5_1.gif',
  '/snowwars/5_2.gif',
  '/snowwars/6_1.gif',
  '/snowwars/6_2.gif',
  '/snowwars/7_1.gif',
  '/snowwars/7_2.gif',
  '/snowwars/7_3.gif',
  '/snowwars/8_1.gif',
  '/snowwars/8_2.gif',
  '/snowwars/8_3.gif',
  '/snowwars/8_4.gif',
];

const gameArea = document.querySelectorAll('.snowwars-board-container');
const oppBoard = gameArea[0];
const userBoard = gameArea[1];
const oppTiles = oppBoard.querySelectorAll('.snowwars-spot');
const userTiles = userBoard.querySelectorAll('.snowwars-spot');
const turnCount = userBoard.querySelectorAll('.x-mark').length;

oppTiles.forEach(tile => {
  let containsHit = hitArray.some(hit => tile.style.backgroundImage.includes(hit));
  if (!containsHit) {
    tile.style.backgroundImage = 'none';
  }
});

userTiles.forEach(tile => {
  let containsHit = hitArray.some(hit => tile.style.backgroundImage.includes(hit));
  if (!containsHit) {
    tile.style.backgroundImage = 'none';
  }
});

const userHits = Array.from(userTiles).reduce((count, tile) => {
  let containsHit = hitArray.some(hit => tile.style.backgroundImage.includes(hit));
  if (containsHit && tile.innerHTML.includes('x-mark')) {
    return count + 1;
  }
  return count;
}, 0);

const oppHits = Array.from(oppTiles).reduce((count, tile) => {
  let containsHit = hitArray.some(hit => tile.style.backgroundImage.includes(hit));
  if (containsHit) {
    return count + 1;
  }
  return count;
}, 0);





var value = 'blank'

const statsContainer = document.createElement('p');
statsContainer.innerHTML = `<strong>Turns Completed:</strong> ${turnCount} | <strong>Hits you've made:</strong> ${oppHits} | <strong>Hits you've received:</strong> ${userHits}`;

const mainArea = document.querySelector('.center');
mainArea.prepend(statsContainer);


}

if (window.location.href.includes("cell=")) {
  const submitButton = $('input[type="submit"].form-control.full-width');
  if (submitButton.length > 0) {
    submitButton.val("Press Enter or click here to continue!");
    $(document).on("keydown", function (event) {
      if (event.key === "Enter") {
        submitButton.click();
      }
    });
  }
}