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 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 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);

}