// ==UserScript==
// @name HV Keybinds
// @namespace HVKEYBIND
// @version 2.4.1
// @description Adds customized keybinding to HV
// @match
http://hentaiverse.org/*// @include
http://hentaiverse.org/*// ==/UserScript==
var bindings = new Array();
var KEY_A = 65, KEY_B = 66, KEY_C = 67, KEY_D = 68, KEY_E = 69, KEY_F = 70, KEY_G = 71, KEY_H = 72, KEY_I = 73, KEY_J = 74, KEY_K = 75, KEY_L = 76, KEY_M = 77;
var KEY_N = 78, KEY_O = 79, KEY_P = 80, KEY_Q = 81, KEY_R = 82, KEY_S = 83, KEY_T = 84, KEY_U = 85, KEY_V = 86, KEY_W = 87, KEY_X = 88, KEY_Y = 89, KEY_Z = 90;
var KEY_1 = 49, KEY_2 = 50, KEY_3 = 51, KEY_4 = 52, KEY_5 = 53, KEY_6 = 54, KEY_7 = 55, KEY_8 = 56, KEY_9 = 57, KEY_0 = 48;
var KEY_SPACE = 32, KEY_ENTER = 13, KEY_PAGEUP = 33, KEY_PAGEDOWN = 34, KEY_END = 35, KEY_HOME = 36, KEY_UP = 37, KEY_UP = 38, KEY_RIGHT = 39, KEY_DOWN = 40;
var KEY_F1 = 112, KEY_F2 = 113, KEY_F3 = 114, KEY_F4 = 115, KEY_F5 = 116, KEY_F6 = 117, KEY_F7 = 118, KEY_F8 = 119, KEY_F9 = 120, KEY_F10 = 121, KEY_F11 = 122, KEY_F12 = 123;
var KEY_COMMA = 188, KEY_PERIOD = 190, KEY_SLASH = 191, KEY_FORWARDSLASH = 191, KEY_GRAVE = 192, KEY_TILDE = 192, KEY_LBRACKET = 219, KEY_BACKSLASH = 220;
var KEY_SEMI = 186, KEY_RBRACKET = 221, KEY_APOSTROPHE = 222;
var NextRound = function() {} //dummy function
//For keycodes: [
www.javascripter.net]
http://www.javascripter.net/faq/keycodes.htm// or: [
www.cambiaresearch.com]
http://www.cambiaresearch.com/articles/15/...codes-key-codes// or: Use above codes for most keys.
// Just add this for as many bindings as you want:
// Bind(KeyCode, Modifier, Action);
// KeyCode = From links above
// Modifier = This is OPTIONAL. Valid mods are NoMod, Shift, Ctrl, Alt, CtrlShift, AltShift, CtrlAlt, CtrlAltShift
// Action = Valid actions:
// Cast("Spell Name")
// Spell Name or Item Name, except for potions.
// UseNext(ItemType)
// (Currently) Valid ItemTypes are HealthPotion, ManaPotion, SpiritPotion. These will be used in the order they appear in your item list.
// Nothing
// Use this to unbind a default key
// Target1 - Target10
// Targets the specified monster.
// PowerupGem
// Uses the powerup gem.
// NextRound
// Enters next round. Using this overrides both Space and Enter for next round. If you still want to use one of those, add it manually.
//
// Examples:
// Bind(KEY_M, Shift, UseNext(ManaPotion)); -- Shift + M = Use next mana potion
// Bind(KEY_LBRACKET, Cast("WRATH OF THOR")); -- Case insensitive. Key [ = cast Wrath of Thor
// Bind(KEY_A, Nothing); -- You can unbind a default key
// Bind(KEY_I, Cast("Infusion of Storms"); -- I uses Infusion of Storms
Bind(KEY_X, Cast("Corruption"));
Bind(KEY_S, Cast("Disintegrate"));
Bind(KEY_Q, Cast("Imperil"));
Bind(KEY_Z, Cast("Smite"));
Bind(KEY_A, Cast("Banishment"));
Bind(KEY_W, Cast("Weaken"));
Bind(KEY_C, Cast("Cure"));
Bind(KEY_D, Cast("Paradise Lost"));
Bind(KEY_F, Cast("Ragnarok"));
Bind(KEY_O, Use("Mana"));
Bind(KEY_P, Use("Spirit"));
// Don't edit anything below. Unless you want to.
if (document.getElementById('togpane_log')) {
var overriddenKeyDown = document.onkeydown;
document.onkeydown = function(e) {
var didKeybind = false;
var roundEndHasOverride = false;
var roundEnded = (document.querySelector("#mainpane form > div.btt > div.btcp > div.btcd > img") || document.getElementById("ckey_continue"));
if (!roundEnded) {
for (i = 0; i < bindings.length ; i++) {
var bind = bindings[i];
if (e.keyCode == bind.keyCode && bind.modifier(e)) {
bind.action();
didKeybind = true;
return true;
}
}
} else {
for (i = 0; i < bindings.length ; i++) {
var bind = bindings[i];
if (bind.action === NextRound) {
roundEndHasOverride = true;
if (e.keyCode == bind.keyCode && bind.modifier(e)) {
roundEnded.onclick();
e.preventDefault();
return false;
}
}
}
}
if (roundEndHasOverride) {
e.preventDefault();
return false;
}
if (!didKeybind) {
return overriddenKeyDown(e);
} else {
e.preventDefault();
return false;
}
}
}
function Bind(key, mod, command) {
if (!command) {
command = mod;
mod = NoMod;
}
if (!command) return;
addKeybind(key, mod, command);
}
function addKeybind(key, mod, command) {
bindings.push(new Keybind(key,mod,command));
}
function getSpell(name){
return document.querySelector('.bts>div[onmouseover *= "'+name+'"]');
}
function Cast(name) {
var spell = getSpell(name);
if(spell.id > 1000){
return function(){
if(document.querySelector('#togpane_magico[style="display:none"]')){
document.querySelector('.btpm2>img[onclick]').onclick();
}
spell.onmouseover();
spell.onclick();
}
}else{
return function(){
if(document.querySelector('#togpane_magict[style="display:none"]')){
document.querySelector('.btpm3>img[onclick]').onclick();
}
spell.onmouseover();
spell.onclick();
}
}
return null;
}
function Use(name){
return function(){
var item_list = document.querySelectorAll('.bti3>div');
for(var i=0; i<item_list.length; i++){
var item = item_list[i];
if(item.onmouseover && item.onmouseover.toString().match(name)){
item.onclick();
break;
}
}
}
}
function Keybind(key, mod, action) {
this.keyCode = key;
this.modifier = mod;
this.action = action;
}
function NoMod(e) { return !e.shiftKey && !e.altKey && !e.ctrlKey; }
function CtrlAltShift(e) { return e.shiftKey && e.altKey && e.ctrlKey; }
function CtrlShift(e) { return !e.altKey && e.shiftKey && e.ctrlKey; }
function AltShift(e) { return !e.ctrlKey && e.altKey && e.shiftKey; }
function CtrlAlt(e) { return !e.shiftKey && e.ctrlKey && e.altKey; }
function Ctrl(e) { return e.ctrlKey && !e.shiftKey && !e.altKey; }
function Shift(e) { return e.shiftKey && !e.ctrlKey && !e.altKey; }
function Alt(e) { return e.altKey && !e.shiftKey && !e.ctrlKey; }
function Nothing() {} //for unbinding default keys
function TargetMonster(num) {
var monster = document.getElementById("mkey_"+num);
if (monster) {
monster.onclick();
}
}
function Target1() { TargetMonster(1) }
function Target2() { TargetMonster(2) }
function Target3() { TargetMonster(3) }
function Target4() { TargetMonster(4) }
function Target5() { TargetMonster(5) }
function Target6() { TargetMonster(6) }
function Target7() { TargetMonster(7) }
function Target8() { TargetMonster(8) }
function Target9() { TargetMonster(9) }
function Target10() { TargetMonster(0) }
function PowerupGem() {
var pgem = document.getElementById("ikey_p");
if (pgem) {
pgem.onclick();
}
}