ttadvance.ca

Triple Triad Advance Forums
It is currently Sat Nov 17, 2018 3:42 pm

All times are UTC - 4 hours




Post new topic Reply to topic  [ 19 posts ]  Go to page Previous  1, 2
Author Message
PostPosted: Fri May 15, 2015 5:28 am 
Offline
User avatar

Joined: Sat Apr 04, 2015 5:40 pm
Posts: 294
TTA ID: 119773
TTN ID: 0
Akiyama wrote:
I just tested it and it worked fine. Thanks a lot.


How many did you sell, and how long did it take?

EDIT:
He said in chat it took like 1 second per 10 cards sold or something.

_________________
Image
Most losses by far!


Top
 Profile  
 
PostPosted: Tue Jun 30, 2015 9:53 am 
Offline
User avatar

Joined: Sat Apr 04, 2015 5:40 pm
Posts: 294
TTA ID: 119773
TTN ID: 0
Updated the script to reflect the new FFXIV deck. This script allows you to sell all your dupes with filter options etc. It by default filters all the current quest, unlocks, semis and rares etc (so you don't sell off dupes you have of such cards). To use it, you just gotta install an add-on for your web browser called Greasemonkey or Tampermonkey etc and install the below script.

Code:
// ==UserScript==
// @name         Sell All Dupes
// @namespace    sellDupes
// @version      0.966
// @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, 2351, 2384];
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, 2373];
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 deckFFXIV   = []; for(var i=0; i<110; i++) deckXG[i]      = i+2275;
//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!


Top
 Profile  
 
PostPosted: Fri Feb 19, 2016 7:56 pm 
Offline
User avatar

Joined: Sat Apr 04, 2015 5:40 pm
Posts: 294
TTA ID: 119773
TTN ID: 0
I created an entirely new script for selling my dupes. It has a much better GUI where you can filter all kinda stuff, with pre-made filters for each deck, semis, rares, unlocks etc, but you can even enter you own filter. Allows you to save your own filter for each level too. :D Also allow you to see each dupe card that matches the filter etc below, which auto updates as you changes the filter. You can also set how many to keep etc etc. xD

Furthermore, while selling the cards, it will have a cool little menu I created that shows you how many cards you've sold and got left to sell. It still has a prompt before actually selling the cards, just like before, in case you accidentally hit the sell button. :)

The script can be found here:
http://pastebin.com/74LvMm9H

Here's how it looks when you press the "view dupes" button ("hide dupes"):
Image

This menu is found at the bottom of each level's sell dupe page. The cards under "view dupes" is the cards that will be sold, and the "amount" is the amount of dupes that will be sold. The "keep" number is the amount of each card you want to keep.

To use the "custom filter", just input numbers separated by something non-number. Here's some examples:
1,2,3,4
1 2 3 4
1, 2, 3, 4
etc, just each id separated by something not a number :)

Remember to click the save filter button to save the filter for later! :)

_________________
Image
Most losses by far!


Top
 Profile  
 
PostPosted: Fri Sep 07, 2018 4:54 pm 
Offline
User avatar

Joined: Thu Jul 20, 2006 2:11 pm
Posts: 543
Location: England
TTA ID: 51813
TTN ID: 681
Just in case anyone is actually still buying packs, I played around with this script a bit to add FFMQ in.

I'm not a coder by any means, no way I could write this from scratch but I tweaked what was already there and it worked to sell a batch of MQ cards so if anyone isn't already using it I recommend it, it works and saves a hell of a lot of time.

If Triad Freak ever comes back I'm sure he'll find something wrong but it works well enough :P

Code:
// ==UserScript==
// @name        Sell Dupes
// @namespace   ttadvanceSell
// @description Sell Dupes Easily
// @match       http://www.ttadvance.ca/sell*
// @version     0.61
// @grant       none
// @require     http://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js
// ==/UserScript==

function loadFilters(){
  var sf = getDefaultFilter();
  var ssf = JSON.parse(localStorage.getItem(sl));
  for(f in ssf) sf[f] = ssf[f];
  return sf;
}

function saveFilters(){
  var sf = getFilters();
  localStorage.setItem(sl, JSON.stringify(sf));
}

