[Mod] View Kingdom Card Text

Previous topic - Next topic

Icehawk78

I'll preface this by saying that it currently looks fairly ugly, doesn't react well/at all when dealing with split/varied piles, and may not work if there any any semi-significant UI changes.

However, a friend I was playing with really missed the "view all kingdom cards at once" functionality that the old client had, so I hacked together a simple mod that can be run from your javascript console, which will replace all of the main kingdom cards' images with their description text. The process is rather painful, so this is more proof of concept than anything else:

1) Run this first:

angular.reloadWithDebugInfo()

2) This will cause your page to refresh, so you'll have to log in again afterwards. Once logged in, run this next:

var jquery = document.createElement('script');
  jquery.setAttribute('type', 'text/javascript');
  jquery.setAttribute('src', '//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js');
  document.head.appendChild(jquery);


3) This will not have any visible effect. Lastly, once you have a game with the kingdom loaded, and you will have to run this literally every time that you start a new game, run this:

$('[type="kingdom"]>.mini-card-art').css('background-color', 'white').css('background-image', '').toArray().forEach(e => {
var a = $('<div style="z-index: 100; position: absolute; left: 3%; top: 5%; min-width: 287px; text-align: center; min-height: 170px;">');
a.append(LANGUAGE.getCardText[angular.element(e).scope().pile.topCardName]);
$(e).append(a);
});


The end result should look something like this:


ewz

Hey, I think I found something that will work even better (still requires a little web tool hacking):

Note: this only works while you're in an actual game.

1. Copy the following text:


javascript: (function(){var el=document.createElement('div'),b=document.getElementsByTagName('body')[0];otherlib=false,msg='';el.style.position='fixed';el.style.height='32px';el.style.width='220px';el.style.marginLeft='-110px';el.style.top='0';el.style.left='50%';el.style.padding='5px 10px';el.style.zIndex=1001;el.style.fontSize='12px';el.style.color='#222';el.style.backgroundColor='#f99';if(typeof%20jQuery!='undefined'){msg='This%20page%20already%20using%20jQuery%20v'+jQuery.fn.jquery;return%20showMsg();}else%20if(typeof%20$=='function'){otherlib=true;}%20function%20getScript(url,success){var%20script=document.createElement('script');script.src=url;var%20head=document.getElementsByTagName('head')[0],done=false;script.onload=script.onreadystatechange=function(){if(!done&&(!this.readyState||this.readyState=='loaded'||this.readyState=='complete')){done=true;success();script.onload=script.onreadystatechange=null;head.removeChild(script);}};head.appendChild(script);}%20getScript('//code.jquery.com/jquery-latest.min.js',function(){if(typeof%20jQuery=='undefined'){msg='Sorry,%20but%20jQuery%20wasn\'t%20able%20to%20load';}else{msg='This%20page%20is%20now%20jQuerified%20with%20v'+jQuery.fn.jquery;if(otherlib){msg+='%20and%20noConflict().%20Use%20$jq(),%20not%20$().';}}%20return%20showMsg();});function%20showMsg(){el.innerHTML=msg;b.appendChild(el);window.setTimeout(function(){if(typeof%20jQuery=='undefined'){b.removeChild(el);}else{jQuery(el).fadeOut('slow',function(){jQuery(this).remove();});if(otherlib){$jq=jQuery.noConflict();}}},2500);}})();


- Dominion.games does not have jquery installed, this code, when run in the URL will add jquery to any page.

2. Create a new bookmark in your browser, call it "jQuerify"

3. In the Edit Bookmark window, paste the code into the 'URL'

4. Save the bookmark. Now, whenever you press this button, jquery will be added to the page.

5. Now you can easily manipulate a lotta stuff, so run this in your console (F12) to get the art replaced with the card's text:

$('.card-name').map((i,v) => {
var cardName = $(v).text()
var cardText = window.EnglishCardTexts[cardName]
var parent = $(v).parents('.mini-card')
var cardArt = $(parent).children('.mini-card-art')
if(cardText != '')
$(cardArt).css('background','white').html(cardText)
})


Also, there is probably a way to do this without jQuery, so I'll try to figure that out later.