ttadvance.ca

Triple Triad Advance Forums
It is currently Thu Oct 18, 2018 8:47 pm

All times are UTC - 4 hours




Post new topic Reply to topic  [ 19 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: 'Sell all dupes' option
PostPosted: Thu Nov 06, 2014 9:35 am 
Offline
User avatar

Joined: Mon Jul 24, 2006 2:29 am
Posts: 7
Location: Outside of Midgar
TTA ID: 0
TTN ID: 0
When your hunting one card you chalk up all the useless dupes real quick when buying packs. So you got 20x of 'useless dupe' in order to sell them all back you gotta click it many times to sell them back to get the points. Your hand gets sore plus you'll waste all kinds of time. Why not have a 'sell all dupes' option in order to spare your time/hand. If you got 20x a dupe make a option to 'sell all' on dupes of this card so instead of having to click sell back 20 times it would give you the pts for one click. Would be AWESOME for ttn as well. I can't be the only person on this site to think this way. Would be a GREAT addition to the current upgrades on TTA/TTN. Thanks.

_________________
Image


Top
 Profile  
 
PostPosted: Thu Nov 06, 2014 10:56 am 
Offline
User avatar

Joined: Sat Jun 01, 2013 9:47 pm
Posts: 30
Location: Brazil
TTA ID: 91126
TTN ID: 0
GMT: -3
Could also have an option to show all dupes and have a check box and text field beside each one to be able to select which and how many we want to sell!

:)

_________________
Proud member of |AT|
Collecting CT Card - Roly (ID#1108)
1108, Roly, Level: 1, values: 3, 4, 3, 2. You have 10

Image


Top
 Profile  
 
PostPosted: Thu Nov 06, 2014 1:25 pm 
Offline
User avatar

Joined: Wed Mar 14, 2007 3:33 pm
Posts: 526
Location: Austria
TTA ID: 10827
TTN ID: 926
GMT: +1
Cloud-Strife wrote:
When your hunting one card you chalk up all the useless dupes real quick when buying packs. So you got 20x of 'useless dupe' in order to sell them all back you gotta click it many times to sell them back to get the points. Your hand gets sore plus you'll waste all kinds of time. Why not have a 'sell all dupes' option in order to spare your time/hand. If you got 20x a dupe make a option to 'sell all' on dupes of this card so instead of having to click sell back 20 times it would give you the pts for one click. Would be AWESOME for ttn as well. I can't be the only person on this site to think this way. Would be a GREAT addition to the current upgrades on TTA/TTN. Thanks.


and what would happen if you blow pts to packs and unnoticingly you get dupe/s of a rare and sell it/them unknowlingy with that button ... maye be a rare occassion but sure could happen.

_________________
Dont let the soothing light at the end of the tunnel be a train coming your way.


Top
 Profile  
 
PostPosted: Tue Nov 11, 2014 7:16 pm 
Offline
User avatar

Joined: Mon Jul 24, 2006 2:29 am
Posts: 7
Location: Outside of Midgar
TTA ID: 0
TTN ID: 0
justl wrote:
Cloud-Strife wrote:
When your hunting one card you chalk up all the useless dupes real quick when buying packs. So you got 20x of 'useless dupe' in order to sell them all back you gotta click it many times to sell them back to get the points. Your hand gets sore plus you'll waste all kinds of time. Why not have a 'sell all dupes' option in order to spare your time/hand. If you got 20x a dupe make a option to 'sell all' on dupes of this card so instead of having to click sell back 20 times it would give you the pts for one click. Would be AWESOME for ttn as well. I can't be the only person on this site to think this way. Would be a GREAT addition to the current upgrades on TTA/TTN. Thanks.


and what would happen if you blow pts to packs and unnoticingly you get dupe/s of a rare and sell it/them unknowlingy with that button ... maye be a rare occassion but sure could happen.


I'm thinking something similar to Darklion's idea. When you go to sell back cards for each level you got a page full of 'useless dupe you have 20' Maybe make a box that when you click it gives you the option to sell back all dupes for each card. For example check box for 'sell all dupes' then go down the list when you see 'you got 20 useless dupe' when you click to sell it with the box checked it will give you the options of ' sell back useless dupe x 19 for so and so points' This way you don't have to click sell back 19 times for that card. Get it now? A sell back entire page would also be nice as well but then you would have to make damn sure a rare is not on there.

_________________
Image


Top
 Profile  
 
PostPosted: Wed Nov 12, 2014 10:03 am 
Offline
User avatar

Joined: Fri Dec 28, 2012 11:28 pm
Posts: 208
TTA ID: 115148
TTN ID: 0
GMT: +1
Yes please.


Top
 Profile  
 
PostPosted: Wed Apr 29, 2015 3:38 pm 
Offline
User avatar

Joined: Sat Apr 04, 2015 5:40 pm
Posts: 294
TTA ID: 119773
TTN ID: 0
If anyone is interested, I could make a "button" for this where you sell all dupes on a particular level in one button click, and you can have a list of "exceptions", cards you don't want to sell, like unlocks or rares etc. Somebody asked for this, and I want to see if people are interested, and if they are I could make this. I don't think it would be very hard to make.

_________________
Image
Most losses by far!


Top
 Profile  
 
PostPosted: Wed Apr 29, 2015 5:58 pm 
Offline
lost in the oversoul
User avatar

Joined: Sat Sep 02, 2006 1:47 am
Posts: 116
Location: With The Pyreflies
TTA ID: 30237
TTN ID: 0
GMT: +9,5
Triad Freak wrote:
If anyone is interested, I could make a "button" for this where you sell all dupes on a particular level in one button click, and you can have a list of "exceptions", cards you don't want to sell, like unlocks or rares etc. Somebody asked for this, and I want to see if people are interested, and if they are I could make this. I don't think it would be very hard to make.

You would have to program it automatically to skip unlocks/semis/rares/quest cards. Im sure people will use it when the next deck comes out anyway.

_________________
Image


Top
 Profile  
 
PostPosted: Wed Apr 29, 2015 6:19 pm 
Offline
User avatar

Joined: Fri Dec 28, 2012 11:28 pm
Posts: 208
TTA ID: 115148
TTN ID: 0
GMT: +1
Triad Freak wrote:
If anyone is interested, I could make a "button" for this where you sell all dupes on a particular level in one button click, and you can have a list of "exceptions", cards you don't want to sell, like unlocks or rares etc. Somebody asked for this, and I want to see if people are interested, and if they are I could make this. I don't think it would be very hard to make.


I'm interested.


Top
 Profile  
 
PostPosted: Thu Apr 30, 2015 12:55 am 
Offline
User avatar

Joined: Sat Apr 04, 2015 5:40 pm
Posts: 294
TTA ID: 119773
TTN ID: 0
Okay, so I'm almost done writing the script now, at least the first version.

I could probably write a script that makes it so you can sell every dupe card you have, but it would be a bit more complex and complicated, and there may be some restrictions with the greasemonkey interface to stop me from doing certain calls, so I'm not sure if it's even possible, and then there's the fact that I would need to load several pages to fetch all the IDs etc.

So what I did write was a script that allow you to sell all dupe cards on the page you're on, in other words, all dupe cards on a specific level, and that with just a single button click.

I've also allowed for an "exclude" and "include" list.

In the exclude list you may want to add the ID of rares, unlocks and other cards you don't want to sell. I will make it default that it has all the semi, rares and unlocks, but when FFXIV is released, it will need to be updated. I will post it as soon as I can, but else you gotta do it yourself.

If you add something to the include list, it will not select any card that is not in the include list, and it will still exclude the card if it's in the exclude list. I will try to make a list for each deck, so you kind of have a filter to only sell cards from a specific deck etc.

I will make it so you can see how many cards are selected, and add a button that prints all the cards that are selected in a list to your screen, so you can check this, make sure it doesn't include any card you don't want to sell etc and feel safer before just clicking the button and selling off a lot of cards. This list could be with an image of each card, if that is wanted, but this requires more work, so if it's not wanted, I won't do it!!

If people want to, I can make it so you have to click the button twice before you sell the cards, or so you get a popup saying next time you click the button the dupes will be sold or something like that.

If anyone got any wants or needs etc, please tell me about it as soon as possible. xD

_________________
Image
Most losses by far!


Top
 Profile  
 
PostPosted: Thu Apr 30, 2015 8:56 am 
Offline
User avatar

Joined: Sat Apr 04, 2015 5:40 pm
Posts: 294
TTA ID: 119773
TTN ID: 0
Okay, done writing the first version of this script. It should add a button at the bottom of the sell cards screens and will sell all dupes on the page it is currently on. You can view what cards it will sell and how many etc by pressing the view cards button below. This can be a way for you to feel safe about using the function if you mess around with the "filters". It by default filters all semis, rares, unlocks and quest cards, at least the ones that has been released so far. I've also added some options to only sell from specific decks and your excluded cards still apply then. After the UserScript part there is a big bulk of text you may want to read if you want to understand the exclude and include filters. :) I've documented the entire code very well, so most people, even those code illiterate should be able to understand most of it without too much headache, and as such, you can feel more safe that it's not malicious code. If you find any bugs, please tell me about it!

This script was written to be used with Greasemonkey, which is really a Firefox extension that allows JavaScript to run after the page has loaded. You are in no way messing with the server or anything like that, it's all client-side, though in this case with some requests for various pages from the server, which you normally would have done anyways to sell the cards. Chrome has it's own version, which works pretty much the same, called Tampermonkey. There is also one for Opera called Violent monkey.

How to install and edit etc:
  1. You need to install the appropriate extension/add-on/plug-in for your web browser. Should be easy to find with the information given earlier and google.
  2. The next step is installing/adding the script I wrote. Depending on version of web browser and extension/add-on/plug-in there are different ways to do this. Usually there is some kind of button or option for this in the upper right corner or something, or maybe under one of the menus in the upper left. You will probably be asked for name, namespace, match/site etc, just use the information found below in the actual script until it allows you edit the script. Here you should copy/paste the entire code into whatever editor. Newest version of Firefox made me type in some letters before I was allowed to copy/paste the first time, this to avoid people just copy/pasting whatever they find on the internet. Afterwards you should save the script.
  3. When you now visit the sell cards pages, you should have some buttons at the bottom of the screen. If you don't, then please tell me about it here in this thread and I will help you fix whatever you have done wrong.
  4. To edit the script, there should be some kind of option somewhere in your web browser to edit the scripts. I know in Firefox you can find them under User Scripts, but you gotta right click on them to be able to select to edit them. In chrome I can press the button in the upper right corner and Dashboard or manage script or something like that. Read my comments carefully before you edit anything in the code. The upper parts of the code after the "UserScript" part is meant to be edited to include or exclude cards etc.

EDIT:
I added a checkbox you can check to see images instead of the ids of the dupe cards that has been selected when clicking on the view dupes button.

2nd EDIT:
I added an option in the actual script, where you can set how many you want to keep of a card. It's set to 1, and you can't sell the last card anyways, so don't even try to set it to 0, but you this allows you to be able to keep 2 of each card, if that's your thing. You will find this option below the "filters", and it should say "var keep = 1;", just change 1 to 2, to keep 2. :)

Code:
// ==UserScript==
// @name         Sell All Dupes
// @namespace    sellDupes
// @version      0.965
// @description  Lets you sell lots of dupes in one button click
// @author       Triad Freak
// @match        http://www.ttadvance.ca/sell*
// @grant        none
// @require      http://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js
// ==/UserScript==

/*
Here you set what to exclude and what to include etc. None of the cards that
are excluded will be added to the list of dupes to be sold. If there are any
cards included, then only these will be added to the list of dupes to be sold.
Excluded cards won't be added to the list, even if they are included. This
allows you to include a whole deck and exclude it's rares and unlocks etc.
By default I've gone ahead and excluded all the semis, rares, unlocks and
quest cards. If a new deck gets added, you will need to updates these lists
manually. Most likely I will post a new version of the entire script if you
don't dare to touch it. The lists are first declared, and then you can let
them be added to the excluded or the include list. This is easily done by for
example have a new line with, "exclude = exclude.concat(nameOfList);", and
instead of deleting useful/reusable lines, you may want to just comment them
out using double slash, like this, "//exclude = exclude.concat(nameOfList);".
You can make your own lists too, if you think you got the hang of it. I made
otherExclude and otherInclude specifically for this, where you can add your
own cards. There's so many examples below, it shouldn't be hard to understand
if you take a minute to look at it and try to understand what is being done
and just copy what is already there. I've also commented and explained what
the entire script does, so you can read through it and understand what it
does, so you shouldn't need to worry about if there is some kind of malicious
code I'm offering.
*/

// declarations of lists etc
// use otherExcluded and otherIncluded for custom exclusions or inclusions
var exclude = [];
var include = [];
var otherExclude = [];
var otherInclude = [];
var semis = [20, 429, 547, 861, 979, 1395, 1549, 1550, 1591, 1672, 2006, 2107,
2241];
var rares = [165, 214, 216, 264, 534, 598, 648, 657, 658, 769, 848, 1059,
1097, 1163, 1259, 1315, 1436, 1442, 1447, 1622, 1745, 1826, 1861, 1971, 2056,
2116, 2138, 2230];
var unlocks = [85, 207, 316, 426, 537, 642, 757, 975, 1222, 826, 71, 1071,
970, 982, 106, 218, 321, 430, 540, 764, 561, 127, 689, 800, 1235, 265, 950,
79, 543, 1775, 160, 378, 623, 304, 860];
var quest = [1893, 1894, 1895, 1896, 1897, 1898, 1899, 1900];

