Eternity Tower Quick Sets

Equips skin, gear, and abilities in configurable sets

当前为 2018-01-02 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name          Eternity Tower Quick Sets
// @icon          https://www.eternitytower.net/favicon.png
// @namespace     http://mean.cloud/
// @version       1.04
// @description   Equips skin, gear, and abilities in configurable sets
// @match         http*://*.eternitytower.net/*
// @copyright     2017-2018, MeanCloud
// @grant         GM_getValue
// @grant         GM_setValue
// @grant         GM_deleteValue
// @run-at        document-body
// ==/UserScript==

function addJQuery(callback)
{
    var script = document.createElement("script");
    script.setAttribute("src", "//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js");
    script.addEventListener('load', function()
    {
        var script = document.createElement("script");
        script.textContent = "window.jQ=jQuery.noConflict(true);(" + callback.toString() + ")();";
        document.body.appendChild(script);
    }, false);
    document.body.appendChild(script);
}

document.PETQS_SkinEquipped = "";
document.PETQS_EquippedItems = [];
document.PETQS_EquippedAbilities = [];
document.PETQS_UserID = "";
document.PETQS_CombatID = "";
document.PETQS_AllItems = [];
document.PETQS_PageOn = 1;
document.PETQS_PageMax = 10;
document.PETQS_SetsPerPage = 8;

function main()
{
    Meteor.connection._stream.on('message', function(sMeteorRawData)
    {
        try
        {
            var oMeteorData = JSON.parse(sMeteorRawData);

            try
            {
                if (oMeteorData.collection == "users")
                    document.PETQS_UserID = oMeteorData.id;

                if (oMeteorData.collection == "combat")
                {
                    if ((oMeteorData.fields.owner === document.PETQS_UserID) && (document.PETQS_CombatID === ""))
                        document.PETQS_CombatID = oMeteorData.id;

                    if ((oMeteorData.id === document.PETQS_CombatID) || (document.PETQS_CombatID === ""))
                        if (oMeteorData.fields.characterIcon)
                            document.PETQS_SkinEquipped = oMeteorData.fields.characterIcon;
                }
            }
            catch (err) { console.log("Error with PETQS/combat: " + err); }

            try
            {
                if (oMeteorData.collection == "abilities")
                {
                    if (oMeteorData.fields && oMeteorData.fields.learntAbilities)
                    {
                        document.PETQS_EquippedAbilities = [];

                        jQ.makeArray(oMeteorData.fields.learntAbilities).forEach(function(oAbility, index, array)
                        {
                            try
                            {
                                if (oAbility.equipped)
                                    document.PETQS_EquippedAbilities.push(oAbility);
                            }
                            catch (err) { console.log("Error with PETQS/ability: " + err); }
                        });
                    }
                }
            }
            catch (err) { console.log("Error with PETQS/abilities: " + err); }

            try
            {
                if (oMeteorData.collection == "items")
                {
                    if (oMeteorData.msg == "added")
                        if (oMeteorData.fields && oMeteorData.fields.itemId && oMeteorData.fields.name && oMeteorData.fields.category)
                            document.PETQS_AllItems.push(oMeteorData);

                    if (oMeteorData.fields.equipped)
                    {
                        document.PETQS_EquippedItems.push(oMeteorData);
                    }
                    else
                    {
                        if (document.PETQS_EquippedItems.length > 0)
                        {
                            for (i = 0; i < document.PETQS_EquippedItems.length; i++)
                            {
                                if (document.PETQS_EquippedItems[i].id == oMeteorData.id)
                                {
                                    document.PETQS_EquippedItems.splice(i, 1);
                                    break;
                                }
                            }
                        }
                    }
                }
            }
            catch (err) { console.log("Error with PETQS/items: " + err); }
        }
        catch (err) { console.log("Error with PETQS/meteor: " + err); }
    });

    document.PETQS_TestUI();
}