function clearFilters(){
  if(!window.confirm('Clear filters?')) return;
  localStorage.removeItem(sl);
  var sf = getDefaultFilter();
  var i, is = document.getElementById("filters").getElementsByTagName("input");
  for(i=0; i<is.length; i++){
    if(sf[is[i].name]) is[i].checked = true;
    else is[i].checked = false;
  }
  document.getElementById("keep").value = sf["keep"];
  document.getElementById("customFilter").value = sf["custom"];
  updateViewDupes();
}

function addJavaScript(str){
  var script = document.createElement("script");
  script.setAttribute("type", "application/javascript");
  script.textContent = str;
  document.head.appendChild(script);
}

function createInput(type, name, value){
  var input = document.createElement("input");
  input.setAttribute("type", type);
  input.setAttribute("name", name);
  input.setAttribute("value", value);
  return input;
}

function createCheckbox(name, checked){
  var input = document.createElement("input");
  input.setAttribute("type", "checkbox");
  input.setAttribute("name", name);
  return input;
}

function createTh(str){
  var th = document.createElement("th");
  th.textContent = str;
  return th;
}

function createTd(str){
  var td = document.createElement("td");
  td.textContent = str;
  return td;
}

function createImg(src){
  var img = document.createElement("img");
  img.setAttribute("src", src);
  return img;
}

function createA(url){
  var a = document.createElement("a");
  a.setAttribute("href", url);
  return a;
}

function createTdAImg(url, img){
  var td = document.createElement("td");
  var a = createA(url);
  a.appendChild(createImg(img));
  td.appendChild(a);
  return td;
}

function getFilters(){
  var i, t, sf = {}, is = document.getElementById("filters").getElementsByTagName("input");
  for(i=0; i<is.length; i++) sf[is[i].name] = is[i].checked;
  t = parseInt(document.getElementById("keep").value);
  if(t) sf["keep"] = t; else sf["keep"] = 1;
  sf["custom"] = document.getElementById("customFilter").value;
  return sf;
}

function loadDupes(){
  var i, id, amount, img;
  var main = document.getElementById("Main");
  var cop = main.getElementsByTagName("a");
  for(i=0; i<cop.length; i++){
    id = parseInt(cop[i].getAttribute("href").substr(22));
    amount = parseInt(cop[i].nextSibling.data.substring(2));
    img = cop[i].firstChild.getAttribute("src");
    dupes.push({"id": id, "amount": amount, "img": img, "price": prices[id]});
  }
}

function getCards(){
  var i, id, amount, img, cards = [];
  var cf = getCardFilter();
  var keep = parseInt(document.getElementById("keep").value);
  if(!keep) keep = 1;
  for(i=0; i<dupes.length; i++){
    id = dupes[i]["id"];
    if(cf[id]) continue;
    amount = dupes[i]["amount"] - keep;
    if(amount<=0) continue;
    img = dupes[i]["img"];
    cards.push({"id": id, "amount": amount, "img": img, "price": prices[id]});
  }
  return cards;
}

function getDupeTable(){
  var table = document.createElement("table");
  table.setAttribute("id", "dupetable");
  var tr = document.createElement("tr");
  tr.appendChild(createTh("id"));
  tr.appendChild(createTh("img"));
  tr.appendChild(createTh("amount"));
  tr.appendChild(createTh("price"));
  table.appendChild(tr);
  return table;
}

function getCardTr(card){
  var url = "http://www.ttadvance.ca/selcard.php?card_iden="+card["id"];
  var tr = document.createElement("tr");
  tr.appendChild(createTd(card["id"]));
  tr.appendChild(createTdAImg(url, card["img"]));
  tr.appendChild(createTd(card["amount"]));
  tr.appendChild(createTd(card["price"]));
  return tr;
}

function addCardsTable(table){
  var i, cards = getCards();
  for(i=0; i<cards.length; i++) table.appendChild(getCardTr(cards[i]));
  return table;
}

function viewDupes(){
  var vdb = document.getElementById("viewDupes");
  var dupeTable = document.getElementById("dupetable");
  if(dupeTable){
    document.getElementById("Main").parentElement.removeChild(dupeTable);
    vdb.setAttribute("value", "view dupes");
  }else{
    document.getElementById("Main").parentElement.appendChild(addCardsTable(getDupeTable()));
    vdb.setAttribute("value", "hide dupes");
  }
}