// SE is two lines, and by default not excluded, no point really
//var SE = []; for(var i=0; i<33; i++) { SE[i] = i+1310; SE[i+33] = i+2242; }
//for(var i=0; i<11; i++) SE[i+66] = i+2121;

// remove the double slash before a deck to use the deck
// by default ignored because they use unnecessary resources
//var deckFFO     = []; for(var i=0; i<110; i++) deckFFO[i]     = i+   1;
//var deckFFIV    = []; for(var i=0; i<110; i++) deckFFIV[i]    = i+ 111;
//var deckFFV     = []; for(var i=0; i<110; i++) deckFFV[i]     = i+ 221;
//var deckFFVI    = []; for(var i=0; i<110; i++) deckFFVI[i]    = i+ 331;
//var deckFFVII   = []; for(var i=0; i<110; i++) deckFFVII[i]   = i+ 441;
//var deckFFVIII  = []; for(var i=0; i<110; i++) deckFFVIII[i]  = i+ 551;
//var deckFFVIIIr = []; for(var i=0; i<110; i++) deckFFVIIIr[i] = i+1343;
//var deckFFIX    = []; for(var i=0; i<110; i++) deckFFIX[i]    = i+ 661;
//var deckFFX     = []; for(var i=0; i<110; i++) deckFFX[i]     = i+ 771;
//var deckX2      = []; for(var i=0; i<110; i++) deckX2[i]      = i+1783;
//var deckFFXI    = []; for(var i=0; i<110; i++) deckFFXI[i]    = i+1673;
//var deckFFXII   = []; for(var i=0; i<110; i++) deckFFXII[i]   = i+1901;
//var deckFFXIII  = []; for(var i=0; i<110; i++) deckFFXIII[i]  = i+2011;
//var deckFFT     = []; for(var i=0; i<110; i++) deckFFT[i]     = i+ 881;
//var deckCT      = []; for(var i=0; i<110; i++) deckCT[i]      = i+1101;
//var deckDL      = []; for(var i=0; i<110; i++) deckDL[i]      = i+ 991;
//var deckDQ      = []; for(var i=0; i<110; i++) deckDQ[i]      = i+1453;
//var deckS3      = []; for(var i=0; i<110; i++) deckS3[i]      = i+1563;
//var deckS5      = []; for(var i=0; i<110; i++) deckS5[i]      = i+2132;
//var deckXG      = []; for(var i=0; i<110; i++) deckXG[i]      = i+1211;

// here the lists are added to exclude or include
// just add two slashes before it to ignore the list being added
exclude = exclude.concat(otherExclude);
exclude = exclude.concat(semis);
exclude = exclude.concat(rares);
exclude = exclude.concat(unlocks);
exclude = exclude.concat(quest);
//exclude = exclude.concat(SE);
include = include.concat(otherInclude);
// remember to remove double slashes from deck lists you want to use
//include = include.concat(deckFFO);
//include = include.concat(deckFFIV);


// You can change this option to match how many of a card you want to have
// left after selling off rest of the dupes. It's by default set to one,
// and setting it lower than one is pointless because you can't sell off
// non-dupes this way.
var keep = 1;

// everything from here on and down is just code, you don't need to read,
// understand or edit any of it... :)

// to avoid any potential jQuery conflict with web page
// probably isn't needed, but just in case of future
// implementations
this.$ = this.jQuery = jQuery.noConflict(true);

function getDupeAmounts(main)
{
   // declaring amounts array, where amounts will be stored
   // and later be returned
   var amounts = [];
   // gets the text from the main tag
   // it contains a lot of data, but we just want the numbers
   // after "x " in the order they appear
   var tc = main.textContent;
   // a regular expression to match each amount number
   // looks for "x " and captures the numbers following
   // g makes us able to get all the matches
   var a, regexp = /x (\d+)/g;
   // loops through each match, which are the amounts in "correct" order
   while(a = regexp.exec(tc))
   {
      // adds the captured number to the array
      // first index, because we want the first sub match
      // what was inside the ( and ), namely the number "\d+"
      // parseInt to get the number instead of as a text string
      // -1 to get the "dupe amount", and not the actual amount
      amounts.push(parseInt(a[1])-keep);
   }
   return amounts;
}

