Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name HentaiVerse Equipment
- // @namespace HV_EQUIP
- // @description Creates BBCode formatted list of your unequipped items from wherever item stats are listed
- // @include http://hentaiverse.org/?s=Bazaar&ss=es*
- // @include http://hentaiverse.org/?s=Character&ss=eq*
- // @include http://hentaiverse.org/pages/showequip.php*
- // @include http://hv.e-hentai.org/pages/showequip.php*
- // ==/UserScript==
- var SELL_MODIFIER = 5;
- working_j = -1;
- var factor_data = [
- ["Attack Damage Multiplier", 100, "ADmg", 0.308],
- ["Magic Damage Multiplier", 100, "MDmg", 0.302],
- ["Attack Accuracy Bonus", 2000, "AAcc", 0.8],
- ["Magic Accuracy Bonus", 2000, "MAcc", 0.997],
- ["Attack Critical Bonus", 2000, "ACrit", 0.21],
- ["Magic Critical Bonus", 2000, "MCrit", 0.228],
- ["Physical Absorption", 20, "PAbs", 0.029],
- ["Physical Mitigation", 400, "PMit", 0.104],
- ["Magical Absorption", 20, "MAbs", 0.031],
- ["Magical Mitigation", 400, "MMit", 0.101],
- ["Parry Chance", 400, "Parry", 0.495],
- ["Block Chance", 400, "Block", 0.998],
- ["Evade Chance", 400, "Evade", 0.25],
- ["Resist Chance", 400, "Resist", 0.505],
- ["Burden", 400, "Brdn", 1],
- ["Interference", 400, "Intr", 1],
- ["Crushing", 400, "Crush", 0.08],
- ["Slashing", 400, "Slash", 0.08],
- ["Piercing", 400, "Pierce", 0.08],
- ["Elemental", 50, "Ele_P", 0.306],
- ["Deprecating", 50, "Dep_P", 0.306],
- ["Supportive", 50, "Sup_P", 0.306],
- ["Curative", 50, "Cur_P", 0.306],
- ["Divine", 50, "Div_P", 0.306],
- ["Forbidden", 50, "For_P", 0.306],
- ["Fire", 50, "Fire", 1],
- ["Cold", 50, "Cold", 1],
- ["Elec", 50, "Elec", 1],
- ["Wind", 50, "Wind", 1],
- ["Holy", 50, "Holy", 1],
- ["Dark", 50, "Dark", 1],
- ["Soul", 50, "Soul", 1],
- ["Strength", 10, "Str", 0.03],
- ["Dexterity", 10, "Dex", 0.03],
- ["Agility", 10, "Agi", 0.03],
- ["Endurance", 10, "End", 0.03],
- ["Wisdom", 10, "Wis", 0.03],
- ["Intelligence", 10, "Int", 0.03]];
- var w_i = 0;
- var w_str = "";
- var working_array = new Array();
- // _root = The node to look for the items inside (to avoid grabbing items the Bazaar is selling)
- // _class = The class name the equipment goes by in the HTML ('eqde' for equipped items in the Character Equipment page, 'eqdp' for everything else)
- function get_equipment_bbcode( _root, _class)
- {
- if( _root == null) return;
- var equips = _root.getElementsByClassName( _class);
- var list = "";
- for( var _inc = 0; _inc < equips.length; _inc++)
- {
- var _str = equips[_inc].getAttribute('onmouseover');
- // Find the Level
- var _t = _str.indexOf("Level ");
- var c_LVL = _str.substring( _t + 6, _str.indexOf(" ", _t + 6));
- // Find the Item Name
- _t = _str.indexOf("'", _str.indexOf("'", _str.indexOf("'", _str.indexOf("show_popup_box")) + 1) + 1);
- var c_NAME = _str.substring( _t + 1, _str.indexOf("'",_t + 1));
- // Find the EID and Key
- _t = _str.lastIndexOf( "set_equipmentcopy(");
- var c_EID = _str.substring( _t + 18, _str.indexOf(",", _t + 18));
- _t = _str.indexOf("'", _t + 18);
- var c_KEY = _str.substring( _t + 1, _str.indexOf("'", _t + 1));
- // Find the Sell Value (if sell value is listed on the given page)
- var c_SELL = "";
- _str = equips[_inc].getAttribute('onclick');
- if( _str != null)
- {
- _t = _str.indexOf( "set_selected_item");
- if( _t > -1)
- {
- _t = _str.indexOf(",", _str.indexOf(",", _str.indexOf(",", _t + 16) + 1) + 1);
- c_SELL = "Bazaar Price: " + parseInt(_str.substring( _t + 1, _str.indexOf( ',', _t + 1)))*SELL_MODIFIER + "cp\n";
- }
- }
- list += "[b][url=http://hentaiverse.org/pages/showequip.php?eid=" + c_EID + "&key=" + c_KEY + "]" + c_NAME + "[/url][/b](Level: " + c_LVL + ")\n" + c_SELL + "\n";
- }
- if( list != "")
- {
- // Create Text Box in lower left to copy text from
- var newElement = document.createElement('div');
- newElement.setAttribute( 'style', "position:absolute; left:10px; bottom:10px; z-index:999;");
- newElement.innerHTML = "Equip Link BBCode:<br /><textarea cols='40' rows='0'>"+list+"</textarea>";
- var entry_point = document.getElementsByTagName( 'body')[0];
- entry_point.insertBefore( newElement, entry_point.firstChild);
- }
- }
- function format_all_items()
- {
- // Find all relevant equipment
- var _equip = document.getElementsByClassName( 'eqdp');
- if( _equip == null) return;
- for( _inc = 0; _inc < _equip.length; _inc++)
- {
- var old_str = _equip[_inc].getAttribute('onmouseover');
- var new_str = old_str.match(/show_popup_box.+?<table>/im)[0].replace("<table>","");
- // Find the Item Name and EID
- _t = old_str.indexOf("'", old_str.indexOf("'", old_str.indexOf("'", old_str.indexOf("show_popup_box")) + 1) + 1);
- var c_NAME = old_str.substring( _t + 1, old_str.indexOf("'",_t + 1));
- _t = old_str.lastIndexOf( "set_equipmentcopy(");
- var c_EID = old_str.substring( _t + 18, old_str.indexOf(",", _t + 18));
- working_array = new Array();
- // if( c_NAME.match(/ of /img) == null)
- {
- // Make sure the EID is recorded so you don't double-note items
- go = 1;
- for( i = 0; i < EID_array.length; i++)
- if( EID_array[i] == c_EID) go = 0;
- if( go)
- {
- working_array = new Array();
- w_i = 2;
- EID_array[ EID_array.length] = c_EID;
- var tt = c_NAME.match(/Flimsy|Crude|Fair|Average|Fine|Superior|Exquisite|Magnificent/img);
- if( tt == null) alert( "Quality Mismatch: " + c_NAME);
- working_array[0] = tt[0]; // Item Quality
- // THE NEXT LINE SHALL PIERCE THE HEAVENS!!!!
- var tt = c_NAME.match(/Axe|Club|Dagger|Rapier|Shortsword|Sword Chucks|Wakizashi|Estoc|Longsword|Mace|Scythe|Katana|Ebony|Redwood|Willow|Oak|Katalox|Buckler|Kite Shield|Tower Shield|Cotton Cap|Silk Cap|Gossamer Cap|Phase Cap|Cotton Robe|Silk Robe|Gossamer Robe|Phase Robe|Cotton Gloves|Silk Gloves|Gossamer Gloves|Phase Gloves|Cotton Pants|Silk Pants|Gossamer Pants|Phase Pants|Cotton Shoes|Silk Shoes|Gossamer Shoes|Phase Shoes|Leather Helmet|Dragon Hide Helmet|Kevlar Helmet|Leather Breastplate|Dragon Hide Breastplate|Kevlar Breastplate|Leather Gauntlets|Dragon Hide Gauntlets|Kevlar Gauntlets|Leather Leggings|Dragon Hide Leggings|Kevlar Leggings|Leather Boots|Dragon Hide Boots|Kevlar Boots|Chainmail Coif|Plate Helmet|Chainmail Hauberk|Plate Cuirass|Chainmail Mitons|Plate Gauntlets|Chainmail Chausses|Plate Greaves|Chainmail Boots|Plate Sabatons/img);
- if( tt == null) alert( "Type Mismatch: " + c_NAME);
- working_array[1] = tt[0]; // Item Type
- //Axe|Club|Dagger|Rapier|Shortsword|Sword Chucks|Wakizashi
- //Estoc|Longsword|Mace|Scythe|Katana
- //Ebony|Redwood|Willow|Oak|Katalox
- //Buckler|Kite Shield|Tower Shield
- //Cotton Cap|Silk Cap|Gossamer Cap|Phase Cap
- //Cotton Robe|Silk Robe|Gossamer Robe|Phase Robe
- //Cotton Gloves|Silk Gloves|Gossamer Gloves|Phase Gloves
- //Cotton Pants|Silk Pants|Gossamer Pants|Phase Pants
- //Cotton Shoes|Silk Shoes|Gossamer Shoes|Phase Shoes
- //Leather Helmet|Dragon Hide Helmet|Kevlar Helmet
- //Leather Breastplate|Dragon Hide Breastplate|Kevlar Breastplate
- //Leather Gauntlets|Dragon Hide Gauntlets|Kevlar Gauntlets
- //Leather Leggings|Dragon Hide Leggings|Kevlar Leggings
- //Leather Boots|Dragon Hide Boots|Kevlar Boots
- //Chainmail Coif|Plate Helmet
- //Chainmail Hauberk|Plate Cuirass
- //Chainmail Mitons|Plate Gauntlets
- //Chainmail Chausses|Plate Greaves
- //Chainmail Boots|Plate Sabatons
- }
- }
- new_str = new_str.replace(/320/, 380); // Increase the width to accomidate the new stats
- new_str += format_item_table( old_str.match(/<table.+<\/table>/img)[0], parseInt(old_str.match(/Level \d+?\s/)[0].replace("Level ","")));
- new_str += old_str.substring( old_str.lastIndexOf("</table>")+8);
- _equip[_inc].setAttribute('onmouseover',new_str);
- if( working_array.length != 0)
- w_str += working_array.join(';') + "\n";
- }
- }
- // Takes the item table and reformats it with Base values
- // c_LVL = item's current level
- function format_item_table( table_str, c_LVL)
- {
- var return_str = "<table>";
- // Remove the Sub-attribute tables so they don't interfere
- var sub_str = table_str.match(/<table class="eqat">.+?<\/table>/img);
- table_str = table_str.replace(/<table class="eqat">.+?<\/table>/img,"");
- // Go through each <tr></tr>
- var _t = table_str.match(/<tr>.+?<\/?tr>/img);
- for( i = 0; i < _t.length; i++)
- {
- var line_str = _t[i]; // String to be intered (working edit)
- if( line_str.match(/<td/img).length > 3) // Make sure it's not a line
- {
- // Find the attribute of the current row
- var att_str = line_str.match(/<td.+?<\/td>/im)[0].replace("<td>","").replace(" </td>","");
- // Add width attribute to the first row to make the table pretty
- if( i == 0) line_str = line_str.replace(/<td/, "<td style=\"width:200px\"");
- // Match the scaling factor with the attribute name
- for( j = 0; j < factor_data.length; j++)
- {
- if( att_str == factor_data[j][0])
- {
- // Add to working array
- if( working_array.length != 0)
- {
- working_array[w_i] = factor_data[j][2];
- w_i++;
- }
- working_j = j;
- // Calculate base stat from found stats and add them to row.
- var stats = line_str.match(/\d+?\.\d\d/img);
- if( stats != null)
- line_str = line_str.replace(/<\/tr>/img, "<td style=\"text-align:center;width:80px;font-weight:bold;color:rgb(63,63,160);\">"+ calculate_base_stats( stats, c_LVL,factor_data[j][1], factor_data[j][3]) +" </td></tr>");
- j = factor_data.length;
- }
- }
- }
- return_str += line_str;
- }
- // Go through each of the sub attribute trees
- if( sub_str != null)
- {
- for( i = 0; i < sub_str.length; i++)
- {
- // Remove width limitations imposed by the "eqat" class to make the attribute table pretty
- sub_str[i] = sub_str[i].replace("table class=\"eqat\"","table style=\"margin:-1px auto;\"");
- //Go through each sub attribute
- var _start = sub_str[i].indexOf( "class=\"eqak\"");
- while( _start != -1)
- {
- // Attribute string
- att_str = sub_str[i].substring( _start + 13, sub_str[i].indexOf(" ", _start + 13));
- for( var j = 0; j < factor_data.length; j++)
- if( att_str == factor_data[j][0])
- {
- // Add to working array
- if( working_array.length != 0)
- {
- working_array[w_i] = factor_data[j][2];
- w_i++;
- }
- working_j = j;
- var stats = new Array();
- // Stat scaled to item's level
- var _start2 = sub_str[i].indexOf("\"eqav1\">", _start + 13);
- stats[0] = parseFloat( sub_str[i].substring(_start2 + 9, sub_str[i].indexOf(" ", _start2 + 9)));
- // Stat scaled to player's level
- _start2 = sub_str[i].indexOf("\"eqav2\">", _start2 + 9);
- var __test = parseFloat( sub_str[i].substring(_start2 + 10, sub_str[i].indexOf(" ", _start2 + 10)-1));
- if( !isNaN(__test)) stats[1] = __test;
- // Insert Base Stat
- _start2 = sub_str[i].indexOf("</td>", _start2 + 9);
- sub_str[i] = sub_str[i].substring(0, _start2) + "<td style=\"text-align:center;font-weight:bold;color:rgb(63,63,160);\">" + calculate_base_stats( stats, c_LVL, factor_data[j][1], factor_data[j][3]) +" </td>" + sub_str[i].substring(_start2);
- }
- // Find next attribute
- _start = sub_str[i].indexOf( "class=\"eqak\"", _start + 1);
- }
- }
- // Calculate Bleeding Wounds
- var _start = return_str.indexOf("per tick");
- if( _start != -1)
- {
- }
- // Re-insert table data into the main string
- _start = return_str.indexOf("<td colspan=\"5\">");
- for( i = 0; i < sub_str.length && _start != -1; i++)
- {
- return_str = return_str.substring(0,_start) + "<td colspan=\"6\">" + sub_str[i] + return_str.substring(_start+16);
- _start = return_str.indexOf("<td colspan=\"5\">", _start);
- }
- }
- return_str = return_str + "</table>"
- return return_str;
- }
- // Calculates Base stat string from an array of one or two float strings, the item's level, and a scaling factor
- function calculate_base_stats( stats, c_LVL, _factor, _factor2)
- {
- _factor2 = 1;
- // Stats scaled to item's level
- var max_stat = parseFloat(stats[0]);
- var base_stat_min = (max_stat - 0.005) / (1 + c_LVL / _factor);
- var base_stat_max = (max_stat + 0.005) / (1 + c_LVL / _factor);
- if( stats.length > 1)
- stats_data[working_j] += stats[1] + ";";
- if( stats.length > 1 && p_LVL != -1)
- {
- // Stats scaled to player's level
- var cur_stat = parseFloat(stats[1]);
- base_stat_min = Math.max( base_stat_min, (cur_stat - 0.005) / (1 + p_LVL / _factor));
- base_stat_max = Math.min( base_stat_max, (cur_stat + 0.005) / (1 + p_LVL / _factor));
- }
- // Round the average and error to two decimals
- var base_stat = Math.round( (base_stat_min + base_stat_max) / 2 * 100) / 100;
- var base_diff = Math.round( (base_stat_max - base_stat_min) / 2 * 100) / 100;
- if( base_diff == 0) base_diff = "";
- else base_diff = "±" + base_diff;
- // Add to working array
- if( working_array.length != 0)
- {
- working_array[w_i] = base_stat;
- w_i++;
- }
- if( _factor2 != 1)
- base_stat = Math.round( base_stat/_factor2);
- return "" + base_stat + base_diff;
- }
- function get_level()
- {
- return -1;
- }
- {
- // Parse all the equipments in the leftpane
- // get_equipment_bbcode(document.getElementById('leftpane'),'eqdp'); // Non-equipped items
- // get_equipment_bbcode(document.getElementById('leftpane'),'eqde'); // Equipped items
- var p_LVL = get_level();
- var EID_array = new Array();
- var stats_data = new Array();
- for( i = 0; i < factor_data.length; i++)
- stats_data[i] = factor_data[i][2] + ";";
- EID_array = GM_getValue("EID_array","").split(';');
- format_all_items();
- GM_setValue("EID_array",EID_array.join(';'));
- var equipmentroot = document.getElementById('equipment');
- if(equipmentroot != null)
- {
- equipmentroot.setAttribute('style', equipmentroot.getAttribute('style').replace("width: 320px", "width: 380px"));
- var eHTML = equipmentroot.innerHTML
- equipmentroot.innerHTML = eHTML.replace(/<table.+<\/table>/img,format_item_table(eHTML.match(/<table.+<\/table>/img)[0], parseInt(eHTML.match(/Level \d+?\s/)[0].replace("Level ",""))));
- }
- // if( list != "")
- {
- // Create Text Box in lower left to copy text from
- var newElement = document.createElement('div');
- newElement.setAttribute( 'style', "position:absolute; left:10px; bottom:10px; z-index:999;");
- // NOTE: w_str was something before this. I don't care right now, but I might care later
- w_str = "";
- for( i = 0; i < factor_data.length; i++)
- w_str += stats_data[i] + "\n";
- newElement.innerHTML = "Equip Link BBCode:<br /><textarea cols='40' rows='0'>"+w_str+"</textarea>";
- var entry_point = document.getElementsByTagName( 'body')[0];
- entry_point.insertBefore( newElement, entry_point.firstChild);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment