[GC] - Solitaire Enhancements

See your win rate as a percentage, and prevent accidentally double-clicking and drawing two cards.

目前为 2024-05-31 提交的版本。查看 最新版本

// ==UserScript==
// @name         [GC] - Solitaire Enhancements
// @namespace    https://gf.qytechs.cn/en/users/1225524-kaitlin
// @match        https://www.grundos.cafe/games/sakhmet_solitaire/
// @version      1.6
// @license      MIT
// @author       Cupkait
// @icon         https://i.imgur.com/4Hm2e6z.png
// @description  See your win rate as a percentage, and prevent accidentally double-clicking and drawing two cards.
                 // Credit to Bankde for initial double-click protection script, used/tweaked with permission.
// ==/UserScript==


const deck = document.querySelector(".deck");

if (deck) {
    const f = deck.onclick;

    deck.onclick = function() {
        let clickTimeout;

        function firstClick() {
            f.call(deck);

            deck.onclick = function() {
                clearTimeout(clickTimeout);
                clickTimeout = setTimeout(function() {
                    alert("Oops! Double-click detected and prevented. If the page doesn't automatically load your new card, refresh and try again.");
                }, 1000);
            };
        }

        firstClick();
    };

  const collectBtn = document.querySelector('.margin-1 > input:nth-child(3)');

if (collectBtn.value === 'Collect Winnings') {
  collectBtn.type = 'hidden';

  const endEarly = document.createElement('button');
  endEarly.textContent = 'End Game Early';
  endEarly.style.height = 'auto';
  document.querySelector('#gamearea').prepend(endEarly);

  endEarly.addEventListener('click', function() {
    endEarly.textContent = 'Please wait...';
        endEarly.disabled = true;


    setTimeout(function() {
      endEarly.remove();
      collectBtn.type = 'submit';
    }, 1000);
  });
};
} else {
    const winDataElement = document.querySelector("#page_content > .center > p:nth-child(5)");
    const gamesPlayed = parseInt(document.querySelector("#page_content > .center > p:nth-child(5) > strong:nth-child(1)").textContent.replace(/,/g, ''));
    const gamesWon = parseInt(document.querySelector("#page_content > .center > p:nth-child(5) > strong:nth-child(2)").textContent.replace(/,/g, ''));

    const winRate = `<p>Your current win rate is <strong>${parseFloat(((gamesWon / gamesPlayed) * 100).toFixed(2))}%.</strong></p>`;
    winDataElement.innerHTML += " " + winRate;
}


QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址