function getImgURLs(main)
{
   var i, urls = [], img = main.getElementsByTagName("img");
   for(i=0; i<img.length; i++)
   {
      urls.push(img[i].getAttribute("src"));
   }
   return urls;
}

function getCards()
{
   // declaring some variables to be used later
   // cardsSelected is what this function will return and should
   // contain the ids of all the cards you want to sell
   var i, card, cardsSelected = [];
   // gets the tag with the "Main" id, which is a big table that
   // surrounds the list of cards that be sold
   var main = document.getElementById("Main");
   // gets all the anchor tags, which contains the url to sell each
   // card, which also happens to have it's id
   var cardsOnPage = main.getElementsByTagName("a");
   // fetching all the amounts, which is somewhat complicated, so
   // I decided to use an own function for this, but it does it using
   // the element/tag that had the "Main" id, and by looking at the
   // values after each "x ".
   var amounts = getDupeAmounts(main);
   // fetching all the cards image urls, so you can view the images
   // and not just the id number
   var urls = getImgURLs(main);
   for(i=0; i<cardsOnPage.length; i++)
   {
      // get the anchor element's href attribute, which is the url it
      // links to, for then to only get character at position 22 and out
      // which should be the id of the card in text string format
      // it's rather important that this function gets the correct card id
      // parseInt is to get the card ID as a number, not a text string
      card = parseInt(cardsOnPage[i].getAttribute("href").substr(22));
      // if it doesn't exist in the excluded array and
      // if either the include array is empty or it
      // is in the included array
      // and there needs to be more than 0 of it
      if(exclude.indexOf(card)===-1 &&
        (include.length===0 || include.indexOf(card)!==-1) &&
        (amounts[i] > 0))
      {
         // add the id, amount and image url to the selected card array
         cardsSelected.push({"id": card, "amount": amounts[i],
            "url": urls[i]});
      }
   }
   // returning the array of the selected cards
   return cardsSelected;
}

function sellCards()
{
   // adds the "confirm" pop up window before you sell all the dupe cards
   // this is so you don't just accidentally sell of all the dupes by
   // clicking on the button without the intention of selling all dupes
   if(!window.confirm("Do you want to sell the dupes?")) return;
   var i, a, sold = 0;
   // loops through all the cards
   for(i=0; i<cards.length; i++)
   {
      // sends one per amount (which if you have two cards should be one)
      // even if it was wrong, which is absolutely shouldn't be, you can't
      // sell cards you got one of in this way
      for(a=0; a<cards[i]["amount"]; a++)
      {
         // this is the actual function call that purchases the card!
         // it sends an empty form to the specified url, which contains
         // the id of the card you are selling.
         // $.post is a jQuery function, which is why jQuery is required
         // you can comment the next two lines (double slash) to just
         // test everything without risking to sell anything!!
         $.post("scard.php?card_iden="+cards[i]["id"],
            {}, function(data, status){});
         sold+=1;
      }
   }
   // just gives you a message about how many cards have been sold!
   alert("sold " + sold + " cards!");
   // reloads the page, so you can see the cards have been sold
   location.reload();
}

function viewCards()
{
   // getting the parent main
   var mainParent = document.getElementById("Main").parentElement;
   // get checkbox check value
   var cbv = document.getElementById("viewCardsCheckbox").checked;
   // checking if the correct table is already up
   // and if the wrong is up, deleting it
   if(cbv)
   {
      if(document.getElementById("dupeimgtable")) return;
      if(document.getElementById("dupetable"))
         mainParent.removeChild(document.getElementById("dupetable"));
   }
   else
   {
      if(document.getElementById("dupetable")) return;
      if(document.getElementById("dupeimgtable"))
         mainParent.removeChild(document.getElementById("dupeimgtable"));
   }
   var i, tr, th, td, img, table = document.createElement("table");
   // adds a "unique" id to the table to avoid it being added twice
   if(cbv) table.setAttribute("id", "dupeimgtable");
   else    table.setAttribute("id", "dupetable");
   // adds a row with columns of the header for the table
   tr = document.createElement("tr");
   th = document.createElement("th");
   th.textContent = (cbv?"card":"id");
   tr.appendChild(th);
   th = document.createElement("th");
   th.textContent = "dupes";
   tr.appendChild(th);
   table.appendChild(tr);
   for(i=0; i<cards.length; i++)
   {
      // adds rows with columns of id and amount to the table
      tr = document.createElement("tr");
      td = document.createElement("td");
      if(cbv)
      {
         // adding the image
         img = document.createElement("img");
         img.src = cards[i]["url"];
         td.appendChild(img);
      }
      else
      {
         // adding the card id
         td.textContent = cards[i]["id"];
         td.setAttribute("align", "right");
      }
      tr.appendChild(td);
      td = document.createElement("td");
      td.textContent = cards[i]["amount"];
      td.setAttribute("align", "right");
      tr.appendChild(td);
      table.appendChild(tr);
   }
   // adds it at the end of the page
   mainParent.appendChild(table);
}

function addCardsToSite(cards)
{
   // creates a new HTML element called script
   // to add javascript to the actual page
   var cardArray = document.createElement("script");
   cardArray.setAttribute("type", "application/javascript");
   // this adds the script to the element
   // the script is basically a declaration of
   // the array with all the selected cards
   // JSON.stringify is to turn the returned card array to a string
   // this is to be able to access the array after the script is done running
   cardArray.textContent = "var cards = " + JSON.stringify(getCards()) + ";";
   // adding the newly created element to the actual page
   document.body.appendChild(cardArray);
}

function countDupes()
{
   var i, c = 0;
   // loops through all the cards
   for(i=0; i<cards.length; i++)
   {
      // adds amount of dupes of the card to the counter
      c += cards[i]["amount"];
   }
   // returns the counter
   return c;
}

function addSellDupesButtonToSite()
{
   // adds a "br" tag, which is basically a "new line" character
   document.getElementById("Main").parentElement.appendChild(document.createElement("br"));
   // creates a new input element, which is an actual button
   var button = document.createElement("input");
   button.setAttribute("type", "button");
   button.setAttribute("id", "sellAllCards");
   button.setAttribute("value", "Sell " + countDupes() + " Dupes of " +
      cards.length + " Different Cards!");
   // adding it to the bottom of the page, after the end of the tag with the id Main
   document.getElementById("Main").parentElement.appendChild(button);
   // adding what it will actually do when you click the button
   // which is to call the function sellCards
   document.getElementById("sellAllCards").addEventListener("click", sellCards, true);
}

function addViewDupesButtonToSite()
{
   // gets the parent tag of main
   var mainParent = document.getElementById("Main").parentElement;
   // adds a "br" tag, which is basically a "new line" character
   mainParent.appendChild(document.createElement("br"));
   mainParent.appendChild(document.createElement("br"));
   // adds a check box so you can view images instead of just ids
   var checkbox = document.createElement("input");
   checkbox.setAttribute("type", "checkbox");
   checkbox.setAttribute("id", "viewCardsCheckbox");
   mainParent.appendChild(checkbox);
   // adding "imgs" text next to the checkbox
   mainParent.insertBefore(document.createTextNode("imgs: "), checkbox);
   // adds another "br" tag, which is basically a "new line" character
   mainParent.appendChild(document.createElement("br"));
   // creates a new input element, which is an actual button
   var button = document.createElement("input");
   button.setAttribute("type", "button");
   button.setAttribute("id", "viewCards");
   button.setAttribute("value", "View Dupes!");
   // adding it to the bottom of the page, after the tag with the id Main
   mainParent.appendChild(button);
   // adding what it will actually do when you click the button
   // which is to call the function viewCards
   document.getElementById("viewCards").addEventListener("click", viewCards, true);
   // adding checkbox for if you want to view the images of the cards
}

function addSellButtons(cards)
{
   // adds the array of cards to the site
   addCardsToSite();
   // adds the sell dupes button to the site
   addSellDupesButtonToSite();
   // adds the view dupes button to the site
   addViewDupesButtonToSite();
}

// creates the sell dupes button and the view dupes button
addSellButtons();

_________________
Image
Most losses by far!


Last edited by Triad Freak on Fri May 01, 2015 11:03 am, edited 3 times in total.

Top
 Profile  
 
PostPosted: Thu Apr 30, 2015 11:32 am 
Offline
User avatar

Joined: Wed Mar 14, 2007 3:33 pm
Posts: 526
Location: Austria
TTA ID: 10827
TTN ID: 926
GMT: +1
i would rather ask balz if you can use that script - even if its user-side.

its his site and every intrusion from outside - may it only be the browserscript - could lead to unforeseen consequences.

justl

_________________
Dont let the soothing light at the end of the tunnel be a train coming your way.


Top
 Profile  
 
PostPosted: Thu Apr 30, 2015 9:24 pm 
Offline
User avatar

Joined: Sat Apr 04, 2015 5:40 pm
Posts: 294
TTA ID: 119773
TTN ID: 0
justl wrote:
i would rather ask balz if you can use that script - even if its user-side.

its his site and every intrusion from outside - may it only be the browserscript - could lead to unforeseen consequences.

justl


Intrusion??? Balz has made the UI, and I can't do anything he hasn't already allowed me to do. I just help the users use what Balz has provided, allowed and intended a bit more efficiently. Has absolutely nothing to do with any kind of intrusion.

Unforeseen consequences???

This is sort of an impossible to reach standard, seeing as it would be unforeseeable. Don't think I haven't thought about the implications of this script though, hence why at least this version doesn't allow you to sell absolutely all your dupe cards, because I could have done that. I hope you read this entire post, because I wrote it for you!

It does nothing you can't manually do, or will do to sell off the cards. In fact, it does less, because it loads a third of the pages.

There is one bad thing about this, and that is, it spams the server with that sell request, but what is the alternative? You got people doing the same thing manually anyways, and when they do that, they actually do more than twice as many requests, and often loads images again. If anything, this saves the server a lot of headache. You can probably spam the button somehow or something, but there are far more effective ways to cripple the server, because this requests probably just makes the server go and modify one value in the database. Most of the time when you load a page on this site you probably do a more heavy request, like when you go back to your card list and decide what card to sell. So yeah, this saves the server a lot of headache.

While I'd totally say they should use it on their own risk, because there may be some glitch. I've gone over it several times, to make sure everything is correct and you can see the cards that will be sold and can verify etc.

It only collects the cards once, and as such, the cards you see is the exact same as it will try to sell. As long as this is true, it's extremely unlikely some kind of glitch will sell of a dupe rare or anything like that.


So let's dive back into how it can have some kind of unforeseen consequence. What does the script do? I've documented the entire script, and as such you can go over it and read it yourself and see if there is any kind of potential issues with it. I did this thoroughly, because you edited and posted stuff about the create game button.

What it does:
  • Your web browser request the sell cards level page as usual, and it sends it to you, as usual, so your web browser can interpret the HTML and show the web page to you. This is what you normally do, and has nothing to do with the script.
  • What next happens is that the script kicks in, it looks at the web page that has been loaded, only using the information your web browser already have gotten from the server, to collect all the IDs of the cards (which is in their url, which you can see just fine) and the amount of dupes you have. It's as if you did it manually, looking at each card.
  • After this it inserts five things into the web browser's temporary view of the web page. Think about this as me taking a picture of something, and then drawing something on that picture. I did no harm to what I took a picture of, though your picture looks a bit different. These five things are an array (a list) of all the IDs and how many dupes you got of them, a button to sell all of these dupes in the list, some functionality that happens when you click this button, a button to view all the cards in the list, and the functionality to see what happens when you click it.
  • You may wonder what these functions are? Well, they are nothing the web browser can't manually do. Sell the cards does the exact same thing as when you click the button. EXACT SAME THING, I've duplicated it down to the detail. The view is basically just inserting another table after the web site has loaded, and is comparable to drawing on a picture.


If you got any actual questions, then please say so. The only thing I can think of that Balz might not approve of this is if he wants to make it TTA Donator exclusive function. The truth is also that this would have been best done by being implemented by the server. That'd be much more efficient on the server part. Don't need to get a request per card, just do all at once. So if he implements functionality similar to this, then I'd see him having a problem with this, because it would do extra work instead of just pressing his button. As it stands it doesn't do anything to the server you wouldn't have done yourself to be able to sell the cards, in fact, it does less.


EDIT:
To give you some understanding...

1. If you use Chrome, right click, and select Inspect Element.
2. You will probably find yourself under the Elements tab. What you see is your web browsers interpretation of the HTML it received from the server. It (usually) doesn't keep doing requests against the server to get some kind of update or anything like that, and what you see is what you've gotten from the server. It's basically just cosmetic.
3. The script looks through what you've received here. And just add a couple of things to the screen, cosmetic stuff.
4. The sell button is a bit more complicated though, because when you click it, it doesn't send it's form as usual, in fact, it doesn't have a form. Instead what it does is send a form for each card, the same form you would have sent when you click to send the card.
5. Go into the Console tab. Here you can type in JavaScript and do exactly the same thing as the script does. Just try some of the code and see what happens. There is nothing to be afraid of, it's all client side anyways. The only thing that contacts the server is some requests, which is what you do when you load a web page or send in a form etc, but this is still just client side stuff.
6. In my code, $.post (click on it, as I added an URL that will explain what it does), is the function that contacts the server, nothing else does. In my case, all it does is sending a request against the sell card page with the ID of the card in the url. This kind of put me off, because that's really a GET requests, yet, it was placed inside an empty POST request. The data I send is empty, because as I said, empty POST request. Does nothing on success etc, just an empty function.

Code:
         $.post("scard.php?card_iden="+cards[i]["id"],
            {}, function(data, status){});


That is the only thing that contacts the server. The url with the id, empty data ({}, an empty dictionary), and a function that takes data and status as parameter for what is returned from the website when the request is done, but does nothing with it. That's all.

I can somewhat understand why Balz has decided to do the button that way, but it's kind of wrong, at least in some sense.
Code:
<form method=post action=scard.php?card_iden=89><center>
<img src = http://www.ttadvance.ca/FFO/Mindu.jpg border =0><font size="2" face=Calabri, Arial color="#FFFFFF"> x 2<br> Do You Want To Sell Mindu For 43 Points?&nbsp;&nbsp;
<input type="submit" value="Sell Card" style="border: #990000; border-style: solid; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px ; color: #FFFFFF; background-color: #CC0000"></form>

^ Actual code of what is on that page. This is poor HTML for several reasons, see all that styling stuff, that should have been in the CSS. You also see how he often does things like
Code:
board =0

While this is correct, at least in old HTML versions, this should be:
Code:
board="0"

And he does this often too, so it's a mess of both... :s I think Balz is very aware of all of this at this point though, just a lot of effort to change and doesn't do a whole lot of damage.
Let's remove the styling to get the actual form
Code:
<form method=post action=scard.php?card_iden=89>
<input type="submit" value="Sell Card">
</form>

That's it. That's the form... :p How the forms are "supposed" to be:
Code:
<form method="get" action="scard.php">
<input type="hidden" name="card_iden" value="89">
<input type="submit" value="Sell Card">
</form>

Or if XHTML:
Code:
<form method="get" action="scard.php">
<input type="hidden" name="card_iden" value="89" />
<input type="submit" value="Sell Card" />
</form>


The result isn't really the same, but the server decides to tackle it the same way. It doesn't care that you sent a POST request, and the script Balz has written on the server side handles it as if it was a GET request. So for all intents and purposes, all you're doing is visiting this page:
Code:
http://www.ttadvance.ca/scard.php?card_iden=89


In any case, I do what Balz's HTML does, make you send in a POST request, instead of a GET request, which is how Balz's server side script handles it. lol The point is anyways just to show I do nothing you wouldn't have done normally, just more efficiently.

2nd EDIT:
If you think I come off a bit rough in this post, it's only because I spent many hours doing a lot of research on how to write the script properly, writing the script and testing it to make sure everything works correctly.

_________________
Image
Most losses by far!


Top
 Profile  
 
PostPosted: Tue May 05, 2015 12:11 pm 
Offline
User avatar

Joined: Wed Mar 14, 2007 3:33 pm
Posts: 526
Location: Austria
TTA ID: 10827
TTN ID: 926
GMT: +1
hi,
i took the liberty to ask balz about that, here is his answer:

Balz wrote:
hi =)
nah I don't think he needs my consent to do his browser mod, he is not working for us nor is he offering his browser mod on behalf of TTA.
He's not altering game data and players should question any 'script' someone offers to run on their computer anyway.

_________________
Dont let the soothing light at the end of the tunnel be a train coming your way.


Top
 Profile  
 
PostPosted: Thu May 07, 2015 6:37 am 
Offline
User avatar

Joined: Tue Mar 18, 2008 9:12 am
Posts: 389
Location: Germania
TTA ID: 80716
TTN ID: 0
GMT: +1
Is Triad Freak the savior we need?

_________________
ImageImage
Achievements: World Cup Winner 2014.


Top
 Profile  
 
PostPosted: Thu May 14, 2015 9:53 am 
Offline
User avatar

Joined: Fri Dec 28, 2012 11:28 pm
Posts: 208
TTA ID: 115148
TTN ID: 0
GMT: +1
I just tested it and it worked fine. Thanks a lot.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 19 posts ]  Go to page 1, 2  Next

All times are UTC - 4 hours


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group