function updateViewDupes(){
  var dupeTable = document.getElementById("dupetable");
  if(dupeTable){
    document.getElementById("Main").parentElement.removeChild(dupeTable);
    document.getElementById("Main").parentElement.appendChild(addCardsTable(getDupeTable()));
  }
  updateSellDupesButton();
}

function createButton(str, event){
  var button = document.createElement("input");
  button.setAttribute("type", "button");
  button.setAttribute("value", str);
  button.addEventListener("click", event, true);
  return button;
}

function createFilterInput(name, checked){
  var input = createCheckbox(name, checked);
  input.setAttribute("id", name);
  input.checked = checked;
  input.addEventListener("change", updateViewDupes, true);
  return input;
}

function createFilterInputsLine(i, s, td, sf){
  for(; i<=s; i++){
    if(sf[filter[i]]) td.appendChild(createFilterInput(filter[i], true));
    else td.appendChild(createFilterInput(filter[i], false));
    td.appendChild(document.createTextNode(filter[i]+" "));
  }
}

function createFilterInputs(){
  var td = document.createElement("td");
  var sf = loadFilters();
  createFilterInputsLine(0, 9, td, sf);
  td.appendChild(document.createElement("br"));
  createFilterInputsLine(10, 20, td, sf);
  td.appendChild(document.createElement("br"));
  createFilterInputsLine(21, 25, td, sf);
  return td;
}

function getDefaultFilter(){
  return {"unlock": true, "semi": true, "rare": true, "quest": true, "SE": true, "keep": 1, "custom": []};
}

function getCardFilter(){
  var sf = getFilters(), i, t, cf = [];
  for(i=1; i<=2494; i++) cf[i] = false;
  if(sf["FFO"]) for(i=1; i<=110; i++) cf[i] = true;
  if(sf["FFIV"]) for(i=111; i<=220; i++) cf[i] = true;
  if(sf["FFV"]) for(i=221; i<=330; i++) cf[i] = true;
  if(sf["FFVI"]) for(i=331; i<=440; i++) cf[i] = true;
  if(sf["FFVII"]) for(i=441; i<=550; i++) cf[i] = true;
  if(sf["FFVIII"]) for(i=551; i<=660; i++) cf[i] = true;
  if(sf["FFVIIIr"]) for(i=1343; i<=1452; i++) cf[i] = true;
  if(sf["FFIX"]) for(i=661; i<=770; i++) cf[i] = true;
  if(sf["FFX"]) for(i=771; i<=880; i++) cf[i] = true;
  if(sf["X2"]) for(i=1783; i<=1892; i++) cf[i] = true;
  if(sf["FFXI"]) for(i=1673; i<=1782; i++) cf[i] = true;
  if(sf["FFXII"]) for(i=1901; i<=2010; i++) cf[i] = true;
  if(sf["FFXIII"]) for(i=2011; i<=2120; i++) cf[i] = true;
  if(sf["FFXIV"]) for(i=2275; i<=2384; i++) cf[i] = true;
  if(sf["FFT"]) for(i=881; i<=990; i++) cf[i] = true;
  if(sf["MQ"]) for(i=2385; i<=2494; i++) cf[i] = true;
  if(sf["CT"]) for(i=1101; i<=1210; i++) cf[i] = true;
  if(sf["DL"]) for(i=991; i<=1100; i++) cf[i] = true;
  if(sf["DQ"]) for(i=1453; i<=1562; i++) cf[i] = true;
  if(sf["SIII"]) for(i=1563; i<=1672; i++) cf[i] = true;
  if(sf["S5"]) for(i=2132; i<=2241; i++) cf[i] = true;
  if(sf["XG"]) for(i=1211; i<=1320; i++) cf[i] = true;
  if(sf["unlock"]){
    var ts = [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];
    for(i=0; i<ts.length; i++) cf[ts[i]] = true;
  }
  if(sf["semi"]){
    var ts = [20,429,547,861,979,1395,1549,1550,1591,1672,2006,2107,2241,2351,2384];
    for(i=0; i<ts.length; i++) cf[ts[i]] = true;
  }
  if(sf["rare"]){
    var ts = [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,2373,2416];
    for(i=0; i<ts.length; i++) cf[ts[i]] = true;
  }
  if(sf["quest"]){
    var ts = [1893,1894,1895,1896,1897,1898,1899,1900];
    for(i=0; i<ts.length; i++) cf[ts[i]] = true;
  }
  if(sf["SE"]){
    for(i=1321; i<=1342; i++) cf[i] = true;
    for(i=2121; i<=2131; i++) cf[i] = true;
    for(i=2242; i<=2274; i++) cf[i] = true;
  }
  var t, custom = sf["custom"].split(/[^\d]+/);
  for(i=0; i<custom.length; i++){
    t = parseInt(custom[i]);
    if(t && t<=2494) cf[t] = true;
  }
  return cf;
}

function createKeepInput(amount){
  var input = createInput("text", "keep", amount);
  input.setAttribute("id", "keep");
  input.setAttribute("size", 3);
  input.addEventListener("change", updateViewDupes, true);
  return input;
}

function createCustomFilterInput(old){
  var i, str = "", first = true;
  for(i=0; i<old.length; i++) if(first) str += old[i]; else str += "," + old[i];
  var input = createInput("text", "customFilter", str);
  input.setAttribute("id", "customFilter");
  input.setAttribute("size", "10");
  input.addEventListener("change", updateViewDupes, true);
  return input;
}

function createFilterLastRow(){
  var sf = loadFilters();
  var td = document.createElement("td");
  td.appendChild(createKeepInput(sf["keep"]));
  td.appendChild(document.createTextNode("keep "));
  td.appendChild(createCustomFilterInput(sf["custom"]));
  td.appendChild(document.createTextNode("custom "));
  td.appendChild(createButton("save filters", saveFilters));
  td.appendChild(document.createTextNode(" "));
  td.appendChild(createButton("clear filters", clearFilters));
  return td;
}

function createFilterTable(){
  var table = document.createElement("table");
  var style = "font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 10pt; color: #FFFFFF;";
  table.setAttribute("style", style);
  var tr = document.createElement("tr");
  tr.appendChild(createFilterInputs());
  tr.setAttribute("id", "filters");
  table.appendChild(tr);
  tr = document.createElement("tr");
  tr.appendChild(createFilterLastRow());
  table.appendChild(tr);
  return table;
}

function createCSSPopup(selling){
  var div = document.createElement("div");
  div.setAttribute("style", "position: fixed; width: 320px; height: 180px; margin: auto; top: 0px; right: 0px; bottom: 0px; left: 0px; z-index: 998; background-color: #580001; opacity: .9;");
  var divc = document.createElement("div");
  divc.setAttribute("style", "text-align: center; height: 180px; line-height: 180px; z-index: 999;");
  divc.setAttribute("id", "sellDupesPopup");
  divc.appendChild(document.createTextNode("sold 0/" + selling));
  div.appendChild(divc);
  return div;
}

function soldDupe(){
  sold++;
  sdp.textContent = "sold " + sold + "/" + selling;
  if(sold==selling){
    alert("all " + selling + " dupes sold...\nrefreshing!");
    window.location.assign(window.location.href);
  }
}

function sellDupes(){
  if(!window.confirm("sell dupes?")) return;
  console.log("selling...");
  var i, j, amount=0, cards = getCards();
  for(i=0; i<cards.length; i++){
    amount += cards[i]["amount"];
  }
  document.body.appendChild(createCSSPopup(amount));
  var script = "var sold = 0, selling = " + amount + ", sdp = document.getElementById(\"sellDupesPopup\");";
  addJavaScript(script);
  for(i=0; i<cards.length; i++){
    for(j=0; j<cards[i]["amount"]; j++){
      $.post("scard.php?card_iden="+cards[i]["id"], {}, soldDupe);
    }
  }
}

function createViewDupesButton(){
  var button = createButton("view dupes", viewDupes);
  button.setAttribute("id", "viewDupes");
  return button;
}

function getSellDupesButtonName(){
  var i, amount=0, price=0, cards = getCards();
  for(i=0; i<cards.length; i++){
    amount += cards[i]["amount"];
    price += cards[i]["price"];
  }
  return "sell " + amount + " dupes for " + price + " points";
}

function updateSellDupesButton(){
  document.getElementById("sellDupes").value = getSellDupesButtonName();
}

function createSellDupesButton(){
  var button = createButton(getSellDupesButtonName(), sellDupes);
  button.setAttribute("id", "sellDupes");
  return button;
}

