· 9 years ago · Jan 03, 2017, 04:38 PM
1// ==UserScript==
2// @name InitiumPro
3// @namespace https://github.com/hey-nails/InitiumPro
4// @version 0.5
5// @updateURL https://raw.githubusercontent.com/hey-nails/InitiumPro/master/InitiumPro.js
6// @downloadURL https://raw.githubusercontent.com/hey-nails/InitiumPro/master/InitiumPro.js
7// @supportURL https://github.com/hey-nails/InitiumPro
8// @match https://www.playinitium.com/*
9// @match http://www.playinitium.com/*
10// @grant none
11// @grant GM_setValue
12// @grant GM_info
13// ==/UserScript==
14/* jshint -W097 */
15
16'use strict';
17
18/*** INITIUM PRO OPTIONS ***/
19
20var AUTO_GOLD = true; //auto get gold after battles and when entering a room
21var AUTO_REST = true; //auto rest if injured and in restable area
22var AUTO_SWING = true; //repeats attack after your initial attack
23var AUTO_LEAVE_FORGET = false; //automatically clicks 'Leave and Forget' after a battle
24var AUTO_FLEE = 80; //percent of health to flee automatically. 0 turns it off
25var AUTO_CONFIRM_POPUPS = false; //confirms popups like camp name so you can keep your fingers to the metal!
26var HIDE_VERSION = false; //this will hide pro icon with the version number (you jerk)
27
28/***************************/
29
30var $=window.jQuery,loc={},player={};
31
32//ajax queue
33(function($) {
34 var ajaxQueue = $({}); // jQuery on an empty object, we are going to use this as our Queue
35 $.ajaxQueue = function( ajaxOpts ) {
36 var jqXHR,dfd = $.Deferred(),promise = dfd.promise();
37 ajaxQueue.queue( doRequest ); // queue our ajax request
38 promise.abort = function( statusText ) { // add the abort method
39 if ( jqXHR ) return jqXHR.abort( statusText ); // proxy abort to the jqXHR if it is active
40 var queue = ajaxQueue.queue(),index = $.inArray( doRequest, queue ); // if there wasn't already a jqXHR we need to remove from queue
41 if ( index > -1 ) queue.splice( index, 1 );
42 dfd.rejectWith( ajaxOpts.context || ajaxOpts, [ promise, statusText, "" ] );// and then reject the deferred
43 return promise;
44 };
45 function doRequest( next ) { jqXHR = $.ajax( ajaxOpts ).done( dfd.resolve ).fail( dfd.reject ).then( next, next );} // run the actual query
46 return promise;
47 };
48})($);
49
50var krill=getThisPartyStarted();
51
52//EXTRA HOTKEYS: C for create campsite, H for show hidden paths
53document.addEventListener('keydown', function(e) {
54 if(e.srcElement.nodeName!='INPUT') {
55 if(e.key==="c") window.createCampsite();
56 if(e.key==="h")window.location.replace("/main.jsp?showHiddenPaths=true"); }}, false);
57
58//add shop item stats to shop view
59function loadShopItemDetails() {
60 window.FLAG_LOADSHOPITEMS=true;
61 var itemsLoaded = setInterval(function() {
62 var numSold=$(".saleItem-sold").length;
63 if (numSold) {
64 //hide sold toggle
65 $(".main-item-filter").append("<div style='padding:15px 1px;float:right;'><a id='toggle-sold-items'>Hide "+numSold+" sold items</a></div>");
66 $("#toggle-sold-items").bind('click',function() {
67 $(this).text($(this).text().substring(0,4) === "Hide"?"Show "+numSold+" sold items":"Hide "+numSold+" sold items");
68 $(".saleItem-sold").parent().parent().parent().toggleClass("hidden");
69 });
70
71 var shopItems=$(".saleItem");
72 for(var i=0;i<shopItems.length;i++) {
73 var itemId=$(shopItems[i]).find(".clue").attr("rel").split("=")[1],
74 itemImg=$(shopItems[i]).find(".clue").find("img").attr("src"),
75 itemCost=$(shopItems[i]).find(".main-item > span:eq(0)").text(),
76 itemBuyLink=$(shopItems[i]).find("a:eq(1)").attr("onclick");
77 $(shopItems[i]).append("<div class='shop-item-stats table' id='shop-item-container"+itemId+"'><div class='loading'>Loading item stats... <img src='/javascript/images/wait.gif'></div></div>");
78
79 $.ajax({
80 url: "viewitemmini.jsp?itemId="+itemId, type: "GET",
81 itemId: itemId,
82 itemImg: itemImg,
83 itemCost: itemCost,
84 itemBuyLink: itemBuyLink
85 }).done(function(data) {
86 var itemStatLines=$(data).find("div:not(#item-comparisons) .item-popup-field");
87 var itemStats={};
88 for(var t=0;t<itemStatLines.length && $(itemStatLines[t]).text().indexOf(":")!=-1;t++) {
89 var att=$(itemStatLines[t]).text().split(":");
90 if(att[1]) itemStats[formatItemStats(att[0])]=att[1].substring(1).replace(/(\r\n|\n|\r)/gm,"");
91 }
92 $("#shop-item-container"+this.itemId).html("<div class='row' id='shop-item-row-"+this.itemId+"'>"+
93 "<div class='cell'><img src='"+this.itemImg+"'></div>"+
94 "<div class='cell' id='shop-item-"+this.itemId+"'></div>"+
95 "<div class='cell shop-buy-button' onclick='"+this.itemBuyLink+"'>BUY<br/><span style='font-size:12px;'><img src='images/dogecoin-18px.png' class='small-dogecoin-icon' border='0/'> "+this.itemCost+"</span></div>"+
96 "</div>");
97 for(var i=0;i<Object.keys(itemStats).length;i++) {
98 var statName=Object.keys(itemStats)[i];
99 var statValue=itemStats[Object.keys(itemStats)[i]];
100 $("#shop-item-"+this.itemId).append("<div><span>"+statName+":</span> <span>"+statValue+"</span></div>");
101 }
102 return true;
103 });
104 }
105 window.FLAG_LOADSHOPITEMS=false;
106 clearInterval(itemsLoaded);
107 }
108 }, 1000);
109}
110
111//add list of carried products to shops overview
112function loadLocalMerchantDetails() {
113 window.FLAG_LOADSHOPS=true;
114 var shopsLoaded = setInterval(function() {
115 if ($('.main-merchant-container').length) {
116 var localMerchants=$(".main-merchant-container");
117 for(var i=0;i<localMerchants.length;i++) {
118 var shopId=$(localMerchants[i]).find("a").attr("onclick").slice(10,-1);
119 $(localMerchants[i]).append("<div class='merchant-inline-overview' id='store-overview-"+shopId+"'><div class='shop-overview'>Loading store overview... <img src='/javascript/images/wait.gif'></div></div>");
120 $.ajaxQueue({
121 url: "/odp/ajax_viewstore.jsp?characterId="+shopId+"&ajax=true",
122 shopId: shopId,
123 }).done(function(data) {
124 var shopItemSummary="",items={},itemData=$(data).find(".clue");
125 for(var i=0;i<itemData.length;i++) { //get uniques
126 var itemName=$(itemData[i]).text(),itemPic=$(itemData[i]).find("img");
127 if(!items[itemName]) { items[itemName]=[{name:itemName,img:itemPic.attr("src")}]; }
128 else { items[itemName].push({name:itemName,img:itemPic.attr("src")});}
129 }
130 for(var item in items) { shopItemSummary+="<div class='shop-overview-item'><img src='"+items[item][0].img+"' width='18px'> ("+items[item].length+"x) <span style='color:#DDD;'>"+items[item][0].name+"</span></div>"; }
131 $("#store-overview-"+this.shopId+" .shop-overview").html("<hr>"+shopItemSummary);
132 });
133 }
134 window.FLAG_LOADSHOPS=false;
135 clearInterval(shopsLoaded);
136 }
137 }, 500);
138}
139
140function keepPunching() {
141 //for a more CircleMUD feel
142 if(AUTO_SWING && player.health>AUTO_FLEE) {
143 if((loc.type==="in a fight!" || loc.type==="in combat!") && window.urlParams.type==="attack" && player.health>AUTO_FLEE) {
144 if(window.urlParams.hand==="RightHand") window.combatAttackWithRightHand(); else window.combatAttackWithLeftHand();
145 combatMessage("Attacking with "+window.urlParams.hand,"AUTO-SWING");
146 }
147 }
148 //if(AUTO_FLEE>0) {
149 // if(loc.type==="in combat!" && player.health<=AUTO_FLEE) {
150 // combatMessage("Your health is below "+AUTO_FLEE+"%, trying to gtfo!","AUTO-FLEE");
151 // window.combatEscape();
152 //}
153 //}
154 if(AUTO_REST && loc.rest===true && player.health<100) window.doRest();
155 if(AUTO_LEAVE_FORGET && loc.type==="combat site") {
156 if(AUTO_GOLD) {
157 setTimeout(function() {
158 if(window.gotGold===true) {
159 $('a[onclick^="leaveAndForgetCombatSite"]').click();
160 } else {
161 location.reload();//we didn't get gold, reload and try again.
162 }
163 }, 7000); //reload aftera wait to make sure we got gold
164 } else {
165 $('a[onclick^="leaveAndForgetCombatSite"]').click();
166 }
167 }
168}
169//get hotkeys from buttons and put 'em on the map overlay
170function putHotkeysOnMap() {
171 var i=0,keys={},otherExits={},mapOverlayDirs=[],
172 directions=$('body').find('a[onclick^="doGoto"]');
173 for(i=0;i<directions.length;i++) {
174 var shortcut=$(directions[i]).find(".shortcut-key").text(),
175 path=$(directions[i]).attr("onclick").split(",")[1].replace(")","");
176 if(shortcut) { //get all the dirs
177 keys[parseInt(path)]=shortcut;
178 otherExits[parseInt(path)]=" <a onclick='"+$(directions[i]).attr("onclick")+"'>"+directions[i].text.replace("(","<span style='color:white;'>(").replace(")",")</span> ").replace("Head towards ","").replace("Go to ","")+"</a> ";
179 } else {
180 mapOverlayDirs.push({path:parseInt(path),dir:directions[i]});
181 }
182 }
183 for(i=0;i<mapOverlayDirs.length;i++) { //update dirs on map overlay
184 $(mapOverlayDirs[i].dir).text((keys[mapOverlayDirs[i].path]||"")+" "+$(mapOverlayDirs[i].dir).text());
185 delete otherExits[mapOverlayDirs[i].path]; //exit is on overlay, delete from otherExits
186 }
187 if(!$.isEmptyObject(otherExits)){
188 $(".main-banner").append("<div id='other-exits'>"+((mapOverlayDirs.length>0)?"Other exits:":"Exits:")+"</div>");
189 for(var exit in otherExits) $("#other-exits").append(otherExits[exit]);
190 }
191}
192
193function getLocalGold() {
194 var localCharsURL="/locationcharacterlist.jsp";
195
196 $.ajaxQueue({
197 url: localCharsURL,
198 }).done(function(data) {
199 var goldLinks = $(data).find("[onclick*='Doge']:not(:contains(' 0 gold'))");
200 var dogeCollected=0,confirmedDoge=0,foundDoge;
201 var battleGoldLink=$(".main-item-container").find('a[onclick*="collectDogecoin"]');
202 if(goldLinks.length===0)return showMessage("No gold laying around.","gray");
203 showMessage("<img src='"+window.IMG_GOLDCOIN+"' class='coin-tiny'> <span id='picking-gold-status'>Found gold! Picking it up.</span>","yellow");
204 goldLinks.each(function(index) {
205 var getGoldURL=$(this).attr("onclick").split('"')[1]+"&ajax=true&v="+window.verifyCode;
206 var foundDoge=parseInt($(this).text().split(" ")[1]);
207 dogeCollected+=foundDoge;
208 $.ajaxQueue({url: getGoldURL,doge:this,foundDoge:foundDoge}).done(function(data) {
209 confirmedDoge+=parseInt($(this.doge).text().split(" ")[1]);
210 $(this.doge).html("Collected "+ foundDoge+" gold!");
211 $(battleGoldLink).text("Collected "+ foundDoge+" gold!").css({"color":"yellow"});
212 $("#picking-gold-status").text((confirmedDoge!==dogeCollected)?"Picking up "+confirmedDoge+" of "+dogeCollected+" gold found!":"Picked up "+dogeCollected+" gold!");
213 console.info("Confirmed "+confirmedDoge+" of "+dogeCollected+" doge!");
214 window.gotGold=true;
215 });
216 });
217 //inform the user of our sweet gains!
218 $("#mainGoldIndicator").text(Number(player.gold+dogeCollected).toLocaleString('en'));
219 pulse("#mainGoldIndicator","yellow");
220 });
221}
222
223function getLocalStuff() {
224 var localItemsList,localItemsURL="/ajax_moveitems.jsp?preset=location";
225 if($("#local-item-summary-container").length===0) $("#buttonbar-main").first().append("<div id='local-item-summary-container'><div id='local-item-summary-container'><h4 style='margin-top:20px;'>Items in area: <div id='reload-local-items-container'><a id='reload-inline-items'><img src='javascript/images/wait.gif'></a></div></h4><div class='blue-box-full-top'></div><div id='local-item-summary' class='div-table'><div><br/><br/><center><img src='javascript/images/wait.gif'></center><br/><br/></div></div><div class='blue-box-full-bottom'></div></div></div>"); //add summary box if not exists
226 $("#reload-inline-items").html("<img src='javascript/images/wait.gif'>");
227 window.localItems={};//clear the obj
228 $.ajax({ url: localItemsURL, type: "GET",
229 success: function(data) {
230 var itemLines="",itemSubLines="",localItemSummary="",
231 locationName=$(data).find(".header-cell:nth-child(2) h5").text(),
232 localItemsList=$(data).find("#right a.clue"),
233 pickupLinks=$(data).find("#right a.move-right"),
234 items=localItemsList.map(function(index) {
235 var itemClass=$(localItemsList[index]).attr("class"),
236 rarity=itemClass.replace("clue","").replace("item-","").replace(" ",""),
237 viewLink=$(localItemsList[index]).attr("rel"),
238 item={id:viewLink.split("=")[1],
239 name:$(localItemsList[index]).text(),
240 image:$(localItemsList[index]).find("img").attr("src"),
241 viewLink:viewLink,
242 pickupLink:$(pickupLinks[index]).attr("onclick"),
243 element:$(pickupLinks[index]),
244 updateLocalCount:function(count) { $(".cell[item-name='"+this.name.encode()+"']:eq(0)").parent().find(".cell:eq(1) span").text(count);},
245 class:itemClass,
246 rarity:(rarity==="")?rarity="common":rarity=rarity,
247 stats:{},
248 statLine:"",
249 delete:function() { return delete window.localItems[this.name][this.id]; },
250 pickup:function(elem,remElem,countElem,last) {
251 $(elem).html("<img src='/javascript/images/wait.gif'>");
252 $.ajaxQueue({
253 item:this.id,
254 name:this.name,
255 elem:elem, //element to update
256 remElem:remElem, //element to remove on complete
257 countElem:countElem, //to update the visible item count
258 url: "/ServletCharacterControl?type=moveItem&itemId="+this.id+"&destinationKey=Character_"+window.characterId+"&v="+window.verifyCode+"&ajax=true&v="+window.verifyCode+"&_="+window.clientTime,
259 }).done(function(data) {
260 var resultMessage=$(data)[2]||null;
261 if(resultMessage) {
262 showMessage(resultMessage.innerText.split("', '")[1].replace("');",""),"orange");
263 } else {
264 var remaining = Object.keys(window.localItems[this.name]).length-1;
265 window.localItems[this.name][this.item].updateLocalCount(remaining);
266 window.localItems[this.name][this.item].delete();
267 if(this.remElem && last) {
268 removeElement($(this.remElem));
269 getLocalStuff();
270 }
271 }
272 });
273 }
274 };
275 if(!window.localItems[item.name]) window.localItems[item.name]={}; //create item
276 window.localItems[item.name][item.id]=item;
277 return item;
278 });
279
280 //item overview list (one row per item type)
281 for(var item in window.localItems) {//summary row for display on under main-dynamic-content-box
282 var firstItem=window.localItems[item][Object.keys(window.localItems[item])[0]]; //first item in obj
283 localItemSummary+=
284 "<div class='row'>"+
285 "<div class='cell localitem-summary-image'><img src='"+firstItem.image+ "'></div>"+
286 "<div class='cell localitem-summary-count'>(x <span>"+Object.keys(window.localItems[item]).length+"</span>) <img src='"+window.IMG_ARROW+"' style='width:11px;'> </div>"+
287 "<div class='cell localitem-summary-name show-item-sublist'><div class='main-item-name'><a onclick=''>"+firstItem.name+"</a></div></div>"+
288 "<div class='cell localitem-summary-view show-item-sublist' item-name='"+firstItem.name.encode()+"'><a onclick=''>(View all)</a></div>"+
289 "<div class='cell localitem-summary-take' item-name='"+firstItem.name.encode()+"'><a onclick=''>(Take all)</a></div>"+
290 "</div>";
291 }
292 //display items in area summary when user enters
293 $("#local-item-summary").html(localItemSummary);
294 $("#local-item-summary").css({"background-size":"100% "+((Object.keys(window.localItems).length*28)+100)+"px"});
295 $("#reload-inline-items").bind('click',function(){getLocalStuff();});
296 $('.show-item-sublist').bind('click',function(){ //bind the actions
297 var itemName=$(this).attr('item-name').decode(),firstItem=window.localItems[itemName][Object.keys(window.localItems[itemName])[0]], //first item in obj
298 itemSublist="<div style='font-size:20px;'><img src='"+firstItem.image+ "'> <span style='color:#DDD;'>x"+Object.keys(window.localItems[firstItem.name]).length+"</span> <span>"+firstItem.name+":</span><span style='float:right;font-size:27px;'><a class='close-item-sublist' onclick=''>X</a></span></div><hr>";
299 $(".itemSublist").remove();//remove all other item sublists
300 for(var item in window.localItems[firstItem.name]) { //item sublist popup
301 var itemData,subItem=window.localItems[firstItem.name][item];
302 itemSublist+="<div class='row'>"+
303 "<div class='cell "+subItem.class+" localitem-popup-image'><img src='"+subItem.image+ "'> </div>"+
304 "<div class='cell'><a class='"+subItem.class+" localitem-popup-name' rel='"+subItem.viewLink+"'>"+subItem.name+"</a><br/>"+
305 "<div class='inline-stats' id='inline-stats-"+item+"'>Loading item stats...<br/><img src='/javascript/images/wait.gif'></div></div>"+
306 "<div class='cell localitem-summary-view' style='vertical-align:middle;'> <a class='take-item' itemName='"+encodeURIComponent(subItem.name)+"' itemId='"+item+"'>(Take)</a></div></div>";
307 }
308 var itemSublistPopup='<div class="itemSublist table cluetip ui-widget ui-widget-content ui-cluetip clue-right-rounded cluetip-rounded ui-corner-all" style="position: absolute; margin-bottom:20px; width: 450px; left: '+($(this).position().left)+'px; z-index: 2000000; top: '+($(this).position().top+5)+'px; box-shadow: rgba(0, 0, 0, 0.498039) 1px 1px 6px;"><div class="cluetip-outer" style="position: relative; z-index: 2000000; overflow: visible; height: auto;"><div class="cluetip-inner ui-widget-content ui-cluetip-content">'+itemSublist+'</div></div><div class="cluetip-extra"></div><div class="cluetip-arrows ui-state-default" style="z-index: 2000001; top: -4px; display: block;"></div></div>';
309 $("body").append(itemSublistPopup);
310 $('.close-item-sublist').bind('click',function(){ $(".itemSublist").remove(); }); //close item sublist button closes all item sublists
311 $('.take-item').bind('click',function(){
312 window.localItems[$(this).attr("itemName").decode()][$(this).attr("itemId")].pickup(this,$(this).parent().parent(),null,true);
313 });
314 for(var itemId in window.localItems[firstItem.name]) ajaxItemStats(firstItem.name,itemId); //load stats in popup
315 });
316 $('.localitem-summary-take').bind('click',function(){ //take all
317 var z=Object.keys(window.localItems[$(this).attr('item-name').decode()]).length;
318 var itemName=$(this).attr('item-name').decode();
319 var itemCountDisplay=$(".cell[item-name='"+itemName.encode()+"']:eq(0)").parent().find(".cell:eq(1) span");
320 while(z--) {
321 var itemId=Object.keys(window.localItems[$(this).attr('item-name').decode()])[z];
322 window.localItems[itemName][itemId].pickup(this,this,itemCountDisplay,(z===0)?true:false);
323 }
324 });
325 $("#reload-inline-items").html("↻");
326 }
327 });
328}
329
330function ajaxItemStats(itemName,itemId) {
331 $.ajax({itemName:itemName,
332 itemId:itemId,
333 url: window.localItems[itemName][itemId].viewLink, type: "GET",
334 success: function(data) {
335 var itemStatLines=$(data).find("div:not(#item-comparisons) .item-popup-field");
336 for(var t=0;t<itemStatLines.length && $(itemStatLines[t]).text().indexOf(":")!=-1;t++) {
337 var att=$(itemStatLines[t]).text().split(":");
338 if(att[1]) window.localItems[this.itemName][this.itemId].stats[formatItemStats(att[0])]=att[1].substring(1).replace(/(\r\n|\n|\r)/gm,"");
339 }
340 var itemStats=window.localItems[this.itemName][this.itemId].stats;
341 $("#inline-stats-"+this.itemId).html("<div class='inline-stats' id='inline-stats-"+this.itemId+"'></div>");
342 for(var i=0;i<Object.keys(itemStats).length;i++) {
343 var statName=Object.keys(window.localItems[this.itemName][this.itemId].stats)[i];
344 var statValue=window.localItems[this.itemName][this.itemId].stats[statName];
345 $("#inline-stats-"+this.itemId).append("<div style='margin-left:10px;float:left;'><span style='color:orange;'>"+statName+":</span> <span style='color:white;'>"+statValue+"</span></div>");
346 }
347 return true;
348 },
349 error: function(e) {
350 return false;
351 }
352 });
353 return null;
354}
355function formatItemStats(thang) {
356 return thang.replace(" - ","")
357 .replace("Dexterity penalty","Dex")
358 .replace("Strength requirement","Str")
359 .replace("Weapon damage","Dmg")
360 .replace("Critical chance","Crit")
361 .replace("Critical hit multiplier","Crit mult")
362 .replace("Damage Type","Dmg type")
363 .replace("Block chance","Blk")
364 .replace("Damage reduction","Dmg red")
365 .replace("Block bludgeoning","Blk bldg")
366 .replace("Block piercing","Blk prc")
367 .replace("Block slashing","Blk slsh")
368 .replace("Weight","Wt")
369 .replace("Space","Spc")
370 .replace("Durability","Dur");
371}
372//get location data
373function getLocation() {
374 var loc={name:$(".header-location").text()};
375 if(loc.name.indexOf("Combat site:")!==-1) { loc.type=($(".character-display-box").length>1)?"in combat!":"combat site"; } //if we're in a combat site, are we in combat or not?
376 else if(loc.name.indexOf("Camp:")!==-1) { loc.type="camp"; } //if we ain't fighting, are are we in a camp?
377 else { loc.type=(window.biome)?window.biome.toLowerCase():"in a fight!"; } //if all else fails, i guess we're outside
378 loc.campable=($("a[onclick^=createCampsite]").length>0)?true:false;
379 loc.rest=($("a[onclick^=doRest]").length>0)?true:false;
380 return loc;
381}
382
383//get player stats and details
384function getPlayerStats() {
385 var hp=$("#hitpointsBar").text().split("/");
386 return { charachterId:window.characterId,
387 verifyCode:window.verifyCode,
388 name:$("a[rel^=#profile]:eq(0)").text(),
389 maxhp:parseInt(hp[1]),
390 hp:parseInt(hp[0]),
391 health:+((hp[0]/hp[1])*100).toFixed(2),
392 gold:parseInt($("#mainGoldIndicator").text().replace(/,/g, ""))};
393}
394
395//display stats
396function statDisplay() {
397 $.ajaxQueue({
398 url: $(".character-display-box:eq(0)").children().first().attr("rel"),
399 }).done(function(data) {
400 var stats = $(data).find('.main-item-subnote');
401 $(".character-display-box:eq(0) > div:eq(1)").append("<div id='pro-stats' class='buff-pane'>"+
402 "<img src='"+window.IMG_STAT_SWORD+"'><span>"+$( stats[0] ).text().split(" ")[0]+"</span>"+//str
403 "<img src='"+window.IMG_STAT_SHIELD+"'><span>"+$( stats[1] ).text().split(" ")[0]+"</span>"+//def
404 "<img src='"+window.IMG_STAT_POTION+"'><span>"+$( stats[2] ).text().split(" ")[0]+"</span>"+//int
405 "</a></div>");
406 $('.header-stats a:nth-child(2)').children().html("Inv<span style=\"color:#AAA;margin-left:4px;margin-right:-5px;\">("+$( stats[3] ).text().split(" ")[0]+")</span> ");//carry
407
408 });
409}
410//utility stuff
411function getThisPartyStarted() {
412 //flags
413 window.FLAG_LOADSHOPS=false;
414 window.FLAG_LOADSHOPITEMS=false;
415 window.gotGold=false;
416 window.localItems={};
417 window.urlParams=getUrlParams();
418 //init stuff
419 updateCSS();
420 statDisplay();
421 getLocalGold();
422 //getLocalStuff();
423 //mutation observer watches the dom
424 MutationObserver = window.MutationObserver || window.WebKitMutationObserver;
425 //setting up observers
426 observe(["#instanceRespawnWarning",".popup_confirm_yes","#popups","#page-popup-root"],{childList:true,characterData:true,attributes:true,subtree:true});
427 //finish up when page ready
428 $(document).ready(function () {
429 player=getPlayerStats();
430 loc=getLocation();
431 updateLayouts();
432 putHotkeysOnMap();
433 keepPunching();
434 });
435 return true;
436}
437
438//do stuff when dom changes!
439function mutationHandler (mutationRecords) {
440 mutationRecords.forEach ( function (mutation) {
441 if (typeof mutation.removedNodes == "object") {
442 var removed = $(mutation.removedNodes);
443 var added = $(mutation.addedNodes);
444 if(AUTO_CONFIRM_POPUPS) $(added).find(".popup_confirm_yes").click();//auto-click confirm yes button
445 //instance countdown
446 var countDown=removed.text().split("arrive")[1];
447 if(countDown) {
448 var tm=countDown.split(" ");
449 if(tm[2]=="less")tm[2]="< 1";
450 tm[2].replace("seconds.","sec").replace("minutes.","min");
451 var header_location="<div class='header-location above-page-popup'><a onclick=''>"+loc.name+":</a> <span style='color:red;'>"+tm[2]+" "+tm[3]+"</span></div>";
452 $(".header-location").replaceWith(header_location);
453 }
454 //local merchants
455 // if($('.main-merchant-container').length===0 && added.html() && window.FLAG_LOADSHOPS===false) {
456 //loadLocalMerchantDetails();
457 //}
458 //store item details
459 // if($('.saleItem').length===0 && added.html() && window.FLAG_LOADSHOPITEMS===false) {
460 //loadShopItemDetails();
461 //}
462 }
463 });
464}
465function observe(els,config) {
466 window.myObserver = new MutationObserver (mutationHandler);
467 return els.forEach(function(el) { $(el).each ( function () { window.myObserver.observe (this, config); }); } );
468}
469function updateLayouts() {
470 //Class updates
471 $(".main-buttonbox").find("br").remove().appendTo("main-page-banner-image");
472 $(".main-button").removeClass("main-button").addClass("main-button-half").addClass("action-button");
473 //Add loc type to header
474 if(loc.type)$(".header-location").append("<span style='margin-left:12px;color:red;'>("+loc.type+")</span>");
475 //show 'em that pro is active!
476 if(!HIDE_VERSION)$(".header").append("<div id='initium-pro-version'><a href='https://github.com/hey-nails/InitiumPro' target='_blank'><img src='"+window.IMG_PRO+"'><span>v "+GM_info.script.version+"</span></a></div>");
477 //the candle
478 $(".header").append("<div id='light'><a onclick='$(\".banner-shadowbox\").toggleClass(\"torched\");'><img src='"+window.IMG_CANDLE+"'></a></div>");
479}
480function updateCSS() {
481 $("head").append("<style>"+
482 //style overrides
483 "#initium-pro-version { position:absolute;top:239px;margin-left:666px;z-index:99999999; } #initium-pro-version img { width:38%;filter:brightness(.75);transition:.5s ease; } #initium-pro-version img:hover { filter:brightness(1); } #initium-pro-version span { font-size:9px;margin-left:-21px;padding-top:5px; }"+
484 ".main-page p { margin-top:10px; }"+
485 "img { image-rendering: pixelated; }"+
486 "#instanceRespawnWarning { display:none!important; }"+
487 ".character-display-box { padding: 5px!important; }"+
488 ".main-buttonbox { text-align: center; }"+
489 ".main-button-icon { display: none; }"+
490 ".main-button-half.action-button { width: 33.3333%;float:left;font-size:15px; }"+
491 ".main-dynamic-content-box { padding-left:10px; }"+
492 "#instanceRespawnWarning { padding:10px; }"+
493 "#banner-loading-icon { opacity: 0.7; }"+
494 ".saleItem { margin-top:25px; }"+
495 ".saleItem .clue { margin-left:20px; }"+
496 ".saleItem .clue img { display:none; }"+
497 ".banner-shadowbox { transition:1s ease; }"+
498 "div[src]>div>br { display:none!important; }"+
499 //InitiumPro custom elements
500 ".hidden { display:none!important; }"+
501 ".torched { filter:brightness(2); }"+
502 "#light { transition:.2s ease;filter:brightness(.3);position:absolute;top:115px;margin-left:710px;z-index:99999999; }"+
503 "#light:hover { filter:brightness(1); }"+
504 "#toggle-sold-items { padding:15px 1px;float:right; }" +
505 ".merchant-inline-overview { padding:5px 0px 10px 5px; }"+
506 ".main-merchant-container .main-item { margin-top:25px; }"+
507 ".shop-overview { color:#999;margin-bottom:20px; }"+
508 ".shop-overview-item { float:left;font-size:13px;width:300px; }"+
509 "#other-exits { position:absolute;top:185px;left:15px;text-shadow:1px 1px 3px rgba(0, 0, 0, 1); }"+
510 ".inline-stats {font-size:11px;padding:0px 0px 5px 2px;width:300px; }"+
511 ".coin-tiny { width:12px; }"+
512 ".table { display:table; } .row { display:table-row; } .cell { display:table-cell; }"+
513 "#local-item-summary { margin: 0px 0px 0px 10px;background:url(/images/ui/large-popup-middle.jpg);background-position-y:-50px;overflow:hidden; }"+
514 "#local-item-summary .cell { vertical-align:middle; }"+
515 "#local-item-summary .cell:first-of-type { text-align:center;padding:0px 13px 0px 3px; }"+
516 "#local-item-summary .cell:first-of-type img { height:24px;width:24px;transition: .2s ease; }"+
517 "#local-item-summary .cell:first-of-type img:hover { filter:brightness(1.2); }"+
518 "#local-item-summary .cell:nth-of-type(2) { color:#ddd;padding-right:10px;text-align:right;}"+
519 "#local-item-summary .cell:nth-of-type(3) { padding-right:18px;color:#FFF; }"+
520 "#local-item-summary .cell:nth-of-type(4) a { padding-right:13px;color:#e69500; }"+
521 "#local-item-summary .cell:nth-of-type(5) a { color:#666666; }"+
522 ".blue-box-full-top { margin: 15px 0px 0px 10px;height:10px;background:url(/images/ui/large-popup-top.jpg);background-position-y:-5px; }"+
523 ".blue-box-full-bottom { margin: 0px 0px 20px 10px;height:10px;background:url(/images/ui/large-popup-bottom.jpg); background-position-y:-5px; }"+
524 "#reload-local-items-container { height:25px;float:right;padding-right:5px; }"+
525 ".shop-item-stats { transition:.2s ease;border:1px solid #404040;min-height:70px;padding:10px;margin:1px;width:700px;border-radius:10px;background:rgba(0,0,0,.2); }"+
526 ".shop-item-stats:hover { background:rgba(0,0,0,.15); }"+
527 ".shop-item-stats .cell { vertical-align:middle; }"+
528 ".shop-item-stats .cell > div { height:18px;margin-left:10px;float:left;color:white; }"+
529 ".shop-item-stats .cell > div > span:nth-child(odd) { color:orange; }"+
530 ".shop-item-stats .loading { width:100%;height:100%;vertical-align:middle;padding-top:27px;text-align:center; }"+
531 ".shop-item-stats .row > .cell:first-of-type) { width:80px;padding-right:5px; }"+
532 ".shop-item-stats .cell:not(.shop-buy-button) img { transition:.2s ease;filter:drop-shadow(4px 4px 6px rgba(0,0,0,.85));width:50px;padding:0px 10px; }"+
533 ".shop-item-stats .cell:not(.shop-buy-button) img:hover { filter:brightness(1.2) drop-shadow(1px 2px 8px rgba(0,0,0,1));transform: rotate(-5deg); }"+
534 ".shop-buy-button { transition: .2s ease;width:85px;text-align:center;border:1px solid rgba(173,173,173,0.1);border-radius:10px;background:rgba(255,255,255,0.1);}"+
535 ".shop-buy-button:hover { background:rgba(173,173,173,0.2); }"+
536 //stat box icons
537 "#pro-stats { width:160px; height:17px; font-size:10.5px; text-align:left; margin:-1px 0px 0px -5px; font-family:sans-serif; text-shadow:1px 1px 2px rgba(0, 0, 0, 1); } #pro-stats img { width:9px;height:9px;margin:3px 3px 0px 3px;vertical-align:sub; border:1px solid #AAAAAA;background:rgba(0,0,0,.5);border-radius:4px;padding:2px;/*-webkit-filter: drop-shadow(1px 1px 1px rgba(0, 0, 0, 0.2));filter: drop-shadow(1px 1px 1px rgba(0, 0, 0, 0.2));*/} #pro-stats span { padding:0px 4px 0px 0px; }"+
538 "</style>");
539 //base64 images
540 window.IMG_PRO="data:image/gif;base64,R0lGODlhZABDALMAAP+VRaqqp8zMzK2baezGXoB/eIx0M9/PpMmnR/9mAGaZmaCGQIXa+P///wAAAAAAACH5BAEAAA0ALAAAAABkAEMAAAT/sMlJq7046ybM/mAojqMQFGSqriwXCGgrz7T5xnSuh/a9/0BLrwALGn89U/HIlCWVuKa0FKgqfdMsKGnFar+Xq6lA9ILPrmvBUF6iwUrBeDBoR9/TuLwwINSheFpPAX1+doF5VS8mhYaAiEyDjQh/ZpBIiowDBwQECJQvlpc5XHycnggGiqKjTpknm52fC69ErTqljZ6qXba3NbW6CLS9Ar/AasILcqG+xy1isJ2oy2rGz9CLc9OzcszO2Cp6MJPD3mPX4eLa5Nyp7ODqVOeE7sSL8fI87PWy71Yw0ukTYcMboVOzMgV8JmAAC0kI/zUTeOsApXUAD/q7hy6cRT8k/7holMVrorqPIPf1iiWL4wmKregMWIBgmsMPuU55WnCgWLgBs2pOW6Yh17SdzNAlWMq0aVMAFZxKbYphqtMJHYYJtQlTglFu1UxanRp17FULAMwupSBgAc2jsmB+bUnPl1MAePOmXUvhrl68TKFW2Ps371LBXg1sPTpA4Fyk55w9vbCXb4OzgydfpnpBcwOUcD1dm9stskDPFConmIA5tebWfQNPAB26MWlzpssepsx5M1Pesn1b1p0AMe3aBVbagwcT9QTVrHu7Dg47+m4JBwxo387drapt/nh5yycc8XTL1RuoFpy+fAXFw7hrJ0NoDdBPwxSSd4+2N+yp7EkX2/91EyxgkwELIJggHQvcN5NEe3QlgXMSQDehgABe+FtnwWFlIH4IhrgTfsO4tJ+GVlVG3FMdDjici+Z5ZeAuIRrQCU0g1iKhdWqt5mKKHG5oAYUc4KiddzfiOICOH/hVGF4rAkZke0RyoJh8blEik09NtrjBWaoJiaKPQ3pZwQDaHaVVTQuUcSJxMWoAJlk/VmVmBQcYqF1N8OWn3Y5lEtilmMK1GGZgdwphYAEM6MldAQ0CCqcI/0ll3qFSbTETAWw4eqRbfkj6nF4i/DVYYWg9SeoGB/RhIzcKKjgjAqIOZEEANSEQQILbueUdqJ00ZqsIAcQVnwDZ+RrijHEN+0GDsZ4Um8o1QJEELFfOCnFAqzU11g0F1c7CLDe1HkPIffHdZwBM4Q4TWqjZNsASrG5JWC0B46pZbkz4bkcjoPfly9i+l/DJAAMK8AkCg++SO6zBCCscApZY3jQQnwooUIDEJChrsbOF4BftCjQ1GK+8n4B1AAtufTwssmhqF8DKLZgcbwQAOw==";
541 window.IMG_GOLDCOIN="data:image/gif;base64,R0lGODlhDgAQAPIAAAAAAJRjAMaUAP/OAP///wAAAAAAAAAAACH/C05FVFNDQVBFMi4wAwEAAAAh+QQJDAAFACH+FlJlc2l6ZWQgd2l0aCBlemdpZi5jb20ALAAAAAAOABAAAANEWFrQvsuRKUSLYI69K1AZp3VfQ2znEHRWiA7CSrrDGXNtWsMybIo83O91m+lsvZYrUJF5GLpA8sOg4SwYwPUCqTqoigQAIfkECQwABQAsAAAAAA4AEAAAAzdYqtCwkBEyxIsF0MEt1gMRVNcChiMJnWJXZlurmnHq0Zx8S7n9sr5VzRUBBUY7HGdWnDA/jkgCACH5BAUMAAEALAAAAAAOABAAAAIpjA9wuzCjWBsiygCpu9jVwWVf6G2XaEooeJas6pLay6xcUN64puPWUQAAIfkEBQwABQAsAgAAAAoAEAAAAy1YCqsOgxTBViRk0Ibzhh02AWA4lt15pRQqtutLxhIc1gzTaRXKP5Gfo9BzJAAAOw==";
542 window.IMG_STAT_SWORD="data:image/gif;base64,R0lGODlhEAAQAKIHAO2dBJmpsMPN0Uxjb/vJYuSvT2h9hv///yH5BAEAAAcALAAAAAAQABAAAAM2eLrMAC2qByUh80lFQNebUlChIhiGV57GMBYbOwhHgUUyHQboXPKtwK8n3BFXx+GgWELpSocEADs=";
543 window.IMG_STAT_SHIELD="data:image/gif;base64,R0lGODlhEAAQAKIEAJmZmf+NAP+fAP+PAP///wAAAAAAAAAAACH5BAEAAAQALAAAAAAQABAAAANDSLrQsNA5MWRTQOgdwtgPkW3aYJpBOJLnqZJlm2Iw1VY0fAuv3vKYVQx1yW1OnlCQNUgql6VOESIaOamRTOWJrU4XCQA7";
544 window.IMG_STAT_POTION="data:image/gif;base64,R0lGODlhEAAQAKIFALvEyAOW3Sq49imd1GN6hf///wAAAAAAACH5BAEAAAUALAAAAAAQABAAAAM6WKpATmDJ1V6csrqL2YOdIgwkGQwdKaxB22LDyroBLAt0PcVybve038wlxAV3Nx8SSFwOX7vSQFlIAAA7";
545 window.IMG_ARROW="data:image/gif;base64,R0lGODlhFAASAIABAPv+/v///yH5BAEAAAEALAAAAAAUABIAAAInjH+ggO2x1JtRTlfZbXnz6iEdlJXmiaYlqYLh6MGbfNGU+0ZhsjwFADs=";
546 window.IMG_CANDLE="data:image/gif;base64,R0lGODlhHgA8AKIHAEEyMdmgZu7Fl99xJopvMP///6wyMv///yH5BAEAAAcALAAAAAAeADwAAAP/eLq8Zi3KqR69OOvNu3cfBoXSM5KNiUbq6gzD6RqwvNK1HRqCEOsfns8y6/1cCtgAuVAyGYBVbxoI4EjTXhUAw/oGhV6h6uwYwWJy91MdBwQFdyBUFdTjePr7ji/o7W9xU398g2x7gWE9hImGHnWFi4eAcIoCjFmSj4iZlx9Ub5mYdZodkJylHKeUqRugrJ4er6SxZlqotRyzobmumachncCfv4jBxYB/oFVzk8tVyresm6HMzK0Y14DW2A1kCtrW1hnfB+Hi0BEE6wQAdettcehkW+wK7OtcA+1TAP7t+gDgI7BgIAEYAqe0W6jPYIR/+Pzp2zfQHwaJGDNm1KCxCCPGDh4lUkgAADs=";
547 window.IMG_BOXBUTTON="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAIAAAAB1CAYAAACGYelhAAAB20lEQVR4nO3UsW3CUBRG4Vu4dIUsKGKLBZAyQArGyAreALmlZgFKqtRMQJFBUqTIGE6RiALsSOg5MuacX/pKF0/3yBHOOeecc879sUVEnDQJzz03TNoyIlpNwrrnhkkzgOkwADgDgEsOYBE/Bz/LsuylKIpW92U+n1/J8/z18n4R8XRLAKfLqoqiaA+Hg+7M8Xi8slqtuv4KHwbwgAwAzgDgDABu9AC2261GtNlsrlRVZQAUBgBnAHAGAGcAcAYAZwBwBgBnAHAGAGcAcAYAZwBwBgBnAHAGAGcAcAYAZwBwBgBnAHAGAGcAcAYAZwBwBgBnAHAGAGcAcAYAZwBwBgBnAHAGAGcAcAYAZwBwBgBnAHAGAGcAcAYAZwBwBgBnAHAGAGcAcAYAZwBwBgBnAHAGAGcAcAYAZwBwBgBnAHAGAGcAcAYAZwBwBgBnAHAGAGcAcAYAZwBwBgBnAHAGAGcAcAYAZwBwBgBnAHAGAGcAcAYAZwBwBgBnAHAGAGcAcAYAN3oA+/0+SdM0SjB6AKm6HqA0BgBnAHAGADdEAG+/H5zNZrPP3W7XDq2uaw2sLMuvy/tFxPstAXRt2VGV7tO654ZJM4DpMAA4A4AzALh/CcA555xzzj3IvgGv+knN2J8eTwAAAABJRU5ErkJggg==";
548}
549String.prototype.decode=function() { return decodeURIComponent(this).replace("%27","'"); };
550String.prototype.encode=function() { return encodeURIComponent(this).replace(/'/g, "%27"); };
551function removeElement(el) {$(el).fadeOut(300, function() { $(this).remove(); });}
552function showMessage(msg,color) { $(".show-message").remove();$(".main-dynamic-content-box").first().append("<div class='show-message' style=\"color:"+(color||"white")+";padding-top:15px;\">"+msg+"</div>");}
553function combatMessage(msg,type) { return $(".main-page:eq(1) > p:eq(0)").append("<div style='margin:10px 0px;'><span style='color:orange;'>["+(type||"INFO")+"]</span> "+msg+"</div>"); }
554function pulse(elName,color) { $(elName).css({"background-color":color}).fadeTo(400, 0.5, function() { $(elName).fadeTo(300, 1).css({"background-color":""}); }); }
555function getUrlParams() { var params={};window.location.search.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(str,key,value) { params[key] = value; });return params;}