Monk Forums
Would you like to react to this message? Create an account in a few clicks or log in to continue.

FindCard script custom

2 posters

Go down

FindCard script custom Empty FindCard script custom

Post by Street Sweeper Arias February 14th 2011, 6:17 pm

I couldnt live without the FindCard greasemonkey script.

I like it so much I added some additional searches.

-pierce: calculates the damage that pierces thru so you can select the charms that give the most piercing damage
-mel+mag: adds the direct melee and magic damage so you can see your most damaging charms
-meleeTotal: shows the charms that give the most melee damage including the ones that do x melee during y turns. So put 70 in the box and you see charm that does 70 dmg and one that does 7 dmg over 10 turns.
-magicTotal: ditto
-hits: show charms that do multiple hits
-meleeHits: show charms that do multiple melee hits
-magicHits: ditto

Code:
// ==UserScript==
// @name          Estiah - FindCard
// @namespace      WalburEstiahScripts
// @description    Filters charms according to user specification in the deck building page.
// @include        http://www.estiah.com/character/deck*
// @include        http://contest.estiah.com/character/deck*
// @author        Walbur + SSA
// @version        0.1.0.SSA.1
// ==/UserScript==


var match;

function updateCards() {

  var userinput = document.getElementById('findcharm_userinput').value;
  var property = document.getElementById('findcharm_property').selectedIndex;
  var gt = document.getElementById('findcharm_gt').checked;
  var lt = document.getElementById('findcharm_lt').checked;
  var eq = document.getElementById('findcharm_eq').checked;
  var compval = parseInt(document.getElementById('findcharm_compval').value);
  var op;
  if (gt == 1) {
    op = 0;
  }
  else if (lt == 1) {
    op = 1;
  }
  else if (eq == 1) {
    op = 2;
  }

  var cardFWs = document.getElementsByClassName('common_file floating opacity bd1');   // floating windows
  for (var i = 0; i < cardFWs.length; i++) {
    var cardFW = cardFWs[i];
    var card = document.getElementById('CollectionCard' + cardFW.id.substring(14))
    if (card != null) {
      var properties = new Array();
      var title1    = cardFW.getElementsByClassName('title ccraft');
      var title2    = cardFW.getElementsByClassName('title ctreasure');
      var title3    = cardFW.getElementsByClassName('title crare');
      var title4    = cardFW.getElementsByClassName('title cclass');
      var title5    = cardFW.getElementsByClassName('title cvendor');
      var title6    = cardFW.getElementsByClassName('title cepic');
      properties[0] = cardFW.getElementsByClassName('melee');
      properties[1] = cardFW.getElementsByClassName('magic');
      properties[2] = cardFW.getElementsByClassName('spirit');
      properties[3] = cardFW.getElementsByClassName('armor');
      properties[4] = cardFW.getElementsByClassName('ward');
      properties[5] = cardFW.getElementsByClassName('willpower');
      var special  = cardFW.getElementsByClassName('special');
      var desc  = cardFW.getElementsByClassName('description');

      match = 0;
      testString(title1, userinput);
      testString(title2, userinput);
      testString(title3, userinput);
      testString(title4, userinput);
      testString(title5, userinput);
      testString(title6, userinput);
      testString(desc, userinput);
     
      if (property != 0 && match == 1) {
        if (property <= 6) {
          if (properties[property - 1] == null || properties[property - 1].length == 0) {
            match = 0;
          } else {
            testCompare(properties[property - 1], op, compval);
          }
        }
        if (property == 7) // % pierce
          match = match & testValue(desc, /([0-9]+)% P\)/, op, compval);
   if (property == 8) { // piercedmg
          if ((properties[0] == null || properties[0].length == 0) && (properties[1] == null || properties[1].length == 0)) {
            match = 0;
     } else {
            if (properties[0] == null || properties[0].length == 0) {
              match = match & testValuemult(desc, /([0-9]+)% P\)/, op, compval, properties[1]);
            } else {
              if (properties[0] == null || properties[1].length == 0) {
                match = match & testValuemult(desc, /([0-9]+)% P\)/, op, compval, properties[0]);
              } else {
           match = match & (testValuemult(desc, /([0-9]+)% P\)/, op, compval, properties[0]) || testValuemult(desc, /([0-9]+)% P\)/, op, compval, properties[1]));
              }
            }
          }
        }
        if (property == 9) {
          if ((properties[0] == null || properties[0].length == 0) && (properties[1] == null || properties[1].length == 0)) {
            match = 0;
     } else {
            if (properties[0] == null || properties[0].length == 0) {
              testCompare(properties[1], op, compval);
            } else {
              if (properties[0] == null || properties[1].length == 0) {
                testCompare(properties[0], op, compval);
              } else {
           testCompare2(properties[0], properties[1], op, compval);
              }
            }
          }
        }
        if (property == 10) {
          if (properties[0] == null || properties[0].length == 0) {
            match = 0;
     } else {
            testCompare(properties[0], op, compval);
            if (!match) {
         match = 1;
              testCompareweakmelee(properties[0], op, compval, desc);
            }

          }
        }
        if (property == 11) {
          if (properties[1] == null || properties[1].length == 0) {
            match = 0;
     } else {
            testCompare(properties[1], op, compval);
            if (!match) {
              match = 1;
              testCompareweakmagic(properties[1], op, compval, desc);
            }
          }
        }
   if (property == 12) {
          testhits(desc);
        }
   if (property == 13) {
          testhitsmelee(desc);
        }
   if (property == 14) {
          testhitsmagic(desc);
        }
      }
      if (!match) {
        card.style.display = 'none';
      } else {
        card.style.display = '';
      }
    }
  }
}

