It is currently 20 Apr 2024, 00:28
   
Text Size

Quickly Donwload Decks from starcitygames

Moderators: timmermac, Blacksmith, KrazyTheFox, Agetian, friarsol, CCGHQ Admins

Quickly Donwload Decks from starcitygames

Postby DonRagout » 03 Nov 2015, 12:46

Hi,

i created a little javascript snippet to quickly create forge decks out of starcitygames deck listings. Because i am new i can't post the code to the example page. just go to starcitygames and append "/article/29003_JaliraPOW.html" to the url.

it only works for commander decks because these are the ones i use the most.
Here's what it does (see screenshot for details):

It uses the title "Jalira, Master Polymorphist" as the deckname and also as the commander. The format is selected from the upper right banner.

then all the cards are selected. If a card has the same name as the title it is kicked out because this card is already our commander.

Code: Select all

$('.deck_listing').each(function(){
   var title = $('.deck_title',$(this)).text();
   var fortmat = $('.deck_format',$(this)).text();
   var cards = "";
   $('ul[rel] li',$(this)).each(function(){
      if($(this).text().indexOf(title)<0)
      cards += $(this).text() + "\n";
   });

   download("starcity_" + title + ".dck", "[metadata]\nName=starcity_" + title + " \n[general]\nConstructed \n[commander]\n1 " + title + " \n[main]\n" + cards+"\n[sideboard]");

});

function download(filename, text) {
  var element = document.createElement('a');
  element.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(text));
  element.setAttribute('download', filename);

  element.style.display = 'none';
  document.body.appendChild(element);

  element.click();

  document.body.removeChild(element);
}
To use it just copy the javascript code into the console of your browser an run it. It will download all found decks on the current page.

Known Bugs:
If the title is not the exact commander name, then your deck will have an invalid commander and too many cards.

When i find the time i will extend the script to support other formats and sites.

any feedback is welcome.
Attachments
stc.png
example listing
DonRagout
 
Posts: 6
Joined: 03 Nov 2015, 11:23
Has thanked: 3 times
Been thanked: 0 time

Return to Forge Decks

Who is online

Users browsing this forum: No registered users and 54 guests


Who is online

In total there are 54 users online :: 0 registered, 0 hidden and 54 guests (based on users active over the past 10 minutes)
Most users ever online was 4143 on 23 Jan 2024, 08:21

Users browsing this forum: No registered users and 54 guests

Login Form