您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
See your win rate as a percentage, and prevent accidentally double-clicking and drawing two cards.
// ==UserScript== // @name [GC] - Solitaire Enhancements // @namespace https://greasyfork.org/en/users/1225524-kaitlin // @match https://www.grundos.cafe/games/sakhmet_solitaire/ // @match https://www.grundos.cafe/games/pyramids/ // @version 2.2 // @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. // ==/UserScript== const deck = document.querySelector(".deck"); if (deck) { const f = deck.onclick; deck.onclick = function() { // Credit to Bankde for initial double-click protection script, used/tweaked with permission. 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)'); const movesLeft = document.querySelector('.flex.center-items.justify-center:nth-child(5)').textContent const originalClickHandler = collectBtn.onclick; function firstClickHandler(event) { event.preventDefault(); event.stopPropagation(); collectBtn.value = "Click again to confirm."; collectBtn.removeEventListener('click', firstClickHandler); collectBtn.addEventListener('click', originalClickHandler); } if ((movesLeft !== 'Last Round: 0') && (collectBtn.value === 'Collect Winnings') && (deck.alt !== 'deck_empty')) { collectBtn.addEventListener('click', firstClickHandler); } } else if (["Play Sakhmet Solitaire!", "Play Pyramids!"].includes(document.querySelector(".center .form-control").value)) { // do nothing, start page } else { const gameName = (document.querySelector('h1')?.textContent) || (document.querySelector('p')?.textContent); const winDataElement = document.querySelector("#page_content > main > .center > p:nth-child(5)") || document.querySelector("#page_content > .center > p:nth-child(5)"); const gamesPlayed = parseInt( (document.querySelector("#page_content > main > .center > p:nth-child(5) > strong:nth-child(1)") || document.querySelector("#page_content > .center > p:nth-child(5) > strong:nth-child(1)")) .textContent.replace(/,/g, '')); const gamesWon = parseInt( (document.querySelector("#page_content > main > .center > p:nth-child(5) > strong:nth-child(2)") || document.querySelector("#page_content > .center > p:nth-child(5) > strong:nth-child(2)")) .textContent.replace(/,/g, '') ); const winRate = `<p>Your current ${gameName} win rate is <strong>${parseFloat(((gamesWon / gamesPlayed) * 100).toFixed(2))}%</strong>.</p>`; winDataElement.innerHTML += " " + winRate; }