Parse new set card data from MTG-Salvation
Moderators: North, BetaSteward, noxx, jeffwadsworth, JayDi, TheElk801, LevelX, CCGHQ Admins
Parse new set card data from MTG-Salvation
by LevelX » 09 Aug 2017, 05:20
Retrieving card Data from MTG-Salvation Spoiler
Open Opera/chrome and go to the Spoiler page
Push CRTL + SHIFT + I to open the Opera debugger or the command to open the Chrome console
Go to the console tab and post the script
Change the set name in Line number 5
Push return
mark the output and copy it to the mtg-cards-data.txt file.
Open Opera/chrome and go to the Spoiler page
Push CRTL + SHIFT + I to open the Opera debugger or the command to open the Chrome console
Go to the console tab and post the script
Change the set name in Line number 5
Push return
mark the output and copy it to the mtg-cards-data.txt file.
- Code: Select all
(function(){
var x = '';
function printCard(card){
var text = '';
text += card.name + '|[ENTER HERE THE SET NAME]|';
text += (card.number ? card.number : '') + '|';
text += card.rarity[0].replace('B', 'L') + '|';
text += ((card.cost.length > 0) ? '{' : '') + card.cost.join('}{') + ((card.cost.length > 0) ? '}|' : '|');
text += card.type + '|';
text += (card.pt ? card.pt.split('/').join("|") : '|') + '|';
text += (card.abilities ? card.abilities.join('$') : '') + '|';
return text;
}
$.each($('table[cellpadding=5]'), function(index, value) {
var $value = $(value);
var card = {};
card.name = $value.find('td[width=220px]:eq(0) a:eq(1)').attr('name');
card.cost = [];
$.each($value.find('td[width=80px]:eq(0) img'), function(idx, val) {
card.cost.push(val.alt.toUpperCase());
});
card.type = $value.find('td[width=220px]:eq(1)').text();
card.rarity = $value.find('td[width=80px]:eq(1) img').attr('alt');
var findResult = $value.find('td[colspan=2]:eq(0)');
if(findResult.length > 0){
var text = findResult.html().replace(/<img src="http:\/\/forums.mtgsalvation.com\/images\/smilies\/[\w\d]+?.gif" alt="/g, '{');
text = text.replace(/">/g, '}');
text = text.replace(/{{/g, '{');
text = text.replace(/}}/g, '}');
text = text.replace(/(\r\n|\n|\r)/gm,"");
card.abilities = text.split('<br>');
}
findResult = $value.find('tr:last i')
if(findResult.length > 0){
card.number = findResult.html().replace('#', '').split('/')[0];
}
findResult = $value.find('tr:last td:last')
if(findResult.length > 0){
card.pt = findResult.html();
}
if(card.name.indexOf('//') != -1){
var card1 = {};
var card2 = {};
card1.name = card.name.split(' // ')[0];
card2.name = card.name.split(' // ')[1];
card1.cost = card.cost;
card2.cost = [];
card1.rarity = card.rarity;
card2.rarity = card.rarity;
card1.type = card.type.split(' // ')[0];
card2.type = card.type.split(' // ')[1];
card1.pt = card.pt.split(' // ')[0];
card2.pt = card.pt.split(' // ')[1];
if(card.number){
card1.number = card.number;
card2.number = card.number;
}
var first = true;
card1.abilities = [];
card2.abilities = [];
for(var i = 0; i < card.abilities.length; i++){
if(card.abilities[i].indexOf('//') != -1 || card.abilities[i].indexOf('--') != -1){
first = false;
}else if (card.abilities[i].length > 0) {
if(first){
card1.abilities.push(card.abilities[i]);
}else{
card2.abilities.push(card.abilities[i]);
}
}
}
x += printCard(card1) + '\n';
x += printCard(card2) + '\n';
}else{
x += printCard(card) + '\n';
}
});
console.log(x);
})();
-
LevelX - DEVELOPER
- Posts: 1677
- Joined: 08 Dec 2011, 15:08
- Has thanked: 174 times
- Been thanked: 374 times
Re: Parse new set card data from MTG-Salvation
by victoryearing » 14 Jan 2025, 07:33
Push CRTL + SHIFT + I to open the Opera debugger or the command to open the Chrome console
- victoryearing
- Posts: 2
- Joined: 25 Nov 2024, 07:46
- Has thanked: 0 time
- Been thanked: 0 time
2 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 2 guests