GC Tyranu Evavu Tracker

Tracks Tyranu Evavu on the page so you don't need an external tool to count cards and tells you whether to choose Tyranu or Evavu.

当前为 2023-09-26 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         GC Tyranu Evavu Tracker
// @namespace    https://greasyfork.org/en/users/1175371/
// @version      0.4
// @description  Tracks Tyranu Evavu on the page so you don't need an external tool to count cards and tells you whether to choose Tyranu or Evavu.
// @author       sanjix
// @match        https://www.grundos.cafe/games/tyranuevavu/
// @icon         https://www.google.com/s2/favicons?sz=64&domain=grundos.cafe
// @grant        none
// ==/UserScript==

//construct deck
var deck = [];
var cards = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14];
for (var i = 0; i < cards.length; i++) {
  deck.push(cards[i]);
  deck.push(cards[i]);
  deck.push(cards[i]);
  deck.push(cards[i]);
}

//add current card to list of played cards
function update(card,playedCards){
    playedCards.push(card);
    localStorage.setItem('playedCards',JSON.stringify(playedCards));
}

//remove played cards from deck
function updateDeck(deck, playedCards){
    playedCards.forEach((card) => {
        var rmCard = deck.indexOf(card);
        deck.splice(rmCard, 1);
        return deck
})}

//decide tyranu v evavu
    function te(currentCard, deck){
        var smallerCards = deck.filter((card) => currentCard > card);
        var biggerCards = deck.filter((card) => currentCard < card);
        if (smallerCards.length > biggerCards.length){
            direction.textContent = 'Evavu';
        } else if (smallerCards.length < biggerCards.length){
            direction.textContent = 'Tyranu';
        } else {
            console.log('either');
            direction.textContent = 'Either';
        }
        console.log('in deck ,', deck);
    }

if (document.querySelector('input[value="Play Again"]') != null){
    //reset tracking
    localStorage.removeItem('playedCards');
} else if (document.querySelector('.te-cards') != null) {
    //id current card
    var currentCard = document.querySelector('.te-cards img').src;
    currentCard = currentCard.replace('https://grundoscafe.b-cdn.net/games/php_games/tyranuevavu/','');
    currentCard = parseInt(currentCard.split('_')[0]);

    //find played cards
    var playedCards = JSON.parse(localStorage.getItem('playedCards')) || [];

    //add element to DOM to direct player
    var direction = document.createElement('p');
    document.querySelector('.te-buttons').prepend(direction);
    direction.className = 'te-directions';

    update(currentCard, playedCards);
    updateDeck(deck, playedCards);
    te(currentCard, deck);
    console.log('played: ',playedCards);

}