function testhitsmagic(desc) {
  var magic = 0;
  var startmagic = desc[0].innerHTML.indexOf('magic"><strong');
  if (startmagic > -1) {
   magic = 1;
     var startmagic = desc[0].innerHTML.indexOf('magic"><strong', startmagic + 14);
     if (startmagic > -1) {
        magic = 2;
        }
  }
  if (magic < 2)
    match = 0;
}

function testhitsmelee(desc) {
  var magic = 0;
  var melee = 0;
  var startmelee = desc[0].innerHTML.indexOf('melee"><strong');
  if (startmelee > -1) {
   melee = 1;
     var startmelee = desc[0].innerHTML.indexOf('melee"><strong', startmelee + 14);
     if (startmelee > -1) {
        melee = 2;
        }
  }
  if (melee < 2)
    match = 0;
}

function testhits(desc) {
  var melee = 0;
  var startmelee = desc[0].innerHTML.indexOf('melee"><strong');
  if (startmelee > -1) {
   melee = 1;
     var startmelee = desc[0].innerHTML.indexOf('melee"><strong', startmelee + 14);
     if (startmelee > -1) {
        melee = 2;
        }
  }
  var magic = 0;
  var startmagic = desc[0].innerHTML.indexOf('magic"><strong');
  if (startmagic > -1) {
   magic = 1;
     var startmagic = desc[0].innerHTML.indexOf('magic"><strong', startmagic + 14);
     if (startmagic > -1) {
        magic = 2;
        }
  }
  if (magic + melee < 2)
    match = 0;
}

function testCompare2(str, str2, op, compval) {
  var prop = -1;
  var end = str[0].innerHTML.indexOf('</strong>');
  if (end > -1) {
     var findStart = end - 12;
     if (findStart < 0) findStart = 0;
     var start = str[0].innerHTML.indexOf('<strong>', findStart);
     if (start > -1) {
        prop = parseInt(str[0].innerHTML.substring(start + 8, end));
    }
  }
  var prop2 = -1;
  var end2 = str2[0].innerHTML.indexOf('</strong>');
  if (end2 > -1) {
     var findStart2 = end2 - 12;
     if (findStart2 < 0) findStart2 = 0;
     var start2 = str2[0].innerHTML.indexOf('<strong>', findStart2);
     if (start2 > -1) {
        prop2 = parseInt(str2[0].innerHTML.substring(start2 + 8, end2));
    }
  }
  if (prop == -1 || prop2 == -1)
    match = 0;
  var prop3 = prop+prop2;
  if (op == 0 && prop3 < compval && prop3 >= 0)
    match = 0;
  if (op == 1 && prop3 > compval && prop3 >= 0)
    match = 0;
  if (op == 2 && prop3 != compval && prop3 >= 0)
    match = 0;
}