document.PETQS_TestUI = function()
{
    try
    {
        if (jQ("div#PETQS_UI").length === 0)
            if (jQ("div.hidden-lg-down").length > 0)
                document.PETQS_CreateUI();
    }
    catch (err) { }

    setTimeout(document.PETQS_TestUI, 1000);
};

document.PETQS_CreateUI = function()
{
    jQ("div#PETQS_UI").remove();

    jQ(jQ("div.hidden-lg-down").children("div").get(0)).append
    (
        "<div style=\"margin-top: 20px; border: 1px solid #dde; background-color: #fafbfd; padding: 5px; width: 280px; font-size: 14px;\" id=\"PETQS_UI\">" +
        "<div style=\"width: 270px; max-width: 270px; height: 22px; cursor: pointer;\" id=\"PETQS_Slotbar" + document.pad(1 + ((document.PETQS_PageOn - 1) * document.PETQS_SetsPerPage), 2) + "\" onclick=\"javascript:document.PETQS_ClickedSet(" + (1 + ((document.PETQS_PageOn - 1) * document.PETQS_SetsPerPage)).toFixed(0) + ",event);\">[empty set]</div>" +
        "<div style=\"width: 270px; max-width: 270px; height: 22px; cursor: pointer;\" id=\"PETQS_Slotbar" + document.pad(2 + ((document.PETQS_PageOn - 1) * document.PETQS_SetsPerPage), 2) + "\" onclick=\"javascript:document.PETQS_ClickedSet(" + (2 + ((document.PETQS_PageOn - 1) * document.PETQS_SetsPerPage)).toFixed(0) + ",event);\">[empty set]</div>" +
        "<div style=\"width: 270px; max-width: 270px; height: 22px; cursor: pointer;\" id=\"PETQS_Slotbar" + document.pad(3 + ((document.PETQS_PageOn - 1) * document.PETQS_SetsPerPage), 2) + "\" onclick=\"javascript:document.PETQS_ClickedSet(" + (3 + ((document.PETQS_PageOn - 1) * document.PETQS_SetsPerPage)).toFixed(0) + ",event);\">[empty set]</div>" +
        "<div style=\"width: 270px; max-width: 270px; height: 22px; cursor: pointer; margin-bottom: 4px;\" id=\"PETQS_Slotbar" + document.pad(4 + ((document.PETQS_PageOn - 1) * document.PETQS_SetsPerPage), 2) + "\" onclick=\"javascript:document.PETQS_ClickedSet(" + (4 + ((document.PETQS_PageOn - 1) * document.PETQS_SetsPerPage)).toFixed(0) + ",event);\">[empty set]</div>" +
        "<div style=\"width: 270px; max-width: 270px; height: 22px; cursor: pointer; border-top: 1px solid #dde;\" id=\"PETQS_Slotbar" + document.pad(5 + ((document.PETQS_PageOn - 1) * document.PETQS_SetsPerPage), 2) + "\" onclick=\"javascript:document.PETQS_ClickedSet(" + (5 + ((document.PETQS_PageOn - 1) * document.PETQS_SetsPerPage)).toFixed(0) + ",event);\">[empty set]</div>" +
        "<div style=\"width: 270px; max-width: 270px; height: 22px; cursor: pointer;\" id=\"PETQS_Slotbar" + document.pad(6 + ((document.PETQS_PageOn - 1) * document.PETQS_SetsPerPage), 2) + "\" onclick=\"javascript:document.PETQS_ClickedSet(" + (6 + ((document.PETQS_PageOn - 1) * document.PETQS_SetsPerPage)).toFixed(0) + ",event);\">[empty set]</div>" +
        "<div style=\"width: 270px; max-width: 270px; height: 22px; cursor: pointer;\" id=\"PETQS_Slotbar" + document.pad(7 + ((document.PETQS_PageOn - 1) * document.PETQS_SetsPerPage), 2) + "\" onclick=\"javascript:document.PETQS_ClickedSet(" + (7 + ((document.PETQS_PageOn - 1) * document.PETQS_SetsPerPage)).toFixed(0) + ",event);\">[empty set]</div>" +
        "<div style=\"width: 270px; max-width: 270px; height: 22px; cursor: pointer;\" id=\"PETQS_Slotbar" + document.pad(8 + ((document.PETQS_PageOn - 1) * document.PETQS_SetsPerPage), 2) + "\" onclick=\"javascript:document.PETQS_ClickedSet(" + (8 + ((document.PETQS_PageOn - 1) * document.PETQS_SetsPerPage)).toFixed(0) + ",event);\">[empty set]</div>" +
        "<div style=\"width: 270px; max-width: 270px; padding-top: 10px;\">" +
        "<input type=\"button\" value=\"Save #" + (1 + ((document.PETQS_PageOn - 1) * document.PETQS_SetsPerPage)).toFixed(0) + "\" onclick=\"javascript:document.PETQS_SaveSet(" + (1 + ((document.PETQS_PageOn - 1) * document.PETQS_SetsPerPage)).toFixed(0) + ");\" style=\"display: inline-block; width: 64px; font-size: 12px;\" /> " +
        "<input type=\"button\" value=\"Save #" + (2 + ((document.PETQS_PageOn - 1) * document.PETQS_SetsPerPage)).toFixed(0) + "\" onclick=\"javascript:document.PETQS_SaveSet(" + (2 + ((document.PETQS_PageOn - 1) * document.PETQS_SetsPerPage)).toFixed(0) + ");\" style=\"display: inline-block; width: 64px; font-size: 12px;\" /> " +
        "<input type=\"button\" value=\"Save #" + (3 + ((document.PETQS_PageOn - 1) * document.PETQS_SetsPerPage)).toFixed(0) + "\" onclick=\"javascript:document.PETQS_SaveSet(" + (3 + ((document.PETQS_PageOn - 1) * document.PETQS_SetsPerPage)).toFixed(0) + ");\" style=\"display: inline-block; width: 64px; font-size: 12px;\" /> " +
        "<input type=\"button\" value=\"Save #" + (4 + ((document.PETQS_PageOn - 1) * document.PETQS_SetsPerPage)).toFixed(0) + "\" onclick=\"javascript:document.PETQS_SaveSet(" + (4 + ((document.PETQS_PageOn - 1) * document.PETQS_SetsPerPage)).toFixed(0) + ");\" style=\"display: inline-block; width: 64px; font-size: 12px;\" /><br />" +
        "<input type=\"button\" value=\"Save #" + (5 + ((document.PETQS_PageOn - 1) * document.PETQS_SetsPerPage)).toFixed(0) + "\" onclick=\"javascript:document.PETQS_SaveSet(" + (5 + ((document.PETQS_PageOn - 1) * document.PETQS_SetsPerPage)).toFixed(0) + ");\" style=\"display: inline-block; width: 64px; font-size: 12px;\" /> " +
        "<input type=\"button\" value=\"Save #" + (6 + ((document.PETQS_PageOn - 1) * document.PETQS_SetsPerPage)).toFixed(0) + "\" onclick=\"javascript:document.PETQS_SaveSet(" + (6 + ((document.PETQS_PageOn - 1) * document.PETQS_SetsPerPage)).toFixed(0) + ");\" style=\"display: inline-block; width: 64px; font-size: 12px;\" /> " +
        "<input type=\"button\" value=\"Save #" + (7 + ((document.PETQS_PageOn - 1) * document.PETQS_SetsPerPage)).toFixed(0) + "\" onclick=\"javascript:document.PETQS_SaveSet(" + (7 + ((document.PETQS_PageOn - 1) * document.PETQS_SetsPerPage)).toFixed(0) + ");\" style=\"display: inline-block; width: 64px; font-size: 12px;\" /> " +
        "<input type=\"button\" value=\"Save #" + (8 + ((document.PETQS_PageOn - 1) * document.PETQS_SetsPerPage)).toFixed(0) + "\" onclick=\"javascript:document.PETQS_SaveSet(" + (8 + ((document.PETQS_PageOn - 1) * document.PETQS_SetsPerPage)).toFixed(0) + ");\" style=\"display: inline-block; width: 64px; font-size: 12px;\" /><br />" +
        "<input type=\"button\" value=\"&lt;  Prev Page\" onclick=\"javascript:document.PETQS_PageChange(-1);\" style=\"display: inline-block; width: 132px; font-size: 12px;\" /> " +
        "<input type=\"button\" value=\"Next Page  &gt;\" onclick=\"javascript:document.PETQS_PageChange(1);\" style=\"display: inline-block; width: 132px; font-size: 12px;\" /><br />" +
        "</div>" +
        "</div>"
    );

    for (iSlot = 1; iSlot <= document.PETQS_SetsPerPage; iSlot++)
        document.PETQS_LoadSet(iSlot + ((document.PETQS_PageOn - 1) * document.PETQS_SetsPerPage));
};

