diff --git a/onlinetichu-counter.js b/onlinetichu-counter.js index 3ae8055..d0ecef2 100644 --- a/onlinetichu-counter.js +++ b/onlinetichu-counter.js @@ -1,6 +1,6 @@ // ==UserScript== // @name onlinetichu.com card counter -// @version 1.3.6 +// @version 1.4.0 // @description automatically count cards at onlinetichu.com // @match *://*.onlinetichu.com/Site/Game/Table/* // @author Maximilian Keßler @@ -119,12 +119,19 @@ function injectCounter() { showRemainingButton.type = "button"; showRemainingButton.innerHTML = 'Show: Remaining'; + var showOwnCardsButton = document.createElement('button'); + showOwnCardsButton.className = "btn btn-primary btn-xs"; + showOwnCardsButton.id = "showOwnCards"; + showOwnCardsButton.type = "button"; + showOwnCardsButton.innerHTML = 'OwnCards: Shown'; + var showCountedCardsButton = document.createElement('button'); showCountedCardsButton.className = "btn btn-success btn-xs"; showCountedCardsButton.id = "showCountedCards"; showCountedCardsButton.type = "button"; showCountedCardsButton.innerHTML = 'Show cards: No'; + controlButtonsRight.appendChild(showOwnCardsButton); controlButtonsRight.appendChild(showRemainingButton); controlButtonsRight.appendChild(showCountedCardsButton); controlButtonsLeft.appendChild(davidProtectionButton); @@ -237,6 +244,8 @@ function injectCounter() { $showCardCounterValue: $('#showCardCounterValue'), $showRemaining: $('#showRemaining'), $showRemainingValue: $('#showRemainingValue'), + $showOwnCards: $('#showOwnCards'), + $showOwnCardsValue: $('#showOwnCardsValue'), $showCountedCards: $('#showCountedCards'), $showCountedCardsValue: $('#showCountedCardsValue'), $davidProtection: $('#davidProtection'), @@ -267,10 +276,12 @@ function injectCounter() { exchangedFrom: {}, handCardShuffle: [], playerNames: {}, + ownCards: [], // config values, triggered with buttons smartFold: false, showCardCounter: false, + showOwnCards: true, showRemaining: true, showCountedCards: false, davidProtection: false, @@ -476,7 +487,7 @@ function injectCounter() { if (otc.showRemaining) { cards = []; for(let j=0; j < otc.allCards[i].length; j ++) { - if(!otc.util.cardInArray(otc.allCards[i][j], otc.playedCards[i])) { + if(!otc.util.cardInArray(otc.allCards[i][j], otc.playedCards[i]) && (otc.showOwnCards || !otc.util.cardInArray(otc.allCards[i][j], otc.ownCards))) { cards.push(otc.allCards[i][j]); } otc.$playedCards[i].html(otc.util.displayCardsHtmlString(cards)); @@ -578,6 +589,16 @@ function injectCounter() { otc.action.drawPlayedCards(); }); + otc.$showOwnCards.click(function () { + otc.showOwnCards = !otc.showOwnCards; + if (otc.showOwnCards) { + otc.$showOwnCardsValue.text(otc.$showOwnCardsValue.data('on')); + } else { + otc.$showOwnCardsValue.text(otc.$showOwnCardsValue.data('off')); + } + otc.action.drawPlayedCards(); + }); + for(let i = 1; i < 15; i++) { otc.$playedCards[i] = $('#playedCards' + i); } @@ -635,6 +656,7 @@ function injectCounter() { southPosition = 1; $(message.Table.Players).each(function () { if (this.Username == ot.$Username.val()) { + otc.ownCards = this.Cards; spectator = false; southPosition = this.Position; // console.log('found player');