function testValuemult(desc, pat, op, thresh, str) {
  var res = desc[0].innerHTML.match(pat);
  var prop = parseInt(res);
  if (res == null || prop == -1 || prop == null)
    return 0;
  var prop2 = -1;
  var end = str[0].innerHTML.indexOf('</strong>');
  if (end > -1) {
     var findStart = end - 12;
     if (findStart < 0) findStart = 0;
     var start = str[0].innerHTML.indexOf('<strong>', findStart);
     if (start > -1) {
        prop2  = parseInt(str[0].innerHTML.substring(start + 8, end));
    }
  }
  if (prop2 == -1)
    return 0;
  var prop3 = (prop/100)*prop2;
  if (op == 0 && prop3 < thresh && prop >= 0 && prop2 >= 0)
    return 0;
  if (op == 1 && prop3 > thresh && prop >= 0 && prop2 >= 0)
    return 0;
  if (op == 2 && prop3 != thresh && prop >= 0 && prop2 >= 0)
    return 0;
 
  return 1;
}

function testCompareweakmagic(str, op, compval, desc) {
  var prop = -1;
  var end = str[0].innerHTML.indexOf(' magic');
 
  if (end > -1) {
     var start = 0
     if (start > -1) {
        prop = parseInt(str[0].innerHTML.substring(start, end));
    }
  }
  var turns = -1;
  var end2 = desc[0].innerHTML.indexOf(' turns');
  if (end2 > -1) {
     var start2 = desc[0].innerHTML.indexOf('during ', 0);
     if (start2 > -1) {
        turns = parseInt(desc[0].innerHTML.substring(start2 + 7, end2));
    }
  }

  if (prop == -1 || turns == -1)
    match = 0;
 
  var prop3 = prop*turns;

  if (op == 0 && prop3 < compval && prop3 >= 0)
    match = 0;
  if (op == 1 && prop3 > compval && prop3 >= 0)
    match = 0;
  if (op == 2 && prop3 != compval && prop3 >= 0)
    match = 0;
}

function testCompareweakmelee(str, op, compval, desc) {
  var prop = -1;
  var end = str[0].innerHTML.indexOf(' melee');
 
  if (end > -1) {
     var start = 0
     if (start > -1) {
        prop = parseInt(str[0].innerHTML.substring(start, end));
    }
  }
  GM_log(match);
  var turns = -1;
  var end2 = desc[0].innerHTML.indexOf(' turns');
  if (end2 > -1) {
     var start2 = desc[0].innerHTML.indexOf('during ', 0);
     if (start2 > -1) {
        turns = parseInt(desc[0].innerHTML.substring(start2 + 7, end2));
    }
  }

  if (prop == -1 || turns == -1)
    match = 0;
 
  var prop3 = prop*turns;

  if (op == 0 && prop3 < compval && prop3 >= 0)
    match = 0;
  if (op == 1 && prop3 > compval && prop3 >= 0)
    match = 0;
  if (op == 2 && prop3 != compval && prop3 >= 0)
    match = 0;
}

function testValue(desc, pat, op, thresh) {
  var res = desc[0].innerHTML.match(pat);
  var prop = parseInt(res);
  if (res == null || prop == -1 || prop == null)
    return 0;
  if (op == 0 && prop < thresh && prop >= 0)
    return 0;
  if (op == 1 && prop > thresh && prop >= 0)
    return 0;
  if (op == 2 && prop != thresh && prop >= 0)
    return 0;
  //GM_log(res);
  return 1;
}


function testString(toTest, pattern) {
  patternLC = pattern.toLowerCase();
  pats = patternLC.split(" ");
  for (var p = 0; p < toTest.length; p ++) {
    toTestLC = toTest[p].innerHTML.toLowerCase();

    var miss = 0;
    for (var i = 0; i < pats.length; i ++) {
      var end = toTestLC.indexOf(pats[i]);
      if (end < 0) {
        miss = 1;
      }
    }
    if (miss == 0) {
      match = 1;
    }
  }
}

function testCompare(str, op, compval) {
  var prop = -1;
  var end = str[0].innerHTML.indexOf('</strong>');
 
  if (end > -1) {
     var findStart = end - 12;
     if (findStart < 0) findStart = 0;
     var start = str[0].innerHTML.indexOf('<strong>', findStart);
     if (start > -1) {
        prop = parseInt(str[0].innerHTML.substring(start + 8, end));
    }
  }
  if (prop == -1)
    match = 0;
  if (op == 0 && prop < compval && prop >= 0)
    match = 0;
  if (op == 1 && prop > compval && prop >= 0)
    match = 0;
  if (op == 2 && prop != compval && prop >= 0)
    match = 0;
}


var OperationDiv = document.createElement("div");
OperationDiv.innerHTML = ' \
<div class="configlist outline" id="PatternConfig"> \
  <form id="PatternForm"> \
    <label>Contains string:</label> \
    <input name="pat" value="" id="findcharm_userinput" width="20" /> <br>\
    <select name="prop" class="select" id="findcharm_property"> \
      <option label="none" value="none" selected="selected">none</option> \
      <option label="melee" value="melee">melee</option> \
      <option label="magic" value="magic">magic</option> \
      <option label="spirit" value="spirit">spirit</option> \
      <option label="armor" value="armor">armor</option> \
      <option label="ward" value="ward">ward</option> \
      <option label="willpower" value="willpower">willpower</option> \
      <option label="% pierce" value="pierce">% pierce</option> \
      <option label="pierce" value="piercedmg">pierce</option> \
      <option label="melmag" value="melmag">mel+mag</option> \
      <option label="meleet" value="meleet">meleeTotal</option> \
      <option label="magict" value="magict">magicToTal</option> \
      <option label="hits" value="hits">hits</option> \
      <option label="mehits" value="mehits">meleeHits</option> \
      <option label="mahits" value="mahits">magicHits</option> \
    </select> \
    <label><input type="radio" name="cond" value="0" id="findcharm_gt" checked="checked" class="radio" />>=</label>  \
    <label><input type="radio" name="cond" value="1" id="findcharm_lt" class="radio" /><=</label>  \
    <label><input type="radio" name="cond" value="2" id="findcharm_eq" class="radio" />=</label>&nbsp; \
    <input name="compval" value="0" id="findcharm_compval" width="10"/> \
  </form> \
</div>';

OperationDiv.id = "PatternDiv";
var cardlist = document.getElementsByClassName("cardlist");
cardlist[1].parentNode.insertBefore(OperationDiv, cardlist[1]);

var input_desc = document.getElementById("findcharm_userinput");
input_desc.addEventListener("keyup",updateCards,false);
var input_comp = document.getElementById("findcharm_compval");
input_comp.addEventListener("keyup",updateCards,false);
var input_prop = document.getElementById("findcharm_property");
input_prop.addEventListener("change",updateCards,false);
var input_gt = document.getElementById("findcharm_gt");
input_gt.addEventListener("click",updateCards,false);
var input_lt = document.getElementById("findcharm_lt");
input_lt.addEventListener("click",updateCards,false);
var input_eq = document.getElementById("findcharm_eq");
input_eq.addEventListener("click",updateCards,false);


Street Sweeper Arias
Street Sweeper Arias
1st Lieutenant
1st Lieutenant

Number of posts : 355
High Path or Class : Assassin
Avatar URL : Videos

Headshot : I made your Icon.

Back to top Go down

FindCard script custom Empty Re: FindCard script custom

Post by Howie Feltersnatch February 14th 2011, 11:34 pm

Nice, I actually never used/knew about those search options....but i like the additions that you put on it now that I do.

Howie Feltersnatch
Retired Lieutenant General
Retired Lieutenant General

Number of posts : 2900
High Path or Class : Berserker
Avatar URL : Estiah
Headshot : Estiah

Back to top Go down

FindCard script custom Empty Re: FindCard script custom

Post by Howie Feltersnatch February 24th 2012, 6:00 pm

Just wanted to bump this up for those that missed it the first time around. I couldn't figure out why my search didn't have all those choices anymore.

Howie Feltersnatch
Retired Lieutenant General
Retired Lieutenant General

Number of posts : 2900
High Path or Class : Berserker
Avatar URL : Estiah
Headshot : Estiah

Back to top Go down

FindCard script custom Empty Re: FindCard script custom

Post by Sponsored content


Sponsored content


Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum