Skip to content

Instantly share code, notes, and snippets.

@satyr
Created January 20, 2012 18:16
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save satyr/1648785 to your computer and use it in GitHub Desktop.
Save satyr/1648785 to your computer and use it in GitHub Desktop.
mondradelhelper
// ==UserScript==
// @name mondradelhelper
// @description Helps you delete redundant normal/bronze cards.
// @match http://w001.monsterdragon.jp/card/index
// @author satyr
// @version 0.2
// ==/UserScript==
var actions, header, target, action;
actions = {
Dups: function(){
var dict, lis, li, name, cards, i, _i, _len, _to;
dict = Object.create(null);
lis = document.querySelectorAll('.monster-card-trigger');
for (_i = 0, _len = lis.length; _i < _len; ++_i) {
li = lis[_i];
name = li.getAttribute('monster-name-sort');
if ((name === 'ゴブリン' || name === 'トンベリ') || 2 < li.getAttribute('monster-rare')) {
continue;
}
(dict[name] || (dict[name] = [])).push(li);
}
for (name in dict) {
cards = dict[name];
for (i = 3, _to = cards.length; i < _to; ++i) {
click(cards[i]);
}
}
},
None: function(){
var input, _i, _ref, _len;
for (_i = 0, _len = (_ref = document.querySelectorAll('input[name="delete_card_ids[]"]')).length; _i < _len; ++_i) {
input = _ref[_i];
if (input.checked) {
click(input.parentNode);
}
}
}
};
header = document.querySelector('.ui-monster-deck-header');
for (target in actions) {
action = actions[target];
(_fn.call(header.appendChild(document.createElement('button')), target, action));
}
function click(node){
var ev;
ev = document.createEvent('MouseEvents');
ev.initEvent('mousedown', true, true);
node.dispatchEvent(ev);
}
function _fn(target, action){
this.textContent = "Select " + target;
this.addEventListener('click', function(it){
action();
it.preventDefault();
}, false);
}
`// ==UserScript==
// @name mondradelhelper
// @description Helps you delete redundant normal/bronze cards.
// @match http://w001.monsterdragon.jp/card/index
// @author satyr
// @version 0.2
// ==/UserScript==`
actions =
Dups: !->
dict = Object.create null
lis = document.querySelectorAll \.monster-card-trigger
for li of lis
name = li.getAttribute \monster-name-sort
continue if name of <[ゴブリン トンベリ]>
or 2 < li.getAttribute \monster-rare
dict@@[name]push li
for name, cards in dict
click cards[i] for i from 3 til cards.length
None: !->
for input of document.querySelectorAll 'input[name="delete_card_ids[]"]'
click input.parentNode if input.checked
header = document.querySelector \.ui-monster-deck-header
for target, action in actions
with header.appendChild document.createElement \button
@textContent = "Select #target"
@addEventListener \click !->
action!
it.preventDefault!
, false
!function click node
ev = document.createEvent \MouseEvents
ev.initEvent \mousedown true true
node.dispatchEvent ev
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment