Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name DeckBox IsCardInDeckColumn
- // @version 0.1
- // @description Adds a column to Deckbox/sets/ to determine if a card is physically in this deck or not
- // @author Alex B.
- // @include http://deckbox.org/sets/*
- // @include https://deckbox.org/sets/*
- // @require http://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js
- // @grant GM_setValue
- // @grant GM_getValue
- // @run-at document-end
- // ==/UserScript==
- $('th.card_select').after('<th rowspan="2">IsInDeck</th>');
- var curDeckID = $($('li.current')[0]).attr('id').split('_')[1];
- $('.inventory_count').each(function( index, element )
- {
- var data = $('<td class="has_panel card_count" style="background-color:#98ABE5;"></td>');
- $(element).before(data);
- var parent = $(data).parent();
- var id = parent.attr('id').split('_')[0];
- var val = GM_getValue(curDeckID+':'+id,'false');
- data.attr('data-IsInDeck',val.value);
- if(val == "true")
- {
- data.text('1');
- }
- else
- {
- data.text('0');
- }
- $(data).on(
- "click",
- function(e)
- {
- var isInDeck = $(this).attr('data-isindeck');
- if(isInDeck == "true")
- {
- $(this).text('0');
- $(this).attr('data-isindeck','false');
- }
- else
- {
- $(this).text('1');
- $(this).attr('data-isindeck','true');
- }
- e.stopPropagation();
- GM_setValue(curDeckID+':'+id,$(this).attr('data-isindeck'));
- }
- );
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement