Advertisement
Guest User

Deckbox IsInDeck Script

a guest
Jun 19th, 2015
285
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name         DeckBox IsCardInDeckColumn
  3. // @version      0.1
  4. // @description  Adds a column to Deckbox/sets/ to determine if a card is physically in this deck or not
  5. // @author       Alex B.
  6. // @include        http://deckbox.org/sets/*
  7. // @include        https://deckbox.org/sets/*
  8. // @require http://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js
  9. // @grant GM_setValue
  10. // @grant GM_getValue
  11. // @run-at document-end
  12. // ==/UserScript==
  13.  
  14. $('th.card_select').after('<th rowspan="2">IsInDeck</th>');
  15. var curDeckID = $($('li.current')[0]).attr('id').split('_')[1];
  16. $('.inventory_count').each(function( index, element )
  17.                            {
  18.                                var data = $('<td class="has_panel card_count" style="background-color:#98ABE5;"></td>');
  19.                                $(element).before(data);
  20.                                var parent = $(data).parent();
  21.                                var id = parent.attr('id').split('_')[0];
  22.                                var val = GM_getValue(curDeckID+':'+id,'false');
  23.                                data.attr('data-IsInDeck',val.value);
  24.                                if(val == "true")
  25.                                {
  26.                                    data.text('1');
  27.                                }
  28.                                else
  29.                                {
  30.                                    data.text('0');
  31.                                }
  32.                                $(data).on(
  33.                                    "click",
  34.                                    function(e)
  35.                                    {
  36.                                        var isInDeck = $(this).attr('data-isindeck');
  37.                                        if(isInDeck == "true")
  38.                                        {
  39.                                            $(this).text('0');
  40.                                            $(this).attr('data-isindeck','false');
  41.                                        }
  42.                                        else
  43.                                        {
  44.                                            $(this).text('1');
  45.                                            $(this).attr('data-isindeck','true');
  46.                                        }
  47.                                        e.stopPropagation();
  48.                                        GM_setValue(curDeckID+':'+id,$(this).attr('data-isindeck'));
  49.                                    }
  50.                                );
  51.                            });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement