GC - Neggsweeper Mines Remaining

Shows how many mines are left in a neggsweeper game, assuming that you flagged mines correctly.

  1. // ==UserScript==
  2. // @name GC - Neggsweeper Mines Remaining
  3. // @namespace https://greasyfork.org/en/users/1202961-twiggies
  4. // @version 2023-12-13
  5. // @description Shows how many mines are left in a neggsweeper game, assuming that you flagged mines correctly.
  6. // @author You
  7. // @match https://www.grundos.cafe/games/neggsweeper/
  8. // @icon https://www.google.com/s2/favicons?sz=64&domain=grundos.cafe
  9. // @grant none
  10. // @license MIT
  11. // ==/UserScript==
  12.  
  13. 'use strict';
  14. const neggGrid = document.querySelector('#neggsweeper_grid')
  15. if (neggGrid != undefined) {
  16. const statusGrid = document.querySelector('#neggsweeper_status');
  17. const remainingDiv = statusGrid.querySelector('div:nth-of-type(4)');
  18. const remaining = Number(remainingDiv.textContent);
  19. //Remaining number of unmarked, unrevealed neggs.
  20. const neggsLeft = neggGrid.querySelectorAll('img[src="https://grundoscafe.b-cdn.net/games/php_games/neggsweeper/negg.gif"]').length;
  21.  
  22. console.log(`Mines: ${neggsLeft - remaining}`);
  23. statusGrid.querySelector('div:nth-of-type(1)').insertAdjacentHTML('afterend','<div class="bg-gold">Mines</div>')
  24. remainingDiv.insertAdjacentHTML('afterend',`<div>${neggsLeft - remaining}</div>`)
  25. statusGrid.style.gridTemplateColumns = "30% 20% 20% 30%"
  26.  
  27. }