document.PETQS_PageChange = function(iAmt)
{
	document.PETQS_PageOn += iAmt;
	if (document.PETQS_PageOn < 0)
		document.PETQS_PageOn = document.PETQS_PageMax;
	if (document.PETQS_PageOn > document.PETQS_PageMax)
		document.PETQS_PageOn = 1;
	document.PETQS_CreateUI();
}

document.PETQS_UpdateSetTooltip = function(iSlot, bEmpty)
{
    oEl = jQ("#PETQS_Slotbar" + document.pad(iSlot, 2)).get(0);
    if (!oEl)
        return;

    if (oEl._tippy)
        oEl._tippy.destroy();

    jQ("#tooltip-PETQS_Slotbar" + document.pad(iSlot, 2)).remove();
    jQ("body").append("<div class=\"item-tooltip-content my-tooltip-inner\" id=\"tooltip-PETQS_Slotbar" + document.pad(iSlot, 2) + "\"></div>");

    if (bEmpty)
    {
        jQ("#tooltip-PETQS_Slotbar" + document.pad(iSlot, 2)).html
        (
            "    <h3 class=\"popover-title\">" +
            "        " + (document.CookieGet("PETQS_Name" + document.pad(iSlot, 2)) || "Quick Set #" + iSlot.toFixed(0)) +
            "    </h3>" +
            "    <div class=\"popover-content\">" +
            "        set #" + iSlot.toFixed(0) + "<br />" +
            "        this set is empty" +
            "    </div>"
        );
    }
    else
    {
        jQ("#tooltip-PETQS_Slotbar" + document.pad(iSlot, 2)).html
        (
            "    <h3 class=\"popover-title\">" +
            "        " + (document.CookieGet("PETQS_Name" + document.pad(iSlot, 2)) || "Quick Set #" + iSlot.toFixed(0)) +
            "    </h3>" +
            "    <div class=\"popover-content\">" +
            "        set #" + iSlot.toFixed(0) + "<br />" +
            "        <b>Left Click</b> to equip this set<br />" +
            "        <b>Shift Click</b> to rename this set<br />" +
            "        <b>Control Click</b> to delete this set" +
            "    </div>"
        );
    }

    tippy("#PETQS_Slotbar" + document.pad(iSlot, 2),
    {
        html: jQ("#tooltip-PETQS_Slotbar" + document.pad(iSlot, 2))[0],
        performance: !0,
        animateFill: !1,
        distance: 5
    });
};

document.PETQS_ClickedSet = function(iSlot, e)
{
    var bShiftPressed = false;
    var bCtrlPressed = false;

    try
	{
		if (e !== null)
        {
			if (e.shiftKey) bShiftPressed = true;
			if (e.ctrlKey)  bCtrlPressed = true;
        }
	}
	catch (err) { }

    if (bShiftPressed)
    {
        var sSetName = prompt("Enter a new name for this set:", document.CookieGet("PETQS_Name" + document.pad(iSlot, 2)) || "Quick Set #" + iSlot.toFixed(0));
        if (sSetName !== null)
        {
            document.CookieSet("PETQS_Name" + document.pad(iSlot, 2), sSetName.trim());
            document.PETQS_LoadSet(iSlot);
        }
    }
    else if (bCtrlPressed)
    {
        if (confirm("Really delete set #" + iSlot.toFixed(0) + " (\"" + (document.CookieGet("PETQS_Name" + document.pad(iSlot, 2)) || "Quick Set #" + iSlot.toFixed(0)) + "\")?"))
        {
            document.CookieDelete("PETQS_Name" + document.pad(iSlot, 2));
            document.CookieDelete("PETQS_QS" + document.pad(iSlot, 2));
            jQ("div#PETQS_Slotbar" + document.pad(iSlot, 2)).html("[empty set]");
            document.PETQS_UpdateSetTooltip(iSlot, true);
        }
    }
    else
        document.PETQS_LoadSet(iSlot, true);
};