addJavaScript("var dupes = [];\nvar sl = 'sellDupesFilter'+window.location.href.match(/\\d+/);\nvar filter = ['FFO','FFIV','FFV','FFVI','FFVII','FFVIII','FFVIIIr','FFIX','FFX','X2','FFXI','FFXII','FFXIII','FFXIV','FFT','MQ','CT','DL','DQ','SIII','S5','XG','unlock','semi','rare','quest','SE'];\nvar prices = [0,4,4,3,3,4,3,3,4,4,3,4,4,6,5,4,4,4,4,4,199,6,5,5,5,8,5,8,7,5,5,5,8,8,8,8,8,8,10,8,8,8,8,8,8,11,10,11,11,11,10,10,10,10,10,10,16,15,16,15,15,16,17,15,17,15,15,18,18,16,16,16,16,20,18,16,20,16,30,25,25,25,25,30,25,25,25,30,30,43,50,43,43,43,48,53,50,43,43,50,90,98,98,90,98,98,90,90,90,105,98,4,4,3,3,3,3,3,3,4,3,4,4,6,4,4,4,4,4,4,6,4,4,7,5,7,7,5,5,8,7,5,7,7,10,8,10,8,8,8,8,8,8,10,8,10,10,12,11,11,11,10,11,10,10,499,15,15,16,15,15,16,17,16,15,16,15,20,16,18,18,18,16,20,18,18,19,18,28,30,30,28,25,25,25,30,27,25,30,50,43,48,43,43,48,43,50,48,43,43,105,95,95,90,1999,90,1999,90,90,98,98,4,3,3,4,3,3,4,3,3,3,4,6,4,4,4,4,4,4,4,6,4,4,5,5,7,5,7,7,5,5,5,7,5,8,10,9,10,8,10,10,8,8,8,199,10,10,11,11,12,11,11,10,10,10,10,15,16,15,15,15,15,16,15,15,16,16,18,16,20,20,16,16,20,18,16,16,18,25,28,25,25,25,25,30,25,30,30,25,48,48,48,43,48,48,43,43,43,50,43,90,90,98,90,105,90,90,90,90,90,90,3,3,4,4,4,3,4,3,3,3,3,4,6,5,6,4,4,6,4,4,6,4,5,7,7,7,5,7,7,7,7,5,5,8,8,8,9,9,10,10,10,10,8,8,10,11,10,10,11,10,11,11,10,10,11,16,16,15,15,15,16,16,16,15,15,17,18,20,16,16,16,18,18,16,19,16,20,30,30,28,28,25,28,25,30,30,25,25,48,43,48,50,43,48,43,48,43,48,125,98,105,90,98,98,98,98,90,95,90,90,3,4,4,3,3,4,4,4,3,3,4,6,5,6,6,4,4,4,4,5,4,4,7,7,5,7,5,5,8,7,7,5,5,9,8,10,8,8,10,10,10,8,8,8,10,11,11,10,11,10,10,12,12,10,11,16,16,15,16,16,18,15,18,15,17,15,16,20,20,19,18,19,20,16,18,20,18,30,30,30,25,30,28,30,28,30,25,30,43,48,48,48,48,4999,50,50,48,43,48,90,98,90,98,98,90,90,175,98,98,90,4,3,3,4,3,4,4,3,4,4,4,4,4,4,4,4,6,6,6,4,4,6,7,7,5,7,7,5,5,7,7,5,7,10,8,10,10,10,10,9,10,10,8,8,11,10,10,499,11,11,12,12,10,10,11,17,16,16,16,17,17,15,15,17,15,16,20,20,20,16,16,20,20,18,18,18,18,30,25,25,30,30,30,25,30,30,30,30,48,48,48,48,48,48,50,48,48,3999,50,90,98,98,90,98,105,98,5999,6999,105,105,3,4,4,3,3,4,4,3,4,3,4,3,3,4,3,3,4,3,4,3,3,3,4,4,4,4,5,4,4,4,4,4,5,7,5,5,5,5,5,5,5,5,5,5,8,8,10,10,10,10,8,10,8,8,8,14,15,14,14,14,14,15,14,14,14,14,17,17,17,17,17,17,17,17,17,17,17,24,24,24,24,24,25,24,25,24,24,25,43,50,48,48,43,48,48,48,48,43,43,98,98,90,98,105,98,90,105,98,2499,105,3,3,3,3,4,4,4,3,3,4,3,3,3,4,3,3,3,3,3,3,3,4,4,4,5,4,4,4,4,4,4,4,4,10,6,10,6,6,6,6,10,6,6,10,8,8,8,8,10,8,8,8,10,8,8,14,14,14,16,14,14,14,14,14,14,16,17,17,17,17,17,17,17,17,17,17,18,699,25,25,25,25,25,25,25,25,25,25,48,48,125,43,43,43,43,50,43,43,43,90,105,98,90,90,98,90,90,98,90,105,4,4,4,3,3,4,3,3,3,4,3,4,3,3,3,3,3,3,3,3,3,3,6,4,4,4,4,4,4,4,4,4,4,8,6,6,6,6,6,6,6,6,6,8,8,8,8,10,8,8,10,8,8,8,8,14,14,14,17,14,14,14,14,14,14,14,16,16,16,19,19,16,16,16,16,16,16,25,25,27,25,25,25,25,25,25,25,25,43,48,50,43,48,48,43,43,50,48,125,90,105,98,105,98,90,98,105,90,98,90,3,3,3,4,3,4,4,4,4,3,4,4,4,4,6,4,4,6,6,4,4,4,7,7,7,8,5,8,8,7,7,7,7,8,10,10,10,8,10,10,10,8,8,8,12,10,11,11,12,10,10,12,12,11,10,17,16,16,16,17,16,16,15,17,16,15,19,20,599,18,20,16,16,18,18,20,20,25,30,25,30,28,30,25,30,25,28,30,43,43,43,43,43,43,43,43,43,43,43,98,90,98,98,90,90,105,2399,90,98,90,4,4,4,4,3,4,4,3,3,4,4,3,3,3,4,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,4,4,6,6,6,6,6,6,6,7,6,6,6,9,10,9,9,10,10,10,9,10,9,10,13,13,12,12,14,13,13,499,12,13,14,17,17,16,18,17,16,17,17,16,16,18,25,25,25,25,25,25,25,25,25,25,25,48,50,43,50,43,43,43,48,48,43,50,90,90,98,105,90,90,95,90,90,105,90,4,4,4,4,3,4,3,4,4,4,3,3,3,3,3,3,3,3,3,3,3,3,4,4,4,4,5,4,4,4,4,4,5,6,6,6,6,6,6,6,6,6,6,8,10,10,10,11,499,11,10,10,10,10,10,14,14,14,14,14,14,14,14,14,14,14,17,17,17,17,20,17,17,17,17,17,17,24,24,24,24,24,24,24,28,28,24,24,43,50,48,43,50,48,43,43,43,50,43,95,105,90,98,95,1999,98,105,90,98,90,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,3,4,4,4,3,3,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,6,6,6,6,6,6,6,6,6,6,6,8,8,8,8,8,8,8,8,8,8,8,10,10,10,10,10,10,10,10,299,10,10,12,12,12,12,12,12,12,12,12,12,12,15,15,15,15,15,15,15,15,15,15,15,25,25,25,25,25,25,25,25,25,25,25,50,48,48,43,48,1799,50,48,48,48,48,2999,105,98,98,98,2399,105,90,105,90,98,4,4,3,4,4,3,3,3,3,4,3,3,3,3,4,4,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,4,6,6,6,6,6,6,6,6,8,6,6,10,10,9,8,8,8,8,9,8,8,8,14,12,12,12,12,12,14,12,13,12,12,17,17,17,17,17,20,17,20,17,17,17,28,25,28,25,28,25,25,25,25,25,28,43,43,48,50,43,43,43,43,125,125,43,105,90,90,90,98,90,90,98,95,90,90,3,4,4,4,4,4,3,3,4,4,3,4,4,4,6,6,4,6,4,4,4,5,5,5,8,5,5,8,75,7,5,5,5,8,10,10,10,9,8,8,8,10,8,8,10,11,11,10,10,10,10,10,11,12,10,16,16,15,17,599,15,17,15,16,15,16,18,18,18,18,16,20,19,20,16,16,16,25,25,30,30,30,30,30,30,30,28,28,48,43,48,43,43,50,43,48,43,48,50,90,90,98,90,98,90,98,98,90,90,175,4,3,4,3,3,4,3,3,4,3,4,3,3,3,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,5,8,8,8,8,8,8,8,8,8,8,8,14,14,14,14,14,14,14,14,14,14,14,16,16,16,16,16,16,699,16,16,16,16,25,25,25,25,25,25,25,25,25,25,25,43,43,43,50,48,50,50,50,50,43,43,98,90,90,105,98,105,98,105,90,105,90,4,3,3,4,3,3,4,3,3,3,3,4,3,5,3,3,3,3,3,3,4,3,5,4,7,4,4,5,4,4,4,4,7,7,8,9,7,9,7,7,7,8,8,299,10,12,12,12,11,11,12,10,11,10,10,15,16,16,17,16,15,16,16,15,16,15,20,19,19,20,20,19,19,20,20,19,19,25,599,25,25,25,25,27,25,25,26,26,48,43,43,43,43,43,43,43,50,48,43,90,90,90,95,90,98,90,90,98,90,105,1,1,1,1,1,1,1,1,3,4,3,3,3,4,3,4,4,3,4,4,4,4,5,3,4,3,4,4,3,3,4,4,7,5,4,5,4,4,5,7,7,6,10,6,10,8,8,8,6,8,10,6,11,8,12,10,7,8,8,10,11,10,10,14,14,15,14,14,15,15,14,16,14,14,16,20,16,18,699,18,17,18,15,16,18,25,30,30,25,30,25,25,25,28,25,28,48,48,43,43,48,43,43,50,48,43,45,98,90,98,90,90,90,175,90,95,98,90,3,4,3,3,3,4,3,4,4,3,4,4,4,4,5,3,4,3,4,4,3,3,4,4,7,5,4,5,4,4,5,7,7,6,10,6,10,8,8,8,6,8,10,6,11,499,12,10,7,8,8,10,11,10,10,14,14,15,14,14,15,15,14,16,14,14,16,20,16,18,18,18,17,18,15,16,18,25,30,30,25,30,25,25,25,28,25,28,48,48,43,43,48,43,43,50,125,43,45,98,90,98,90,90,90,6999,90,95,98,90,0,0,0,0,0,0,0,0,0,0,0,3,4,3,4,4,4,199,4,4,4,4,4,4,4,4,4,4,6,3,4,4,4,4,5,4,4,5,7,5,7,5,7,7,8,8,10,10,8,10,10,10,10,10,10,11,11,10,11,10,11,11,11,10,10,11,14,16,14,15,15,15,12,14,16,16,15,20,20,16,16,18,15,15,19,18,16,16,28,28,30,30,30,25,25,25,30,30,28,45,43,43,45,48,48,48,50,43,43,1799,105,90,90,98,90,90,90,90,90,90,175,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,3,3,3,3,3,3,4,3,3,3,5,5,5,4,4,4,4,5,4,5,5,8,7,7,7,7,8,8,7,8,7,7,11,10,10,10,10,10,11,11,11,10,11,12,11,11,11,12,12,12,12,12,11,11,16,15,15,15,15,15,16,14,16,15,15,16,16,18,18,16,19,20,19,20,20,19,28,28,28,28,26,28,26,28,26,30,30,45,48,48,50,46,50,48,45,48,46,3999,90,98,95,105,90,90,98,90,105,90,175,4,4,4,4,3,4,4,4,4,4,4,4,4,4,4,6,4,4,4,6,4,4,7,7,7,8,7,5,7,7,8,199,7,10,9,9,9,9,9,9,9,10,9,9,11,12,10,11,11,11,10,12,10,11,10,18,15,18,15,16,15,15,16,15,16,16,18,20,19,19,20,20,18,18,20,19,18,28,26,27,27,27,25,25,28,30,27,25,45,45,45,45,45,45,50,48,50,48,50,105,98,98,95,98,98,95,95,95,95,98];");
loadDupes();

var mainParent = document.getElementById("Main").parentElement;
mainParent.appendChild(document.createElement("br"));
mainParent.appendChild(document.createElement("br"));
mainParent.appendChild(createFilterTable());
mainParent.appendChild(document.createElement("br"));
mainParent.appendChild(createSellDupesButton());
mainParent.appendChild(document.createElement("br"));
mainParent.appendChild(document.createElement("br"));
mainParent.appendChild(createViewDupesButton());
mainParent.appendChild(document.createElement("br"));
mainParent.appendChild(document.createElement("br"));

_________________
Image


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

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