document.PETQS_SaveSet = function(iSlot)
{
    var sSetting = "";

    sSetting += "skin&&" + document.PETQS_SkinEquipped + "||";

    try
    {
        jQ.makeArray(document.PETQS_EquippedItems).forEach(function(oEquippedItem, index, array)
        {
            //console.log(oEquippedItem);

            try
            {
                var oEquippedItemToUse = oEquippedItem;

                if (!oEquippedItem.fields.category)
                {
                    jQ.makeArray(document.PETQS_AllItems).forEach(function(oThisItem, index2, array2)
                    {
                        if ((oThisItem.id === oEquippedItem.id) && (oThisItem.fields.category))
                        {
                            oEquippedItemToUse = oThisItem;
                            //console.log("--> ", oEquippedItemToUse);
                        }
                    });
                }

                sSetting +=     "item&&"
                              + oEquippedItemToUse.id + "&&"
                              + oEquippedItemToUse.fields.itemId + "&&"
                              + oEquippedItemToUse.fields.name + "&&"
                              + (oEquippedItem.fields.slot ? oEquippedItem.fields.slot : oEquippedItemToUse.fields.slot) + "&&"
                              + oEquippedItemToUse.fields.icon + "&&"
                              + (oEquippedItemToUse.fields.quality ? oEquippedItemToUse.fields.quality.toFixed(0) : "-1") + "&&"
                              + (oEquippedItemToUse.fields.enhanced ? "E" : "X") + "||";
            }
            catch (err) { console.log("Error with PETQS/saveItem: " + err); }
        });
    }
    catch (err) { console.log("Error with PETQS/saveItems: " + err); }

    try
    {
        jQ.makeArray(document.PETQS_EquippedAbilities).forEach(function(oEquippedAbility, index, array)
        {
            //console.log(oEquippedAbility);

            try
            {
                sSetting +=     "ability&&"
                              + oEquippedAbility.abilityId + "&&"
                              + oEquippedAbility.name + "&&"
                              + oEquippedAbility.slot + "&&"
                              + oEquippedAbility.icon + "||";
            }
            catch (err) { console.log("Error with PETQS/saveAbility: " + err); }
        });
    }
    catch (err) { console.log("Error with PETQS/saveAbilities: " + err); }

    //console.log("Save: " + sSetting);

    document.CookieSet("PETQS_QS" + document.pad(iSlot, 2), sSetting);

    document.PETQS_LoadSet(iSlot);
};

document.PETQS_LoadSet = function(iSlot, bEquip = false)
{
    var sRawSetting = document.CookieGet("PETQS_QS" + document.pad(iSlot, 2)) || "";
    //console.log("Load: " + sRawSetting);

    if (sRawSetting === "")
    {
        document.PETQS_UpdateSetTooltip(iSlot, true);
        return;
    }

    var sSettingLines = jQ.makeArray(sRawSetting.split("||"));
    var sHotbarHTML = "";

    const sImageSize = "22px";

    if (bEquip)
    {
        Meteor.connection._send({"msg":"method","method":"abilities.unequip","params":["head"],"id":"-1"});
        Meteor.connection._send({"msg":"method","method":"abilities.unequip","params":["chest"],"id":"-1"});
        Meteor.connection._send({"msg":"method","method":"abilities.unequip","params":["offHand"],"id":"-1"});
        Meteor.connection._send({"msg":"method","method":"abilities.unequip","params":["mainHand"],"id":"-1"});
        Meteor.connection._send({"msg":"method","method":"abilities.unequip","params":["legs"],"id":"-1"});

        var equipmentCopy = document.PETQS_EquippedItems.slice();

        if (equipmentCopy.length > 0)
            for (i = 0; i < equipmentCopy.length; i++)
                if (equipmentCopy[i].fields.category != "mining")
                    Meteor.connection._send({"msg":"method","method":"items.unequip","params":[equipmentCopy[i].id,equipmentCopy[i].fields.itemId],"id":"-1"});
    }

    // look for skins first
    sSettingLines.forEach(function(sSettingLine, index, array)
    {
        try
        {
            var sSettingVals = jQ.makeArray(sSettingLine.split("&&"));

            if (sSettingVals[0] == "skin")
            {
                //console.log("skin: " + sSettingVals[1]);

                sHotbarHTML += "<img src=\"/icons/" + sSettingVals[1] + "\" class=\"extra-small-icon\" style=\"width: " + sImageSize + "; height: " + sImageSize + "; padding: 0px; margin: 0px; border: none;\" />";

                if (bEquip)
                {
                    // there's a lookup table for this, but this code is simpler since there's not that many skins
                    // I am a lazy programmer
                    if (sSettingVals[1] == "mageT1HD.png") Meteor.connection._send({"msg":"method","method":"combat.updateCharacterIcon","params":["mage_t1"],"id":"-1"});
                    if (sSettingVals[1] == "mageT2HD.png") Meteor.connection._send({"msg":"method","method":"combat.updateCharacterIcon","params":["mage_t2"],"id":"-1"});
                    if (sSettingVals[1] == "damageT1HD.png") Meteor.connection._send({"msg":"method","method":"combat.updateCharacterIcon","params":["damage_t1"],"id":"-1"});
                    if (sSettingVals[1] == "damageT2HD.png") Meteor.connection._send({"msg":"method","method":"combat.updateCharacterIcon","params":["damage_t2"],"id":"-1"});
                    if (sSettingVals[1] == "tankT1HD.png") Meteor.connection._send({"msg":"method","method":"combat.updateCharacterIcon","params":["tank_t1"],"id":"-1"});
                    if (sSettingVals[1] == "tankT2HD.png") Meteor.connection._send({"msg":"method","method":"combat.updateCharacterIcon","params":["tank_t2"],"id":"-1"});
                    if (sSettingVals[1] == "phoenixT1.png") Meteor.connection._send({"msg":"method","method":"combat.updateCharacterIcon","params":["phoenix_t1"],"id":"-1"});
                    if (sSettingVals[1] == "phoenixT2.png") Meteor.connection._send({"msg":"method","method":"combat.updateCharacterIcon","params":["phoenix_t2"],"id":"-1"});
                    if (sSettingVals[1] == "crowT1.png") Meteor.connection._send({"msg":"method","method":"combat.updateCharacterIcon","params":["crow_t1"],"id":"-1"});
                    if (sSettingVals[1] == "crowT2.png") Meteor.connection._send({"msg":"method","method":"combat.updateCharacterIcon","params":["crow_t2"],"id":"-1"});
                    if (sSettingVals[1] == "vallaT1.png") Meteor.connection._send({"msg":"method","method":"combat.updateCharacterIcon","params":["valla_t1"],"id":"-1"});
                    if (sSettingVals[1] == "adalgarT1.png") Meteor.connection._send({"msg":"method","method":"combat.updateCharacterIcon","params":["adalgar_t1"],"id":"-1"});
                }
            }
        }
        catch (err) { }
    });

    // look for gear
    for (i = 1; i <= 6; i++)
    {
        sSettingLines.forEach(function(sSettingLine, index, array)
        {
            try
            {
                var sSettingVals = jQ.makeArray(sSettingLine.split("&&"));

                if (sSettingVals[0] == "item")
                {
                    if ((i == 1) && (sSettingVals[4] != "mainHand")) return;
                    if ((i == 2) && (sSettingVals[4] != "offHand")) return;
                    if ((i == 3) && (sSettingVals[4] != "head")) return;
                    if ((i == 4) && (sSettingVals[4] != "neck")) return;
                    if ((i == 5) && (sSettingVals[4] != "chest")) return;
                    if ((i == 6) && (sSettingVals[4] != "legs")) return;

                    //console.log("item: " + sSettingVals[3]);

                    sHotbarHTML += "<img src=\"/icons/" + sSettingVals[5] + "\" class=\"extra-small-icon\" style=\"width: " + sImageSize + "; height: " + sImageSize + "; padding: 0px; margin: 0px; border: none;\" />";

                    if (bEquip)
                        Meteor.connection._send({"msg":"method","method":"items.equip","params":[sSettingVals[1],sSettingVals[2]],"id":"-1"});
                }
            }
            catch (err) { }
        });
    }

    // look for abilities
    for (i = 1; i <= 5; i++)
    {
        sSettingLines.forEach(function(sSettingLine, index, array)
        {
            try
            {
                var sSettingVals = jQ.makeArray(sSettingLine.split("&&"));

                if (sSettingVals[0] == "ability")
                {
                    if ((i == 1) && (sSettingVals[3] != "mainHand")) return;
                    if ((i == 2) && (sSettingVals[3] != "offHand")) return;
                    if ((i == 3) && (sSettingVals[3] != "head")) return;
                    if ((i == 4) && (sSettingVals[3] != "chest")) return;
                    if ((i == 5) && (sSettingVals[3] != "legs")) return;

                    //console.log("ability: " + sSettingVals[2]);

                    sHotbarHTML += "<img src=\"/icons/" + sSettingVals[4] + "\" class=\"extra-small-icon\" style=\"width: " + sImageSize + "; height: " + sImageSize + "; padding: 0px; margin: 0px; border: none;\" />";

                    if (bEquip)
                        Meteor.connection._send({"msg":"method","method":"abilities.equip","params":[sSettingVals[1]],"id":"-1"});
                }
            }
            catch (err) { }
        });
    }

    jQ("div#PETQS_Slotbar" + document.pad(iSlot, 2)).html(sHotbarHTML);
    document.PETQS_UpdateSetTooltip(iSlot, false);
};

document.CDbl = function(v)
{
	try
	{
		if (!isNaN(v)) return parseFloat(v);
		if (typeof v === 'undefined') return parseFloat(0.0);
		if (v === null) return parseFloat(0.0);
		var t = parseFloat(v);
		if (isNaN(t)) return parseFloat(0.0);
		return t;
	}
	catch (err) { }

	return parseFloat(0.0);
};

document.CInt = function(v)
{
	try
	{
		if (!isNaN(v)) return parseInt(v);
		if (typeof v === 'undefined') return parseInt(0);
		if (v === null) return parseInt(0);
		var t = parseInt(v);
		if (isNaN(t)) return parseInt(0);
		return t;
	}
	catch (err) { }

	return parseInt(0);
};

document.CookieSet = function(name, value, days = 1000)
{
	GM_setValue(name, value);
};

document.CookieGet = function(name, defVal = null)
{
	try { return GM_getValue(name, defVal); } catch (err) { }
	return null;
};

document.CookieDelete = function(name)
{
	GM_deleteValue(name);
};

document.pad = function(n, width, z)
{
  z = z || '0';
  n = n + '';
  return n.length >= width ? n : new Array(width - n.length + 1).join(z) + n;
};

addJQuery(main);