· 6 years ago · Nov 15, 2019, 03:14 AM
1// ==UserScript==
2// @name Alteracoes
3// @version 20190813.1
4// @author magno
5// @description Torn City Enhancer
6// @include http*://www.torn.com/*
7// @include http*://torn.com/*
8// @require https://ajax.googleapis.com/ajax/libs/jquery/3.4.0/jquery.min.js
9// @require https://gist.github.com/raw/2625891/waitForKeyElements.js
10// @exclude http://www.torn.com/js/channel/trampoline.html
11// @exclude http*://www.torn.com/js/chat/*
12// @exclude http*://www.torn.com/includes/*
13// @grant GM_getValue
14// @grant GM_setValue
15// @grant GM_log
16// @grant GM_xmlhttpRequest
17// @grant GM_openInTab
18// @grant GM_listValues
19// @grant GM_addStyle
20// @connect www.torntuga.com
21// @connect api.torn.com
22// @connect travelrun.torncentral.com
23// ==/UserScript==
24
25GM_setValue('alt_versao','20190813.1');
26
27//Summary:
28// 06/02/16: Changed employee last action in company employee list
29// 09/02/16: Fixes in employee last action (companies)
30// 14/02/16: Faster load of employee last action (companies)
31// 28/02/16: Fix in forum unread message notifications
32// 15/03/16: Added last action in faction member list
33// 19/03/16: Added option to hide missions link
34// 19/03/16: Added customizable options for personal stats
35// 19/03/16: Added option to hide crimes left for next merit
36// 02/04/16: Added link in sidebar for Russian Roulette
37// 10/05/16: Fix in Configurations layout
38// 11/05/16: Fixed option to hide images from map in the city
39// 12/05/16: Added a mailbox indicator while travelling
40// 22/05/16: Added money on hand while travelling
41// 01/06/16: Fixed city finds after layout change
42// 24/06/16: Fixed warbase settings
43// 08/07/16: Not a real update, just reorganizing stuff
44// 27/07/16: Added option to add Bounties to sidebar
45// 27/07/16: Extra Chain bar only shows up when chaining
46// 03/08/16: Added option to redirect to gym after Xanax/FHC taken
47// 08/09/16: Display personal stats abroad.
48// 08/09/16: Added link to Wheels in sidebar
49// 08/09/16: Added possibility to remove some crimes
50// 14/09/16: Fixed error in extra chain bar
51// 26/09/16: Fixed error in personal stats abroad
52// 13/10/16: Fixed redirection to gym after taking Xanax
53// 22/10/16: Fix in forum unread message notifications
54// 03/11/16: Changed data source of employee/member last action to API
55// 22/11/16: Added more stats to personal stats
56// 07/01/17: Added link to stockmarket in sidebar
57// 09/01/17: Added option to remove facebook stuff
58// 10/01/17: Highlight your name in chat windows
59// 11/01/17: Fix in chat highlight
60// 12/01/17: Fixed price information from TravelRun in Home and Travel Agency
61// 13/01/17: Improved layouts of some functionalities
62// 22/01/17: Show cut text in personal perks
63// 23/01/17: Improved layout of next crime merits in Home
64// 25/01/17: Added plushies price information in Home from TravelRun
65// 28/02/17: Adjusted to new home screen layout
66// 02/03/17: Some more fixes in new Home layout
67// 02/03/17: Remove table borders in Home and in profiles
68// 02/03/17: Added total money in own bazaar
69// 03/03/17: Fix in bazaar total money
70// 03/03/17: Add total items and worth in display
71// 03/03/17: Added Count of items in item page
72// 07/03/17: Quick Fix for Home Page not working
73// 12/03/17: Extra chain counter removed temporarily to adjust to new scripting rules
74// 21/03/17: Fix in bazaar total money
75// 21/03/17: Layout of script configuration adjusted to new Torn styles
76// 02/04/17: Fixed a conflict error with Tornstats script
77// 27/05/17: Added Total warbase count in faction
78// 27/05/17: Readded Extra Chain Bar now using API
79// 26/06/17: Removed Total Warbase count due to changes in warbase
80// 27/08/17: Fixed Time Format for time display
81// 31/08/17: Fixed Personal stats for new profile page
82// 31/10/17: Fixed bazaar total money
83// 02/11/17: Added Position Counter for other Companies
84// 10/11/17: Script fixed after sidebar layout changes
85// 01/12/17: Several fixes in the script
86// 14/12/17: Fixed Holder Mode
87// 14/12/17: Added 2 more links to remove in sidebar
88// 26/12/17: Fixed error in other company position counter
89// 17/01/18: Fix in chat highlight
90// 27/04/18: Fixed error in personal stats/employee last action
91// 05/06/18: Hide Icons functionality working again
92// 05/06/18: Added option to hide Fallen players from enemy factions
93// 28/06/18: Added option to hide new company and faction icons
94// 17/07/18: Fixed layout of links in sidebar
95// 24/07/18: New fix for layout of links in sidebar
96// 11/08/18: Added more stats to personal stats
97// 11/08/18: Added time when cooldown ends
98// 11/08/18: Added option to align Torn to left
99// 11/08/18: Stopped calling API everytime an employee is trained
100// 16/08/18: Changed Bookie Link
101// 18/08/18: Added more statistics to bookies
102// 31/10/18: Fixed OC Readiness indicator
103// 12/11/18: Added Chain Alert
104// 22/11/18: Fixed Employee Last Action due to API change
105// 05/12/18: Fixed Member Last Action
106// 13/12/18: Fixed error script stopping while travelling
107// 13/12/18: Fixed extra chain bar
108// 13/12/18: Fixed Sound Chain Alert
109// 11/02/19: Added search filter for userlist
110// 13/02/19: Fized Search Filter
111// 20/04/19: Fixed Personal stats in profile page
112// 29/04/19: Added Stock profit/loss amount
113// 06/05/19: Fixed home page not loading
114// 09/05/19: Fixed checkboxes in script configuration
115// 09/05/19: Highlight people abroad with a tag
116// 17/05/19: Fixed a bug in search filter
117// 25/06/19: Fixed missing icons when hide an icon is selected
118// 29/06/19: Fix in Stocks profit/loss amount
119// 20/07/19: Added Calculate Worth of Shares for Sale in Stock Market
120
121//TODO:
122updateScript();
123
124// dados de configuracao:
125var alt_versao = GM_getValue('alt_versao', null);
126var holderMode = GM_getValue('holderMode', null);
127var removerBounties = GM_getValue('removerBounties', null);
128var lastactionf = GM_getValue('lastaction', null);
129var resumoprecosb = GM_getValue('resprecos', null);
130var flowerdrugprice = GM_getValue('flowerdrugprice', null);
131var destacarJail = GM_getValue('destacarJail', null);
132var destacarHosp = GM_getValue('destacarHosp', null);
133var highlightOut = GM_getValue('highlightOut', null);
134var tagJail = GM_getValue('tagJail', null);
135var tagHosp = GM_getValue('tagHosp', null);
136var tagOut = GM_getValue('tagOut', null);
137var lraces = GM_getValue('lraces', null);
138var lstockmarket = GM_getValue('lstockmarket', null);
139var lpoker = GM_getValue('lpoker', null);
140var lbookies = GM_getValue('lbookies', null);
141var lrroulette = GM_getValue('lrroulette', null);
142var lwheels = GM_getValue('lwheels', null);
143var lstocks = GM_getValue('lstocks', null);
144var lnotepad = GM_getValue('lnotepad', null);
145var lbounties = GM_getValue('lbounties', null);
146var sfsstock = GM_getValue('sfsstock', null);
147var lactivo1 = GM_getValue('lactivo1', null);
148var lactivo2 = GM_getValue('lactivo2', null);
149var lactivo3 = GM_getValue('lactivo3', null);
150var lactivo4 = GM_getValue('lactivo4', null);
151var lactivo5 = GM_getValue('lactivo5', null);
152var nomeL1 = GM_getValue('nomeL1', null);
153var nomeL2 = GM_getValue('nomeL2', null);
154var nomeL3 = GM_getValue('nomeL3', null);
155var nomeL4 = GM_getValue('nomeL4', null);
156var nomeL5 = GM_getValue('nomeL5', null);
157var link1 = GM_getValue('link1', null);
158var link2 = GM_getValue('link2', null);
159var link3 = GM_getValue('link3', null);
160var link4 = GM_getValue('link4', null);
161var link5 = GM_getValue('link5', null);
162var useTravAg = GM_getValue('useTravAg', null);
163var lvault = GM_getValue('lvault', null);
164var hideOff = GM_getValue('hideOff', null);
165var hideTravel = GM_getValue('hideTravel', null);
166var hideHosped = GM_getValue('hideHosped', null);
167var hideFactionList = GM_getValue('hideFactionList', null);
168var chainAlert = GM_getValue('chainAlert', null);
169var chainAlert_time = GM_getValue('chainAlert_time', null);
170if(chainAlert_time == null){ chainAlert_time = '01:30'; }
171var percStats = GM_getValue('percStats', null);
172var effstats = GM_getValue('effstats', null);
173var crimeMerits = GM_getValue('crimeMerits', null);
174var respfaction = GM_getValue('respfaction', null);
175var hidemap = GM_getValue('hidemap', null);
176var flowerprices = GM_getValue('flowerprices', null);
177var plushieprices = GM_getValue('plushieprices', null);
178var sortitems = GM_getValue('sortitems', null);
179var extrachainbar = GM_getValue('extrachainbar', null);
180var personalstats = GM_getValue('personalstats', null);
181var removecrimes = GM_getValue('removecrimes', null);
182var redirectgym = GM_getValue('redirectgym', null);
183var removeborders = GM_getValue('removeborders', null);
184var positioncounter = GM_getValue('positioncounter', null);
185var expressbust = GM_getValue('expressbust', null);
186var alignleft = GM_getValue('alignleft', null);
187var factionless = GM_getValue('factionless', null);
188var companyless = GM_getValue('companyless', null);
189var highlightchat = GM_getValue('highlightchat', null);
190var highlightchat_color = GM_getValue('highlightchat_color', null);
191var osex = GM_getValue('osex', null);
192var odonator = GM_getValue('odonator', null);
193var omarried = GM_getValue('omarried', null);
194var ojob = GM_getValue('ojob', null);
195var ofaction = GM_getValue('ofaction', null);
196var obank = GM_getValue('obank', null);
197var ostock = GM_getValue('ostock', null);
198var oeduc = GM_getValue('oeduc', null);
199var obooster = GM_getValue('obooster', null);
200var omedical = GM_getValue('omedical', null);
201var odrug = GM_getValue('odrug', null);
202var olevel100 = GM_getValue('olevel100', null);
203var otrade = GM_getValue('otrade', null);
204var orace = GM_getValue('orace', null);
205var oitem = GM_getValue('oitem', null);
206var opoints = GM_getValue('opoints', null);
207var oloan = GM_getValue('oloan', null);
208var obounty = GM_getValue('obounty', null);
209var obookie = GM_getValue('obookie', null);
210var ohosp = GM_getValue('ohosp', null);
211var ojail = GM_getValue('ojail', null);
212var ollife = GM_getValue('ollife', null);
213var obook = GM_getValue('obook', null);
214var lastSub = GM_getValue('lastSub', null);
215var usageDay = GM_getValue('usageDay', null);
216var rhome = GM_getValue('rhome', null);
217var ritems = GM_getValue('ritems', null);
218var rcity = GM_getValue('rcity', null);
219var rjob = GM_getValue('rjob', null);
220var rgym = GM_getValue('rgym', null);
221var rproperties = GM_getValue('rproperties', null);
222var reducation = GM_getValue('reducation', null);
223var rcrimes = GM_getValue('rcrimes', null);
224var rmissions = GM_getValue('rmissions', null);
225var rnewspaper = GM_getValue('rnewspaper', null);
226var rjail = GM_getValue('rjail', null);
227var rhospital = GM_getValue('rhospital', null);
228var rcasino = GM_getValue('rcasino', null);
229var rforums = GM_getValue('rforums', null);
230var rhof = GM_getValue('rhof', null);
231var rfaction = GM_getValue('rfaction', null);
232var rcitizens = GM_getValue('rcitizens', null);
233var rrules = GM_getValue('rrules', null);
234var time12h = GM_getValue('time12h', null);
235var time24h = GM_getValue('time24h', null);
236var locale;
237var hour12;
238var travelrunprices = GM_getValue('travelrunprices', null);
239var api_key = GM_getValue('api_key', null);
240
241var psattackswon = GM_getValue('psattackswon', null);
242var psdefendswon = GM_getValue('psdefendswon', null);
243var psmoneymugged = GM_getValue('psmoneymugged', null);
244var pshighestlevel = GM_getValue('pshighestlevel', null);
245var pskillstreak = GM_getValue('pskillstreak', null);
246var pstotalrespect = GM_getValue('pstotalrespect', null);
247var pspeoplebusted = GM_getValue('pspeoplebusted', null);
248var pspeoplebailed = GM_getValue('pspeoplebailed', null);
249var pscriminaloffences = GM_getValue('pscriminaloffences', null);
250var pstimestravelled = GM_getValue('pstimestravelled', null);
251var psrevives = GM_getValue('psrevives', null);
252var psbloodwithdrawn = GM_getValue('psbloodwithdrawn', null);
253var psbooksread = GM_getValue('psbooksread', null);
254var psecstasy = GM_getValue('psecstasy', null);
255var psxanax = GM_getValue('psxanax', null);
256var psvicodin = GM_getValue('psvicodin', null);
257var pslsd = GM_getValue('pslsd', null);
258var psmissioncredits = GM_getValue('psmissioncredits', null);
259var psnetworth = GM_getValue('psnetworth', null);
260var pslogins = GM_getValue('pslogins', null);
261var psreffils = GM_getValue('psreffils', null);
262var psenhancers = GM_getValue('psenhancers', null);
263var psdonator = GM_getValue('psdonator', null);
264var pscandyeaten = GM_getValue('pscandyeaten', null);
265var psalcohol = GM_getValue('psalcohol', null);
266var psdrinks = GM_getValue('psdrinks', null);
267
268var crime2 = GM_getValue('crime2', null);
269var crime3 = GM_getValue('crime3', null);
270var crime4 = GM_getValue('crime4', null);
271var crime5 = GM_getValue('crime5', null);
272var crime6 = GM_getValue('crime6', null);
273var crime7 = GM_getValue('crime7', null);
274var crime8 = GM_getValue('crime8', null);
275var crime9 = GM_getValue('crime9', null);
276var crime10 = GM_getValue('crime10', null);
277var crime11 = GM_getValue('crime11', null);
278var crime12 = GM_getValue('crime12', null);
279var crime13 = GM_getValue('crime13', null);
280var crime14 = GM_getValue('crime14', null);
281var crime15 = GM_getValue('crime15', null);
282var crime16 = GM_getValue('crime16', null);
283var crime17 = GM_getValue('crime17', null);
284var crime18 = GM_getValue('crime18', null);
285
286//arrays para awards
287var attacksArray = new Array();
288attacksArray[0] = [5, 'Woodland Camo'];
289attacksArray[1] = [20, 'Desert Storm Camo'];
290attacksArray[2] = [50, 'Anti Social/Urban Camo'];
291attacksArray[3] = [100, 'Arctic Camo'];
292attacksArray[4] = [250, 'Happy Slapper/Fall Camo'];
293attacksArray[5] = [500, 'Scar Maker/Yellow Camo'];
294attacksArray[6] = [1000, 'Digital Camo'];
295attacksArray[7] = [2000, 'Red Camo'];
296attacksArray[8] = [2500, 'Going Postal'];
297attacksArray[9] = [3000, 'Blue Camo'];
298attacksArray[10] = [4000, 'Orange Camo'];
299attacksArray[11] = [5000, 'Pink Camo'];
300attacksArray[12] = [10000, 'Somebody Call 911'];
301
302var defendsArray = new Array();
303defendsArray[0] = [50, 'Bouncer'];
304defendsArray[1] = [250, 'BrickWall'];
305defendsArray[2] = [500, 'Turtle'];
306defendsArray[3] = [2500, 'Solid as a Rock'];
307defendsArray[4] = [10000, 'Fortress'];
308
309var ranAwayArray = new Array();
310ranAwayArray[0] = [50, 'Close Escape'];
311ranAwayArray[1] = [250, 'Blind Judgement'];
312ranAwayArray[2] = [1000, 'Overzealous'];
313
314var foesRanArray = new Array();
315foesRanArray[0] = [50, 'Ego Smashing'];
316foesRanArray[1] = [250, 'Underestimated'];
317foesRanArray[2] = [1000, 'Run Forest Run'];
318
319var killStreakArray = new Array();
320killStreakArray[0] = [25, 'Strike'];
321killStreakArray[1] = [50, 'Barrage'];
322killStreakArray[2] = [100, 'Skirmish'];
323killStreakArray[3] = [250, 'Blitzkrieg'];
324killStreakArray[4] = [500, 'Onslaught'];
325
326var criticalArray = new Array();
327criticalArray[0] = [500, 'Boom Headshot'];
328criticalArray[1] = [1000, '50 Cal'];
329criticalArray[2] = [2500, 'Pwned in the Face'];
330criticalArray[3] = [10000, 'Lee Harvey Oswald'];
331
332var medicalArray = new Array();
333medicalArray[0] = [500, 'Pin Cushion'];
334medicalArray[1] = [5000, 'Painkiller Abuse'];
335
336var bountiesArray = new Array();
337bountiesArray[0] = [25, 'Hired Gun'];
338bountiesArray[1] = [100, 'Bone Collector'];
339bountiesArray[2] = [250, 'Bounty Hunter'];
340bountiesArray[3] = [500, 'Fett'];
341
342var itemsFoundArray = new Array();
343itemsFoundArray[0] = [10, 'Watchful'];
344itemsFoundArray[1] = [50, 'Finders Keepers'];
345itemsFoundArray[2] = [100, 'Eagle Eye'];
346
347var travelArray = new Array();
348travelArray[0] = [25, 'Frequent Flyer'];
349travelArray[1] = [100, 'Jetlagged/Mile High Club'];
350travelArray[2] = [500, 'Mile High Club'];
351travelArray[3] = [1000, 'There and Back'];
352
353var arrayThefts = [[1000, 'Sneak Thief'], [2500, 'Prowler'], [5000, 'Safe Cracker'], [7500, 'Marauder'], [10000, 'Cat Burgler'], [12500, 'Pilferer'], [15000, 'Desperado'], [17500, 'Rustler'], [20000, 'Pick-Pocket'], [22500, 'Vandal'], [25000, 'Kleptomaniac']];
354var arrayVirus = [[500, 'Ub3rn00b Hacker'], [1000, 'N00b Hacker'], [1500, '1337n00b Hacker'],
355 [2000, 'Ph34r3dn00b Hacker'], [2500, 'Ph34r3d Hacker'], [3000, 'Ph343d1337 Hacker'],
356 [3500, 'Ub3rph34r3d Hacker'], [4000, 'Ub3r Hacker'], [4500, '1337 Hacker'],
357 [5000, 'Ub3r1337 Hacker'], [5500, 'Key Puncher'], [6000, 'Script Kid'], [7000, 'Geek Speak'], [8000, 'Techie'], [9000, 'Cyber Punk'], [10000, 'Programmer']];
358var arrayMurder = [[1000, 'Beginner Assassin'], [2000, 'Novice Assassin'], [3000, 'Competent Assassin'],
359 [4000, 'Elite Assassin'], [5000, 'Deadly Assassin'], [6000, 'Lethal Assassin'], [7000, 'Fatal Assassin'], [8000, 'Trigger Assassin'], [9000, 'Hit Man'], [10000, 'Executioner']];
360var arrayDrugs = [[250, 'Drug Pusher'], [500, 'Drug Runner'], [1000, 'Drug Dealer'],
361 [2000, 'Drug Lord'], [4000, 'Candy Man'], [6000, 'Connection'], [8000, 'King Pin'], [10000, 'Supplier']];
362var arrayFraud = [[300, 'Fake'], [600, 'Counterfeit'], [900, 'Pretender'], [1200, 'Clandestine'],
363 [1500, 'Imposter'], [2000, 'Pseudo'], [2500, 'Imitation'],
364 [3000, 'Simulated'], [3500, 'Hoax'], [4000, 'Faux'],
365 [5000, 'Poser'], [6000, 'Deception'], [7000, 'Phony'], [8000, 'Parody'], [9000, 'Travesty'], [10000, 'Pyro']];
366var arrayGTA = [[200, 'Gone In 300 Seconds'], [400, 'Gone In 240 Seconds'], [600, 'Gone In 180 Seconds'],
367 [800, 'Gone In 120 Seconds'], [1000, 'Gone In 60 Seconds'], [1200, 'Gone In 30 Seconds'],
368 [1500, 'Gone In 45 Seconds'], [2000, 'Gone In 15 Seconds'], [2500, 'Booster'],
369 [3000, 'Joy Rider'], [3500, 'Super Booster'], [4000, 'Master Carjacker'],
370 [4500, 'Slim Jim'], [5000, 'Novice Joy Rider'], [5500, 'Novice Slim Jim'],
371 [6000, 'Professional Joy Rider'], [6500, 'Professional Booster'], [7000, 'Professional Slim Jim'],
372 [8000, 'Master Joy Rider'], [9000, 'Master Booster'], [10000, 'Master Slim Jim']];
373
374var bustAwards = new Array();
375bustAwards[0] = [250, 'Novice Buster'];
376bustAwards[1] = [500, 'Intermediate Buster'];
377bustAwards[2] = [1000, 'Advanced Buster/Bar Breaker'];
378bustAwards[3] = [2000, 'Professional Buster'];
379bustAwards[4] = [2500, 'Aiding and Abetting'];
380bustAwards[5] = [4000, 'Expert Buster'];
381bustAwards[6] = [6000, 'Master Buster'];
382bustAwards[7] = [8000, 'Guru Buster'];
383bustAwards[8] = [10000, 'Don\'t drop It'];
384
385var crimesArray = [[10000, 'Society\'s Worst']];
386var revivesArray = [[500, 'Florence Nightingale'], [1000, 'Second Chance']];
387var refillsArray = [[250, 'Energize']];
388var bazaarArray = [[100, 'Middleman']];
389var auctionArray = [[100, 'Bargain Hunter']];
390var virusArray = [[100, 'Silicon Valley']];
391var dumpArray = [[1000, 'Optimist']];
392var trashArray = [[5000, 'Eco Friendly']];
393var bailArray = [[500, 'Freedom Isn\'t Free']];
394var bountiesMoneyArray = [[100000000, 'Dead or Alive']];
395var medicalsStolenArray = [[500, 'I\'m a Real Doctor']];
396
397var respectAwards = new Array();
398respectAwards[0] = [100, 'Recruit'];
399respectAwards[1] = [500, 'Associate'];
400respectAwards[2] = [1000, 'Picciotto'];
401respectAwards[3] = [2500, 'Soldier'];
402respectAwards[4] = [5000, 'Capo'];
403respectAwards[5] = [10000, 'Contabile'];
404respectAwards[6] = [25000, 'Consigliere'];
405
406var donatorAwards = new Array();
407donatorAwards[0] = [30, 'Citizenship'];
408donatorAwards[1] = [100, 'Devoted'];
409//donatorAwards[2] = [1000, 'Picciotto'];
410//donatorAwards[3] = [1000, 'Picciotto'];
411//donatorAwards[4] = [1000, 'Picciotto'];
412
413var donator = false;
414var no = document.getElementById('icon3');
415if(no != null){
416 donator = true;
417}else{
418 no = document.getElementById('icon4');
419 if(no != null)
420 donator = true;
421}
422// if no time selected => default 12h
423if(time12h != '1' && time24h != '1') locale = ['en-us'];
424if(time12h == '1') { locale = ['en-us']; hour12 = true; }
425if(time24h == '1') { locale = ['pt-PT']; hour12 = false; }
426
427var player = $("p[class^='menu-info-row']>a").text();
428if(player == ''){
429 player = GM_getValue('player', null);
430}else{
431 GM_setValue('player', player);
432}
433var idFacao = GM_getValue('idFacao', null);
434
435if(api_key == null){
436 api_key = get_api_key();
437 set_api_key(api_key);
438}
439
440if (document.location.href.match(/\/index\.php$/)) {
441 var link;
442 var ratio;
443 var jailed;
444 var speedNode = null; var speedValue = null; var speedNodeName = null;
445 var strengthNode = null; var strengthValue = null; var strengthNodeName = null;
446 var defenceNode = null; var defenceValue = null; var defenceNodeName = null;
447 var dexterityNode = null; var dexterityValue = null; var dexterityNodeName = null;
448 var totalNode = null; var totalValue = null; var totalNodeName = null;
449 var level; var faction; var nick; var id;
450 var strengthMod = null; var strengthSign = null; var effStrength = null;
451 var defMod = null; var defSign = null; var effDef = null;
452 var speedMod = null; var speedSign = null; var effSpeed = null;
453 var dexMod = null; var dexSign = null; var effDex = null;
454 var faction_out;
455
456 //determina id da Faction
457 if(! $("#skip-to-content").text().match(/Traveling|Mexico|Canada|Cayman|Kingdom|Switzerland|UAE|Dubai|South|Argentina|Hawaii|Japan|China/)){
458 if( $("div[id^=item]:has(>div.title-black:contains('Faction'))").find("a.href.t-blue").length > 0 )
459 idFacao = $("div[id^=item]:has(>div.title-black:contains('Faction'))").find("a.href.t-blue").attr('href').match(/(\d+)/)[0];
460
461 GM_setValue('idFacao', idFacao);
462
463 level = $('[class^="name"]:contains("Level")').next().text();
464 nick = $('[class^="menu-value"]').text();
465 id = $('[class^="menu-value"]').attr('href').match(/(\d+)/)[0];
466
467 faction_out = $("div[id^=item]:has(>div.title-black:contains('Faction Information'))").find("a").text();
468
469 //Only PT factions are relevant for stats
470 if(faction_out.match(/Family/)){ faction = 'Family'; }
471 if(faction_out.match(/Penguins/)){ faction = 'Penguins'; }
472 if(faction_out.match(/IronHearts/)){ faction = 'IronHearts'; }
473 if(faction_out.match(/BraveHearts/)){ faction = 'BraveHearts'; }
474 if(faction_out.match(/Calculated/)){ faction = 'Calculated'; }
475 if(faction_out.match(/Lifeline/)){ faction = 'Lifeline'; }
476
477 //get stats -- selector adapted to tornstats script
478 $("div[id^=item]:has(>div.title-black:contains('Battle Stats'))>div.bottom-round>div.cont-gray.battle,div[id=vinkuun-tornStats-BattleStats]:has(>div.title-black:contains('Battle Stats'))")
479 .find("ul.info-cont-wrap>li:lt(5)").each(function(){
480 var statNode = $(this).find("span.desc");
481 var statValue = statNode.text().replace(/[^0-9.]/g, '');
482 var statMod = $(this).find("span.mod").text().replace(/\s/g, '');
483 var statName = $(this).find("span.divider").text();
484 var statNameNode = $(this).find("span.divider");
485
486 if(statName.match(/Speed/)){
487 speedValue = 1 * statValue; speedNode = statNode; speedMod = statMod; speedNodeName = statNameNode; }
488 if(statName.match(/Strength/)){
489 strengthValue = 1 * statValue; strengthNode = statNode; strengthMod = statMod; strengthNodeName = statNameNode;}
490 if(statName.match(/Defense/)){
491 defenceValue = 1 * statValue; defenceNode = statNode; defMod = statMod; defenceNodeName = statNameNode;}
492 if(statName.match(/Dexterity/)){
493 dexterityValue = 1 * statValue; dexterityNode = statNode; dexMod = statMod; dexterityNodeName = statNameNode; }
494 if(statName.match(/Total/)){ totalValue = 1 * statValue; totalNode = statNode; totalNodeName = statNameNode;}
495
496 $(this).find("span.divider").attr('style','width: 153px;'); //153 -> 174 //193
497 statNode.css('width', '146px'); //136 -> 145 //136
498 });
499
500 //Adds stat percentage
501 if (speedValue && strengthValue && defenceValue && dexterityValue && percStats == '1') {
502 if (speedNode && strengthNode && defenceNode && dexterityNode) {
503 var novoNode = $("<span class='descCopiedStyleFrom_desc_becauseOfTornStatsSubmit' style='color: rgb(0, 0, 255); width:52px; padding-top: 5px; padding-right: 8px; padding-bottom: 5px; padding-left: 0px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); text-align: right; white-space: nowrap; overflow-x: hidden; overflow-y: hidden; text-overflow: ellipsis; vertical-align: top; display: inline-block; line-height: 14px;'></span>");
504 speedNode.css('width', '121px'); speedNodeName.css('width', '117px');
505 strengthNode.css('width', '121px'); strengthNodeName.css('width', '117px');
506 defenceNode.css('width', '121px'); defenceNodeName.css('width', '117px');
507 dexterityNode.css('width', '121px'); dexterityNodeName.css('width', '117px');
508 totalNode.css('width', '121px'); totalNodeName.css('width', '117px');
509
510 speedNode.after(novoNode.text(' (' + (Math.round(10000 * speedValue / totalValue) / 100) + '%)'));
511 strengthNode.after(novoNode.clone().text(' (' + (Math.round(10000 * strengthValue / totalValue) / 100) + '%)'));
512 defenceNode.after(novoNode.clone().text(' (' + (Math.round(10000 * defenceValue / totalValue) / 100) + '%)'));
513 dexterityNode.after(novoNode.clone().text(' (' + (Math.round(10000 * dexterityValue / totalValue) / 100) + '%)'));
514 }
515 //save stats in memory
516 GM_setValue('speedValue', speedValue.toString());
517 GM_setValue('strengthValue', strengthValue.toString());
518 GM_setValue('defenceValue', defenceValue.toString());
519 GM_setValue('dexterityValue', dexterityValue.toString());
520 }
521
522 speedValue = Math.round(speedValue);
523 strengthValue = Math.round(strengthValue);
524 defenceValue = Math.round(defenceValue);
525 dexterityValue = Math.round(dexterityValue);
526 totalValue = Math.round(totalValue);
527 var data = new Date();
528 var dia = data.getDate();
529 var mes = data.getMonth()+1;
530 var ano = data.getFullYear();
531 if(dia < 10) dia = '0' + dia;
532 if(mes < 10) mes = '0' + mes;
533 var mesSub = ano.toString() + mes.toString();
534 var today = mesSub.toString() + dia.toString();
535
536 //Statistical usage: id/nick/faction sent. For clarify in plain text. Just once a day is enough
537 if(usageDay != today){
538 requestPage2('http://www.torntuga.com/pt/stats/temp.php?id=' + id + '&nome=' + nick + '&faccao=' + faction_out + '&version=' + alt_versao);
539 GM_setValue('usageDay', today);
540 }
541
542 //Effective Battle Stats
543 if( effstats == '1'){
544 speedSign = speedMod.charAt(0).replace('−', '-');
545 speedMod = speedMod.match(/\d+/)[0] * 1;
546 effSpeed = eval(speedValue + speedSign + (speedValue * speedMod / 100)).toFixed(0);
547
548 strengthSign = strengthMod.charAt(0).replace('−', '-');
549 strengthMod = strengthMod.match(/\d+/)[0] * 1;
550 effStrength = eval(strengthValue + strengthSign + (strengthValue * strengthMod / 100)).toFixed(0);
551
552 defSign = defMod.charAt(0).replace('−', '-');
553 defMod = defMod.match(/\d+/)[0] * 1;
554 effDef = eval(defenceValue + defSign + (defenceValue * defMod / 100)).toFixed(0);
555
556 dexSign = dexMod.charAt(0).replace('−', '-');
557 dexMod = dexMod.match(/\d+/)[0] * 1;
558 effDex = eval(dexterityValue + dexSign + (dexterityValue * dexMod / 100)).toFixed(0);
559
560 var novoUL = $( '<ul class="info-cont-wrap"></ul>' );
561
562 novoUL.append( $('<li><span class="divider"><span>Strength:</span></span><span class="desc" style="color:#006600">' + fmtNumber(effStrength) + '</span></li>') );
563
564 novoUL.append( $('<li><span class="divider"><span>Defense:</span></span><span class="desc" style="color:#006600">' + fmtNumber(effDef) + '</span></li>') );
565
566 novoUL.append( $('<li><span class="divider"><span>Speed:</span></span><span class="desc" style="color:#006600">' + fmtNumber(effSpeed) + '</span></li>') );
567
568 novoUL.append( $('<li><span class="divider"><span>Dexterity:</span></span><span class="desc" style="color:#006600">' + fmtNumber(effDex) + '</span></li>') );
569
570 var effTotal = effStrength * 1 + effDef * 1 + effSpeed * 1 + effDex * 1;
571
572 novoUL.append( $('<li class="last"><span class="divider"><span>Total:</span></span><span class="desc">' + fmtNumber(effTotal.toFixed(0)) + '</span></li>') );
573
574 var novoDivGray = $( '<div class="cont-gray battle bottom-round">').append(novoUL);
575
576 var novoDivTopo = $('<div class="sortable-box t-blue-cont h"><div class="title title-black active top-round"><div class="arrow-wrap"><i class="accordion-header-arrow right"></i></div>Effective Battle Stats</div></div>').append(novoDivGray);
577
578 $("div[id^=item]:has(>div.title-black:contains('Battle Stats')), div[id=vinkuun-tornStats-BattleStats]:has(>div.title-black:contains('Battle Stats'))" ).after(novoDivTopo);
579 }
580
581 //Add flower prices from travelrun
582 if(flowerprices == '1'){
583 var novoDivTopo = $('<div class="sortable-box t-blue-cont h"></div>').append('<div class="title title-black active top-round"><div class="arrow-wrap"><i class="accordion-header-arrow right"></i></div>Flowers Information</div>');
584 var novoDivBase = $('<div class="bottom-round"></div>');
585 var novoDivGray = $('<div class="cont-gray bottom-round"></div>');
586 var novoUL = $('<ul class="info-cont-wrap"></ul>');
587
588 //bloco por flor
589 novoUL.append( flowerLine('Dahlia (Mexico)', 'f260'));
590 novoUL.append( flowerLine('Crocus (Canada)', 'f263'));
591 novoUL.append( flowerLine('Banana Orchid (Cayman Islands)', 'f617'));
592 novoUL.append( flowerLine('Orchid (Hawaii)', 'f264'));
593 novoUL.append( flowerLine('Heather (United Kingdom)', 'f267'));
594 novoUL.append( flowerLine('Ceibo Flower (Argentina)', 'f271'));
595 novoUL.append( flowerLine('Edelweiss (Switzerland)', 'f272'));
596 novoUL.append( flowerLine('Cherry Blossom (Japan)', 'f277'));
597 novoUL.append( flowerLine('Peony (China)', 'f276'));
598 novoUL.append( flowerLine('Tribulus Omanense (UAE)', 'f385'));
599 novoUL.append( flowerLine('African Violet (South Africa)', 'f282'));
600
601 novoUL.children(":last").addClass("last");
602
603 novoDivGray.append(novoUL);
604 novoDivBase.append(novoDivGray);
605 novoDivTopo.append(novoDivBase);
606 $("div[id^=item]:has(>div.title-black:contains('Property Information'))").before(novoDivTopo);
607
608 var doc;
609 GM_xmlhttpRequest({
610 method: "GET",
611 url: "http://travelrun.torncentral.com/flowers.php",
612 headers: {
613 'User-agent': 'Mozilla/4.0 (compatible) Greasemonkey/0.3',
614 'Accept': 'application/atom+xml,application/xml,text/xml',
615 },
616 synchronous: false,
617 onload: function(response) {
618 doc = document.implementation.createHTMLDocument("example");
619 doc.documentElement.innerHTML = response.responseText;
620
621 var arrayIDs = new Array();
622 arrayIDs = ['f260','f263', 'f617','f264','f267','f271','f272','f277','f276','f282', 'f385'];
623 for(var i in arrayIDs){
624 var elem = doc.getElementById(arrayIDs[i]);
625 if(elem != null){
626 var TDs = elem.getElementsByTagName('td');
627 var info = TDs[3].textContent + ' - ' + TDs[2].textContent;
628 var elemPage = document.getElementById(arrayIDs[i]);
629 if(elemPage != null){
630 elemPage.innerHTML = info;
631 }
632 }
633 }
634 }
635 });
636 }
637
638 //Add plushies prices from travelrun
639 if(plushieprices == '1'){
640 var novoDivTopo = $('<div class="sortable-box t-blue-cont h"></div>').append('<div class="title title-black active top-round"><div class="arrow-wrap"><i class="accordion-header-arrow right"></i></div>Plushies Information</div>');
641 var novoDivBase = $('<div class="bottom-round"></div>');
642 var novoDivGray = $('<div class="cont-gray bottom-round"></div>');
643 var novoUL = $('<ul class="info-cont-wrap"></ul>');
644
645 //bloco por peluche
646 novoUL.append( flowerLine('Jaguar Plushie (Mexico)', 'Jaguar'));
647 novoUL.append( flowerLine('Wolverine Plushie (Canada)', 'Wolverine'));
648 novoUL.append( flowerLine('Stingray Plushie (Cayman Islands)', 'Stingray'));
649 novoUL.append( flowerLine('Red Fox Plushie (United Kingdom)', 'Red'));
650 novoUL.append( flowerLine('Nessie Plushie (United Kingdom)', 'Nessie'));
651 novoUL.append( flowerLine('Monkey Plushie (Argentina)', 'Monkey'));
652 novoUL.append( flowerLine('Chamois Plushie (Switzerland)', 'Chamois'));
653 novoUL.append( flowerLine('Panda Plushie (China)', 'Panda'));
654 novoUL.append( flowerLine('Camel Plushie (UAE)', 'Camel'));
655 novoUL.append( flowerLine('Lion Plushie (South Africa)', 'Lion'));
656
657 novoUL.children(":last").addClass("last");
658
659 novoDivGray.append(novoUL);
660 novoDivTopo.append(novoDivGray);
661 $("div[id^=item]:has(>div.title-black:contains('Property Information'))").before(novoDivTopo);
662
663 var doc;
664 GM_xmlhttpRequest({
665 method: "GET",
666 url: "http://travelrun.torncentral.com/plushies.php",
667 headers: {
668 'User-agent': 'Mozilla/4.0 (compatible) Greasemonkey/0.3',
669 'Accept': 'application/atom+xml,application/xml,text/xml',
670 },
671 synchronous: false,
672 onload: function(response) {
673
674 var arrayIDs = new Array();
675 arrayIDs = ['Jaguar','Wolverine', 'Stingray','Red','Nessie','Monkey','Chamois','Panda','Camel','Lion'];
676
677 $(response.responseText).find("table tr").each(function(){
678 var plushieName = $(this).find("td:nth-child(1)").text();
679 var name = plushieName.slice(1, plushieName.indexOf(" "));
680 $("#" + name).html($(this).find("td:nth-child(4)").text() + " - " + $(this).find("td:nth-child(3)").text());
681 });
682 }
683 });
684 }
685
686 //Adiciona Awards de Crimes
687 if(crimeMerits == '1'){
688 $("div[id^=item]:has(>div.title-black:contains('Criminal Record'))" ).find('li').each(
689 function(item){
690 var arr = null;
691 var type = $(this).children(":first").text().trim();
692 var desc = $(this).children(":last").text();
693 var n = desc.replace(',','');
694
695 switch(type){
696 case 'Other':
697 type += ' (nerve: 2)';
698 break;
699 case 'Selling illegal products':
700 type = 'Illegal products (nerve: 3, 16)';
701 break;
702 case 'Theft':
703 type += ' (nerve: 4, 5, 6, 7, 15)';
704 arr = arrayThefts;
705 break;
706 case 'Computer crimes':
707 type += ' (nerve: 9, 18)';
708 arr = arrayVirus;
709 break;
710 case 'Murder':
711 type += ' (nerve: 10)';
712 arr = arrayMurder;
713 break;
714 case 'Drug deals':
715 type += ' (nerve: 8)';
716 arr = arrayDrugs;
717 break;
718 case 'Fraud crimes':
719 type = 'Fraud (nerve: 11, 13, 14, 17)';
720 arr = arrayFraud;
721 break;
722 case 'Auto theft':
723 type += ' (nerve: 12)';
724 arr = arrayGTA;
725 break;
726 }
727 $(this).children(":first").text(type);
728
729 if (arr != null) {
730 var mink = -1;
731 for (var k=0; k<arr.length; ++k) {
732 if ((mink == -1) && (arr[k][0] > n)) mink = k;
733 }
734 if (mink >= 0) {
735 //desc += ' (' + arr[mink][1] + ' -- <b>' + (arr[mink][0] - n) + '</b>)';
736 //desc = '<span style="float:left;width:30px;">'+desc+'</span><span style="font-style:italic;float:left;width:70px;">' + arr[mink][1] + '</span><span style="font-weight:bold;color:red;width:30px;float:right;text-align:right;">' + (arr[mink][0] - n) + '</span>';
737 desc = '<span style="float:right;width:60px;">'+desc+'</span><span style="font-style:italic;float:right;width:75px;text-align:left;display:block;overflow:hidden;">' + arr[mink][1] + '</span><span style="font-weight:bold;color:red;width:35px;float:right;text-align:left;">' + (arr[mink][0] - n) + '</span>';
738 $(this).children(":last").html(desc);
739 $(this).children(":last").attr('title', desc);
740 }else{
741 $(this).children(":last").css("color","green");
742 //$(this).children(":last").html("<span style='float:left;width:30px;'>"+desc+"</span><span style='font-style:italic;float:left;width:100px'>Good job!</span>");
743 $(this).children(":last").html("<span style='float:right;width:60px;'>"+desc+"</span><span style='font-style:italic;float:right;width:75px;text-align:left'>Good job!</span>");
744 }
745 }
746 }
747 );
748 }
749
750 //Fix text in personal perks
751 $.each( $( "#personal-perks" ).find( ".perks-desc" ), function(){
752 $(this).attr("title",$(this).html());
753 });
754
755 }
756}
757
758function flowerLine(name, id){
759 return '<li><span class="divider"><span>' + name + '</span></span><span id="' + id + '" class="desc" ></span></li>';
760}
761
762//link para refresh em viagem
763if (document.location.href.match(/\/index\.php$/) || document.location.href.match(/\/authenticate\.php$/) || document.location.href.match(/\/city\.php$/) || document.location.href.match(/torn.com\/$/) || document.location.href.match(/\/sidebar.php$/)) {
764
765 if( $("#skip-to-content").text().match(/Traveling/) || $("#skip-to-content").text().match(/Mexico|Canada|Cayman Islands|Hawaii|United Kingdom|Argentina|Switzerland|Japan|China|South Africa|Dubai/) ){
766 //Get number of mails:
767 var apiResponse = requestAPI('//api.torn.com/user/?selections=notifications,money&key=', api_key);
768
769 $("a.events").after( $('<a class="t-clear h c-pointer m-icon line-h24 right last" href="messages.php"><span role="button">Mailbox (' + apiResponse.notifications.messages + ')</span></a>') );
770
771 if( $("#skip-to-content").text().match(/Traveling/)){
772
773 var secondsLeft = $("#countrTravel").attr("data-to");
774 var data = new Date();
775 data.setSeconds(data.getSeconds() + secondsLeft * 1 );
776
777 $("#skip-to-content").after( ( $('<div class="left"> Arriving at ' + data.toLocaleTimeString(locale, {hour: '2-digit', minute:'2-digit'}) + '</div>').css('margin', '8px 3px') ));
778
779 $("#skip-to-content").after( $('<div class="left"> Money: $' + fmtNumber(Math.round(apiResponse.money_onhand)) + '</div>').css('margin', '8px 3px') );
780 }
781 }
782}
783
784//Stock Profit/Loss by malamen
785function calcProfit(){
786 $("ul.stock-cont li.item-wrap").each(function() {
787 var totalShares = parseInt($(this).find(".b-price-wrap.price-wrap div.first-row").html().replace(/[^0-9.]/g, ''));
788 var currentValue = parseFloat($(this).find(".b-price-wrap.price-wrap div.second-row span.prop-wrap").html().replace(/[^0-9.]/g, ''));
789 var boughtValue = parseFloat($(this).find(".c-price-wrap.price-wrap div.second-row span.prop-wrap").html().replace(/[^0-9.]/g, ''));
790 var result = parseInt(totalShares * currentValue - totalShares * boughtValue);
791 var color = result > 0 ? "#678c00" : result < 0 ? "#d83500" : "black";
792 var resultDiv = $("<div/>");
793 resultDiv.css("position", "absolute");
794 resultDiv.css("left", "330px");
795 resultDiv.css("top", "75px");
796 resultDiv.css("color", color);
797 resultDiv.html("$" + result.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g, "$1,"));
798 $(this).find("div.qualify-wrap").append(resultDiv);
799 });
800}
801
802// Add color indicator for shares with bonus
803if (document.location.href.match(/\/stockexchange\.php\?step\=portfolio/)){
804 $("div.qualify-wrap span:contains('earning')")
805 .css('background-color', 'lightgreen').css('color', 'black');
806
807//Stock Profit/Loss by malamen
808 calcProfit();
809 var observer = new MutationObserver(calcProfit);
810 var target = document.querySelector('div.content-wrapper')
811 observer.observe(target, { childList: true });
812}
813
814function calcSharesWorth(node){
815
816 var currentPrice = parseFloat(node.find("li.t-overflow:eq(4)").text().replace(/[^0-9.]/g, ''));
817 var sharesForSale = parseInt(node.find("li.t-overflow:eq(7)").text().replace(/[^0-9.]/g, ''));
818 var worthForSale = currentPrice * sharesForSale;
819
820 node.find("li.t-overflow:eq(7)")
821 .after('<li class="t-overflow"><div class="property left"><span>Worth:</span></div>$' + fmtNumber(parseInt(worthForSale)) + '</li>' );
822}
823
824//Calculate Worth of Shares for Sale
825if (document.location.href.match(/\/stockexchange\.php/)){
826 var observerStock = new MutationObserver(calcSharesWorth);
827 var targetStock = document.querySelector('div.stock-main-wrap')
828 observerStock.observe(targetStock, { childList: true });
829
830 waitForKeyElements("div.info-stock-wrap", calcSharesWorth);
831}
832
833// botão para obter preço resumo de shares
834if (document.location.href.match(/\/stockexchange\.php$/) && resumoprecosb == '1') {
835 var listaPrecos = new Array();
836
837 $("li.item").each(function(){
838 var stock = $(this).find("div.abbr-name.d-hide").text();
839 var preco = $(this).find("div.price").text().match(/(\$(\d+,)*(\d+)(\.(\d+))?)/)[0];
840 listaPrecos[stock] = preco;
841 });
842
843 var textoAlert;
844 for(var ii in listaPrecos){
845 if(textoAlert == null)
846 textoAlert = ii + '\t' + listaPrecos[ii];
847 else
848 textoAlert += '\n' + ii + '\t' + listaPrecos[ii];
849 }
850
851 var resumo = function(){
852 alert(textoAlert);
853 }
854
855 var newA = $('<a></a>').attr('class', 't-clear h c-pointer m-icon line-h24 right')
856 .attr('id', 'resumoprecos')
857 .attr('href', '#')
858 .html('<span class="icon-wrap"><i></i></span><span>Price Summary</span>')
859 .click(resumo);
860
861 $('a.back.in-laptop-page.t-clear.h.c-pointer.m-icon.line-h24.right').after(newA);
862}
863
864// Adds the hour when drug, bank or education finishes
865// Bug: Qd se abre preferences, script dá erro e não mostra hora de fim
866
867/*waitForKeyElements("div[class^='tooltip']", tooltip, false);
868
869function tooltip(jNode){
870}*/
871
872if(document.location.href.match(/\/item\.php\?temp=/)){
873 var timeleft = $("span.item-count-down").attr("data-time") * 1;
874 var now = new Date();
875 now.setSeconds(now.getSeconds() + timeleft);
876 if(timeleft >= 86400) // > 1 day
877 var endTime = now.toLocaleTimeString(locale, {hour12: hour12, hour: '2-digit', minute:'2-digit', day:'2-digit', month:'short'});
878 else
879 var endTime = now.toLocaleTimeString(locale, {hour12: hour12, hour: '2-digit', minute:'2-digit'});
880
881 var newSpan = "<span> Effect finishes at <b>" + endTime + "</b></span>";
882 $("span.item-count-down").parent().append(newSpan);
883}
884
885var no = document.getElementById('icon49');
886if(no == null)
887 no = document.getElementById('icon50');
888if(no == null)
889 no = document.getElementById('icon51');
890if(no == null)
891 no = document.getElementById('icon52');
892if(no == null)
893 no = document.getElementById('icon53');
894if(no != null && no.getAttribute('class').match(/iconShow/)){
895 var texto = no.getAttribute('title');
896 if(texto != null){
897 var tempo = texto.match(/(\d+)\:(\d+):(\d+)/);
898 var mins = tempo[1] * 1 * 60 + tempo[2] * 1 + 1;
899 var now = new Date();
900 now.setHours(now.getHours() + tempo[1] * 1, now.getMinutes() + tempo[2] * 1);
901 var novoText = texto + " - effect finishes at " + now.toLocaleTimeString(locale, {hour12: hour12, hour: '2-digit', minute:'2-digit'});
902 no.setAttribute('title', novoText);
903 }
904}
905
906//2? adiciona links para vault e airstrip caso tenha.
907//Adiciona outros links ao menu
908
909//get class from sidebar links
910if($('#nav-items').length){
911 var link_class = $('#nav-items').attr('class').split(" ")[0];
912 var row_class = $('#nav-items > div:first').attr('class');
913}
914
915var divProperties = document.getElementById('nav-properties');
916if(divProperties != null && lvault == '1'){
917 var link = 'properties.php\#\/p\=options\&tab\=vault';
918 addLink(divProperties, link, 'Vault', 1);
919}
920
921// Link para stocks e notepad quando se esta no hospital
922var divHospital = document.getElementById('nav-hospital');
923/*if(divHospital != null && divHospital.getElementsByTagName('a')[0].getAttribute('href') == '/'){
924 if(lnotepad == '1')
925 addLink(divHospital, 'notebook.php', 'Notepad', 1);
926 if(lstocks == '1')
927 addLink(divHospital, 'stockexchange.php\?step\=portfolio', 'Stocks', 1);
928}*/
929
930var divCity = document.getElementById('nav-city');
931if(divCity != null){
932 //link para races, viagens, bounties
933 if(lraces == '1')
934 addLink(divCity, 'racing.php', 'Races', 1);
935 if(lstockmarket == '1')
936 addLink(divCity, 'stockexchange.php', 'Stock Market', 1);
937 if(useTravAg == '1')
938 var travelAgLink = addLink(divCity, 'travelagency.php', 'Travel Agency', 1);
939 if(lbounties == '1')
940 addLink(divCity, 'bounties.php#!p=main', 'Bounties', 1);
941
942 //Shortcuts
943 for( var ii=1; ii <= 5; ii++){
944 var linkActivo = "lactivo" + ii;
945 var nomeLink = "nomeL" + ii;
946 var endereco = "link" + ii;
947
948 if( eval(linkActivo) == '1' && eval(nomeLink) != null && eval(endereco) != null ){
949 addLink(divCity, eval(endereco), eval(nomeLink), 1);
950 }
951 }
952}
953
954var divCasino = document.getElementById('nav-casino');
955if(divCasino != null){
956 if(lpoker == '1')
957 addLink(divCasino, 'pokerwindow.php', 'Poker', 1, '_blank');
958 if(lbookies == '1')
959 addLink(divCasino, 'bookies.php', 'Bookies', 1);
960 if(lrroulette == '1')
961 addLink(divCasino, 'loader.php?sid=russianRoulette', 'Russian Roulette', 1);
962 if(lwheels == '1')
963 addLink(divCasino, 'loader.php?sid=spinTheWheel', 'Spin the Wheel', 1);
964}
965
966//Remove Links from sidebar
967if(rhome == '1')
968 $('#nav-home').remove();
969
970if(ritems == '1')
971 $('#nav-items').remove();
972
973if(rcity == '1')
974 $('#nav-city').remove();
975
976if(rjob == '1')
977 $('#nav-job').remove();
978
979if(rgym == '1')
980 $('#nav-gym').remove();
981
982if(rproperties == '1')
983 $('#nav-properties').remove();
984
985if(reducation == '1')
986 $('#nav-education').remove();
987
988if(rcrimes == '1')
989 $('#nav-crimes').remove();
990
991if(rmissions == '1')
992 $('#nav-missions').remove();
993
994if(rnewspaper == '1')
995 $('#nav-newspaper').remove();
996
997if(rjail == '1')
998 $('#nav-jail').remove();
999
1000if(rhospital == '1')
1001 $('#nav-hospital').remove();
1002
1003if(rcasino == '1')
1004 $('#nav-casino').remove();
1005
1006if(rforums == '1')
1007 $('#nav-forums').remove();
1008
1009if(rhof == '1')
1010 $('#nav-hof').remove();
1011
1012if(rfaction == '1')
1013 $('#nav-faction').remove();
1014
1015if(rcitizens == '1')
1016 $('#nav-recruit_citizens').remove();
1017
1018if(rrules == '1'){
1019 $('#nav-rules').remove();
1020}
1021
1022
1023//Hide Icons from bar
1024function hide_icons(jNode){
1025 if(osex == '1'){
1026 jNode.find('#iconicon6').remove();
1027 jNode.find('#iconicon7').remove();
1028 }
1029 if( odonator == '1'){
1030 jNode.find('#iconicon3').remove();
1031 jNode.find('#iconicon4').remove();
1032 }
1033 if( omarried == '1'){
1034 jNode.find('#iconicon8').remove();
1035 }
1036 if( ojob == '1'){
1037 jNode.find('#iconicon21').remove();
1038 jNode.find('#iconicon22').remove();
1039 jNode.find('#iconicon23').remove();
1040 jNode.find('#iconicon24').remove();
1041 jNode.find('#iconicon25').remove();
1042 jNode.find('#iconicon26').remove();
1043 jNode.find('#iconicon27').remove();
1044 jNode.find('#iconicon73').remove();
1045 }
1046 if( ofaction == '1'){
1047 jNode.find('#iconicon9').remove();
1048 jNode.find('#iconicon74').remove();
1049 }
1050 if( oeduc == '1'){
1051 jNode.find('#iconicon19').remove();
1052 jNode.find('#iconicon20').remove();
1053 }
1054 if( obank == '1'){
1055 jNode.find('#iconicon29').remove();
1056 jNode.find('#iconicon30').remove();
1057 jNode.find('#iconicon31').remove();
1058 }
1059 if( oloan == '1'){
1060 jNode.find('#iconicon33').remove();
1061 }
1062 if( oitem == '1'){
1063 jNode.find('#iconicon34').remove();
1064 jNode.find('#iconicon35').remove();
1065 jNode.find('#iconicon36').remove();
1066 }
1067 if( opoints == '1'){
1068 jNode.find('#iconicon54').remove();
1069 }
1070 if( ostock == '1'){
1071 jNode.find('#iconicon38').remove();
1072 }
1073 if( otrade == '1'){
1074 jNode.find('#iconicon37').remove();
1075 }
1076 if( orace == '1'){
1077 jNode.find('#iconicon17').remove();
1078 jNode.find('#iconicon18').remove();
1079 }
1080 if( obounty == '1'){
1081 jNode.find('#iconicon13').remove();
1082 }
1083 if( obookie == '1'){
1084 jNode.find('#iconicon28').remove();
1085 }
1086 //Auction
1087 if( obooster == '1'){
1088 jNode.find('#iconicon39').remove();
1089 jNode.find('#iconicon40').remove();
1090 jNode.find('#iconicon41').remove();
1091 jNode.find('#iconicon42').remove();
1092 jNode.find('#iconicon43').remove();
1093 }
1094 if( omedical == '1'){
1095 jNode.find('#iconicon44').remove();
1096 jNode.find('#iconicon45').remove();
1097 jNode.find('#iconicon46').remove();
1098 jNode.find('#iconicon47').remove();
1099 jNode.find('#iconicon48').remove();
1100 }
1101 if( odrug == '1'){
1102 jNode.find('#iconicon49').remove();
1103 jNode.find('#iconicon50').remove();
1104 jNode.find('#iconicon51').remove();
1105 jNode.find('#iconicon52').remove();
1106 jNode.find('#iconicon53').remove();
1107 }
1108 if(olevel100 == '1'){
1109 jNode.find('#iconicon5').remove();
1110 }
1111 if( ohosp == '1'){
1112 jNode.find('#iconicon15').remove();
1113 }
1114 if( ojail == '1'){
1115 jNode.find('#iconicon16').remove();
1116 }
1117 if( ollife == '1'){
1118 jNode.find('#iconicon12').remove();
1119 }
1120 //Drug Addiction
1121 //Radiation Sickness
1122 if( obook == '1' ){
1123 jNode.find('#iconicon68').remove();
1124 }
1125}
1126
1127waitForKeyElements("#sidebarroot", hide_icons);
1128
1129//configuracao script
1130//Hide images from map for easier city finds by Infamouspt & ebcdic
1131if(document.location.href.match(/\/city.php$/)){
1132 settings();
1133
1134 if(hidemap == '1'){
1135 waitForKeyElements("div.leaflet-tile-pane", hide_map);
1136 }
1137}
1138
1139function hide_map(jNode){
1140 jNode.remove();
1141
1142 //Highlights City Finds with a 5px magenta coloured box and doubles the size of the item for better visibility. by Sanitarium (modified by Pidu)
1143 (function() {var css = "IMG[class=\"leaflet-marker-icon leaflet-zoom-hide leaflet-clickable\"][src*=\"items\/\"]{width:50px !important; height: 25px !important; -moz-border-radius:20px !important; -webkit-border-radius:20px !important; border-radius:20px !important; border: 2px solid magenta !important";
1144 if (typeof GM_addStyle != "undefined") {
1145 GM_addStyle(css);
1146 } else if (typeof PRO_addStyle != "undefined") {
1147 PRO_addStyle(css);
1148 } else if (typeof addStyle != "undefined") {
1149 addStyle(css);
1150 } else {
1151 var node = document.createElement("style");
1152 node.type = "text/css";
1153 node.appendChild(document.createTextNode(css));
1154 var heads = document.getElementsByTagName("head");
1155 if (heads.length > 0) {
1156 heads[0].appendChild(node);
1157 } else {
1158 // no head yet, stick it whereever
1159 document.documentElement.appendChild(node);
1160 }
1161 }
1162 })();
1163
1164 //city find hax by AquaRegia [1551111] modified by ebcdic
1165 data = $('.leaflet-marker-pane > img[src*="\/items"]').map(function() { src = this.src; return src.match(/\/items\/(\d+)/)[1]; }).get();
1166
1167 var items = '';
1168 if(data.length > 0){
1169 var itemList = requestAPI('//api.torn.com/torn/?selections=items&key=', api_key);
1170
1171 $.each(data, function(i, item){
1172 if(items != '') items += ', ';
1173 items += '<a style="margin-right:0px;display:inline" href="http://www.torn.com/imarket.php#/p=shop&step=shop';
1174 items += '&type=&searchname=' + encodeURIComponent(item) + '">';
1175 items += itemList["items"][item]["name"] +'</a>';
1176 });
1177 }
1178
1179 $("h4").append('<span style="font-size: 12px"> ' +
1180 ((data.length == 1) ? 'item' : 'items (' + data.length + ')') +
1181 ': ' + items + '</span>');
1182}
1183
1184function redirect_gym(jNode){
1185 if(jNode.parent().parent().text().match(/You pop the Xanax pill into your mouth and down a glass of water/) ||
1186 jNode.parent().parent().text().match(/and stay for a short while in the hotel./) ){
1187 document.location = '//' + document.domain + '\/gym.php';
1188 }
1189}
1190
1191function ordena_items(jNode){
1192
1193 if(sortitems == '1'){
1194 var items = jNode.children().get();
1195
1196 items.sort(function(a, b) {
1197 var keyA = $(a).find('.type').text();
1198 var keyB = $(b).find('.type').text();
1199
1200 if (keyA < keyB) return -1;
1201 if (keyA > keyB) return 1;
1202 return 0;
1203 });
1204
1205 $.each(items, function(i, li){
1206 jNode.find('ul[class="items-cont cont-gray bottom-round"]').append(li);
1207 jNode.append(li);
1208 });
1209 }
1210
1211 //add a color to main drugs and Boosters
1212 $('li[data-item="206"] div.title').css('background-color', '#eecc66'); //Xanax
1213 $('li[data-item="197"] div.title').css('background-color', '#eecc66'); //Ecstasy
1214 $('li[data-item="367"] div.title').css('background-color', '#eecc66'); //FHC
1215 $('li[data-item="366"] div.title').css('background-color', '#eecc66'); //Erotic DVD
1216
1217}
1218
1219function showItemsTotal(){
1220 if($("#totalItems").length == 0) {
1221 $(".items-name").append("<span id='totalItems'></span>");
1222 }
1223 var totalItems = 0;
1224 $("ul[aria-expanded=true] .qty.bold.d-hide").each(function() {
1225 if($( this ).html() != ""){
1226 totalItems += parseInt($( this ).html().replace('x', ''));
1227 }else{
1228 totalItems += 1;
1229 }
1230 });
1231 $("#totalItems").html(" | Total: "+totalItems);
1232}
1233
1234//colorir items
1235if(document.location.href.match(/\/item.php$/)){
1236 //Sort items by category
1237 waitForKeyElements ('ul#all-items[data-loaded="1"]', ordena_items);
1238
1239 //Count Total Items
1240 waitForKeyElements(".last-row.t-last-row.m-last-row", showItemsTotal);
1241
1242 //Redirect to gym after FHC or Xanax
1243 if(redirectgym == '1')
1244 waitForKeyElements ("a.close-act.t-blue", redirect_gym);
1245}
1246
1247// Add Personal stats in profile [adapted by Scripthen]
1248function handler_personal_stats(parsedRes){
1249 //if(this.readyState == 4 && this.status == 200) {
1250 // if(this.responseText != null){
1251 //var httpResp = this.responseText;
1252 //var personalstatsResp = JSON.parse(httpResp);
1253 var personalstatsResp = parsedRes;
1254
1255 if(personalstatsResp.error != null && ( personalstatsResp.error.code == '2' || personalstatsResp.error.code == '12' )){
1256 var new_api_key = get_api_key();
1257 set_api_key(new_api_key);
1258 var url = this.responseURL.split('&key=');
1259 var new_url = url[0] + '&key=';
1260 personalstatsResp = requestAPI(new_url, new_api_key);
1261 }
1262
1263 if(personalstatsResp.error != null){
1264 console.log('Error getting personal stats: ' + personalstatsResp.error.code);
1265 }
1266
1267 var personalStats = personalstatsResp["personalstats"];
1268 var userID = personalstatsResp["player_id"];
1269
1270 // Keys not valid if user has a zero value. We should really "try" all these up so we don't crash the script.
1271 if(personalStats["attackswon"] === undefined){STAT_ATTACKS_WON = 0;}else{STAT_ATTACKS_WON = personalStats["attackswon"];}
1272 if(personalStats["defendswon"] === undefined){STAT_DEFENDS_WON = 0;}else{STAT_DEFENDS_WON = personalStats["defendswon"];}
1273 if(personalStats["moneymugged"] === undefined){STAT_MONEY_MUGGED = 0;}else{STAT_MONEY_MUGGED = personalStats["moneymugged"];}
1274 if(personalStats["highestbeaten"] === undefined){STAT_HIGH_LEVEL = 0;}else{STAT_HIGH_LEVEL = personalStats["highestbeaten"];}
1275 if(personalStats["bestkillstreak"] === undefined){BEST_KILL_STREAK = 0;}else{BEST_KILL_STREAK = personalStats["bestkillstreak"];}
1276 if(personalStats["respectforfaction"] === undefined){STAT_RESPECT = 0;}else{STAT_RESPECT = personalStats["respectforfaction"];}
1277 if(personalStats["peoplebusted"] === undefined){STAT_PEOPLE_BUSTED = 0;}else{STAT_PEOPLE_BUSTED = personalStats["peoplebusted"];}
1278 if(personalStats["peoplebought"] === undefined){STAT_PEOPLE_BAILED = 0;}else{STAT_PEOPLE_BAILED = personalStats["peoplebought"];}
1279 if(personalStats["exttaken"] === undefined){STAT_ECSTASY_TAKEN = 0;}else{STAT_ECSTASY_TAKEN = personalStats["exttaken"];}
1280 if(personalStats["xantaken"] === undefined){STAT_XANAX_TAKEN = 0;}else{STAT_XANAX_TAKEN = personalStats["xantaken"];}
1281 if(personalStats["victaken"] === undefined){STAT_VICODIN_TAKEN = 0;}else{STAT_VICODIN_TAKEN = personalStats["victaken"];}
1282 if(personalStats["lsdtaken"] === undefined){STAT_LSD_TAKEN = 0;}else{STAT_LSD_TAKEN = personalStats["lsdtaken"];}
1283 if(personalStats["refills"] == undefined){STAT_REFILLS_TAKEN = 0;}else{STAT_REFILLS_TAKEN = personalStats["refills"];}// null or undefined, make sure.
1284 if(personalStats["statenhancersused"] === undefined){STAT_ENHANCER_TAKEN = 0;}else{STAT_ENHANCER_TAKEN = personalStats["statenhancersused"];}
1285 if(personalStats["daysbeendonator"] === undefined){DAYS_BEEN_DONATOR = 0;}else{DAYS_BEEN_DONATOR = personalStats["daysbeendonator"];}
1286 if(personalStats["missioncreditsearned"] == undefined){STAT_CREDITS_EARNED = 0;}else{STAT_CREDITS_EARNED = personalStats["missioncreditsearned"];}
1287 if(personalStats["logins"] == undefined){STAT_LOGINS = 0;}else{STAT_LOGINS = personalStats["logins"];}
1288 if(personalStats["traveltimes"] == undefined){STAT_TRAVEL_TIMES = 0;}else{STAT_TRAVEL_TIMES = personalStats["traveltimes"];}
1289 if(personalStats["revives"] == undefined){STAT_REVIVES = 0;}else{STAT_REVIVES = personalStats["revives"];}
1290 if(personalStats["bloodwithdrawn"] == undefined){STAT_bloodwithdrawn = 0;}else{STAT_bloodwithdrawn = personalStats["bloodwithdrawn"];}
1291 if(personalStats["booksread"] === undefined){STAT_BOOKS_READ = 0;}else{STAT_BOOKS_READ = personalStats["booksread"];}
1292 if(personalStats["candyused"] == undefined){STAT_CANDY_USED = 0;}else{STAT_CANDY_USED = personalStats["candyused"];}
1293 if(personalStats["alcoholused"] == undefined){STAT_alcohol_used = 0;}else{STAT_alcohol_used = personalStats["alcoholused"];}
1294 if(personalStats["energydrinkused"] === undefined){STAT_energy_drink_used = 0;}else{STAT_energy_drink_used = personalStats["energydrinkused"];}
1295 if(personalstatsResp["criminalrecord"]["total"] == undefined){STAT_TOTAL_CRIMES = 0;}else{STAT_TOTAL_CRIMES = personalstatsResp["criminalrecord"]["total"];}
1296
1297 $("#" + 'attackswon-' + userID).text(fmtNumber(STAT_ATTACKS_WON));
1298 $("#" + 'defendswon-' + userID).text(fmtNumber(STAT_DEFENDS_WON));
1299 $("#" + 'moneymugged-' + userID).text(formatCurrency(STAT_MONEY_MUGGED));
1300 $("#" + 'highestlevel-' + userID).text(STAT_HIGH_LEVEL);
1301 $("#" + 'killstreak-' + userID).text(fmtNumber(BEST_KILL_STREAK));
1302 $("#" + 'respect-' + userID).text(fmtNumber(STAT_RESPECT));
1303 $("#" + 'busts-' + userID).text(fmtNumber(STAT_PEOPLE_BUSTED));
1304 $("#" + 'bailed-' + userID).text(fmtNumber(STAT_PEOPLE_BAILED));
1305 $("#" + 'criminaloffences-' + userID).text(fmtNumber(STAT_TOTAL_CRIMES));
1306 $("#" + 'timestravelled-' + userID).text(fmtNumber(STAT_TRAVEL_TIMES));
1307 $("#" + 'revives-' + userID).text(fmtNumber(STAT_REVIVES));
1308 $("#" + 'bloodwithdrawn-' + userID).text(fmtNumber(STAT_bloodwithdrawn));
1309 $("#" + 'booksread-' + userID).text(fmtNumber(STAT_BOOKS_READ));
1310 $("#" + 'ecstasy-' + userID).text(fmtNumber(STAT_ECSTASY_TAKEN));
1311 $("#" + 'xanax-' + userID).text(fmtNumber(STAT_XANAX_TAKEN));
1312 $("#" + 'vicodin-' + userID).text(fmtNumber(STAT_VICODIN_TAKEN));
1313 $("#" + 'lsd-' + userID).text(fmtNumber(STAT_LSD_TAKEN));
1314 $("#" + 'missioncredits-' + userID).text(fmtNumber(STAT_CREDITS_EARNED));
1315 $("#" + 'nw-' + userID).text(formatCurrency(personalStats["networth"]));
1316 $("#" + 'logins-' + userID).text(fmtNumber(STAT_LOGINS));
1317 $("#" + 'reffil-' + userID).text(fmtNumber(STAT_REFILLS_TAKEN));
1318 $("#" + 'enhancers-' + userID).text(fmtNumber(STAT_ENHANCER_TAKEN));
1319 $("#" + 'donator-' + userID).text(fmtNumber(DAYS_BEEN_DONATOR));
1320 $("#" + 'candyeaten-' + userID).text(fmtNumber(STAT_CANDY_USED));
1321 $("#" + 'alcohol-' + userID).text(fmtNumber(STAT_alcohol_used));
1322 $("#" + 'drinks-' + userID).text(fmtNumber(STAT_energy_drink_used));
1323 // }
1324 //}
1325}
1326
1327function addPersonalStatsLine(html, elemID, userID){
1328 var newspan2 = $("<span class='bold'></span").append(html);
1329
1330 var newDiv2_1 = $("<div class='user-information-section left width112'></div>").append(newspan2);
1331 var newspan2_2 = $("<span></span>").attr("id", elemID + userID).append("Wait...");
1332
1333 var newli2_1 = $("<li></li>").append(newDiv2_1,newspan2_2);
1334
1335 return newli2_1;
1336}
1337
1338function personal_stats2(jNode){
1339 var userID = document.location.href.match(/\/profiles.php\?XID\=(\d+)/)[1];
1340
1341 var newDiv1 = $("<div class='menu-header'></div>").text("Personal Stats");
1342 var newDiv2 = $("<div class='profile-container basic-info bottom-round'></div>");
1343 var newul = $("<ul class='basic-list'></ul>");
1344
1345 if(psattackswon == '1') newul.append(addPersonalStatsLine('Attacks Won:', 'attackswon-', userID));
1346 if(psdefendswon == '1') newul.append(addPersonalStatsLine('Defends Won:', 'defendswon-', userID));
1347 if(psmoneymugged == '1') newul.append(addPersonalStatsLine('Money Mugged:', 'moneymugged-', userID));
1348 if(pshighestlevel == '1') newul.append(addPersonalStatsLine('Highest Level Beaten', 'highestlevel-', userID));
1349 if(pstotalrespect == '1') newul.append(addPersonalStatsLine('Total Respect Gained:', 'respect-', userID));
1350 if(pspeoplebusted == '1') newul.append(addPersonalStatsLine('People Busts:', 'busts-', userID));
1351 if(pspeoplebailed == '1') newul.append(addPersonalStatsLine('People Bailed:', 'bailed-', userID));
1352 if(pscriminaloffences == '1') newul.append(addPersonalStatsLine('Criminal offences:', 'criminaloffences-', userID));
1353 if(pstimestravelled == '1') newul.append(addPersonalStatsLine('Times travelled:', 'timestravelled-', userID));
1354 if(psrevives == '1') newul.append(addPersonalStatsLine('Revives:', 'revives-', userID));
1355 if(psbloodwithdrawn == '1') newul.append(addPersonalStatsLine('Blood withdrawn:', 'bloodwithdrawn-', userID));
1356 if(psbooksread == '1') newul.append(addPersonalStatsLine('Books Read:', 'booksread-', userID));
1357 if(psecstasy == '1') newul.append(addPersonalStatsLine('Ecstasy Taken:', 'ecstasy-', userID));
1358 if(psxanax == '1') newul.append(addPersonalStatsLine('Xanax Taken:', 'xanax-', userID));
1359 if(psvicodin == '1') newul.append(addPersonalStatsLine('Vicodin Taken:', 'vicodin-', userID));
1360 if(pslsd == '1') newul.append(addPersonalStatsLine('LSD Taken:', 'lsd-', userID));
1361 if(psmissioncredits == '1') newul.append(addPersonalStatsLine('Mission credits earned:', 'missioncredits-', userID));
1362 if(psnetworth == '1') newul.append(addPersonalStatsLine('Networth:', 'nw-', userID));
1363 if(pslogins == '1') newul.append(addPersonalStatsLine('Logins:', 'logins-', userID));
1364 if(psreffils == '1') newul.append(addPersonalStatsLine('Energy Refills:', 'reffil-', userID));
1365 if(psenhancers == '1') newul.append(addPersonalStatsLine('Stat Enhancers Used:', 'enhancers-', userID));
1366 if(psdonator == '1') newul.append(addPersonalStatsLine('Days Been a Donator:', 'donator-', userID));
1367 if(pscandyeaten == '1') newul.append(addPersonalStatsLine('Candy Eaten:', 'candyeaten-', userID));
1368 if(psalcohol == '1') newul.append(addPersonalStatsLine('Alcohol drunk:', 'alcohol-', userID));
1369 if(psdrinks == '1') newul.append(addPersonalStatsLine('Energy drinks drunk:', 'drinks-', userID));
1370
1371 newDiv2.append(newul);
1372 var newbr = $("<br/>");
1373 $("#competition-profile-wrapper").append(newbr, newDiv1, newDiv2);
1374
1375 var link = "https://api.torn.com/user/"+userID+"?selections=basic,personalstats,crimes&key=" + api_key;
1376 requestPage3(link);
1377 //requestAPI("//api.torn.com/user/"+userID+"?selections=basic,personalstats,crimes&key=", api_key, true, handler_personal_stats);
1378}
1379
1380function requestPage3(link){
1381 GM_xmlhttpRequest({
1382 method: "GET",
1383 url: link,
1384 onreadystatechange: function (res) {
1385 if (res.readyState === 4 && res.status === 200) {
1386 const parsedRes = JSON.parse(res.responseText)
1387 handler_personal_stats( parsedRes);
1388 }
1389 }
1390 });
1391}
1392
1393function personal_stats(jNode){
1394 waitForKeyElements("#competition-profile-wrapper", personal_stats2);
1395}
1396
1397if (document.location.href.match(/profiles.php\?XID\=(\d+)/) ){
1398 if(personalstats == '1'){
1399 waitForKeyElements("#profileroot", personal_stats);
1400 }
1401}
1402
1403//Remover bounties indisponíveis
1404function remove_bounties(jNode){
1405 jNode.children().each(function(i){
1406 if($(this).find('span.t-red').length){
1407 $(this).remove();
1408 }
1409 } );
1410}
1411
1412if(document.location.href.match(/\/bounties.php/) && removerBounties == '1') {
1413 waitForKeyElements ("ul.bounties-list.t-blue-cont.h", remove_bounties, false);
1414}
1415
1416//Redirects to gym after refilling
1417if(document.location.href.match(/\/points.php\?step\=refill/)){
1418 if(document.body.innerHTML.match(/You have used <b>25 points<\/b> to refill/)){
1419 document.location = '//' + document.domain + '\/gym.php';
1420 }
1421}
1422
1423// add express crime form
1424if (document.location.href.match(/\/crimes\.php/)) {
1425 if(removecrimes == '1'){
1426 if(crime2 != '1') $("ul.highlightSearchForCash").parent().remove();
1427 if(crime3 != '1') $("ul.highlightSellMedia").parent().remove();
1428 if(crime4 != '1') $("ul.highlightShoplift").parent().remove();
1429 if(crime5 != '1') $("li.bonus:contains('Pickpocket someone')").parent().parent().remove();
1430 if(crime6 != '1') $("li.bonus:contains('Larceny')").parent().parent().remove();
1431 if(crime7 != '1') $("li.bonus:contains('Armed Robberies')").parent().parent().remove();
1432 if(crime8 != '1') $("li.bonus:contains('Transport drugs')").parent().parent().remove();
1433 if(crime9 != '1') $("li.bonus:contains('Plant a computer virus')").parent().parent().remove();
1434 if(crime10 != '1') $("li.bonus:contains('Assassination')").parent().parent().remove();
1435 if(crime11 != '1') $("li.bonus:contains('Arson')").parent().parent().remove();
1436 if(crime12 != '1') $("li.bonus:contains('Grand Theft Auto')").parent().parent().remove();
1437 if(crime13 != '1') $("li.bonus:contains('Pawn Shop')").parent().parent().remove();
1438 if(crime14 != '1') $("li.bonus:contains('Counterfeiting')").parent().parent().remove();
1439 if(crime15 != '1') $("li.bonus:contains('Kidnapping')").parent().parent().remove();
1440 if(crime16 != '1') $("li.bonus:contains('Arms Trafficking')").parent().parent().remove();
1441 if(crime17 != '1') $("li.bonus:contains('Bombings')").parent().parent().remove();
1442 if(crime18 != '1') $("li.bonus:contains('Hacking')").parent().parent().remove();
1443
1444 $("div.special.btn-wrap.silver.m-top10").after($("<div class=\"special btn-wrap silver m-top10\"><div id=\"view_original\" class=\"btn\" role=\"button\" onclick=\"location.href='crimes.php#/step=main';\"> View Original </div></div>"));
1445
1446 }
1447}
1448
1449// Express Bust
1450function express_bust(jNode){
1451 jNode.attr('href', jNode.attr('href') + '1');
1452}
1453
1454if(document.location.href.match(/jailview.php$/) && expressbust == '1') {
1455 waitForKeyElements ("a.bust.t-gray-3", express_bust);
1456}
1457
1458// increase size of notepad
1459if (document.location.href.match(/\/notebook\.php/)) {
1460 var TEXTs = document.getElementsByTagName('textarea');
1461 for (var k=0; k<TEXTs.length; ++k) {
1462 if (TEXTs[k].hasAttribute('name') && (TEXTs[k].getAttribute('name') == 'notebook')) {
1463 TEXTs[k].setAttribute('rows', 30); //notepadHeight);
1464 }
1465 }
1466}
1467
1468function destacarLista(tipo, tag){
1469 if(tipo == 1){
1470 $('li:has(a.user.faction:contains("' + tag + '"))').css('background-color', 'lightgreen');
1471 }
1472}
1473if(document.location.href.match(/\/jailview.php/)){
1474 waitForKeyElements ("ul.user-info-list-wrap.links.icons.users-list.bottom-round", destaca);
1475}
1476
1477function destaca(jNode){
1478 jNode.find('li:has(a.user.faction:contains("' + tagJail + '"))').css('background-color', 'lightgreen');
1479}
1480
1481// Highlight people abroad with tag
1482if(document.location.href.match(/\/index.php\?page\=people/)){
1483 $('ul.users-list>li:has(a.user.faction:contains("' + tagOut + '"))').each(function(){
1484 $(this).css('background-color', 'lightgreen');
1485 });
1486}
1487
1488// Submits automatically prices from other cities to TravelRun
1489// http://travelrun.torncentral.com/ run by ebcdic
1490// Destacar pessoas na jail e no hospital com tag indicada
1491if(!document.location.href.match(/\/city.php/)){
1492 window.onload = function(){
1493 if(document.body.innerHTML.match(/You have purchased/) &&
1494 document.body.innerHTML.match(/You are in/)){
1495
1496 var min5 = 5 * 60 * 1000;
1497 var now = new Date().getTime();
1498 var lastflowerupdate = GM_getValue('lastflowerupdate', null);
1499 if(!lastflowerupdate)
1500 lastflowerupdate = 0;
1501 if((now - lastflowerupdate) > min5){
1502 GM_setValue('lastflowerupdate', now.toString());
1503
1504 GM_xmlhttpRequest ( {
1505 method: "POST",
1506 url: "http://travelrun.torncentral.com/update2.php",
1507 data: "data=" + encodeURIComponent(document.body.textContent),
1508 headers: {
1509 "Content-Type": "application/x-www-form-urlencoded"
1510 },
1511 onload: function (response) {
1512 //GM_log("Resposta update TravelRun: " + response.responseText);
1513 }
1514 } );
1515
1516 }
1517 }
1518
1519 // Teve de ser movido para aqui pq o Chrome não reconhecia o document.body
1520 if(document.location.href.match(/\/jailview.php/) || (document.location.href.match(/\/index.php/) && ( document.body.getAttribute('bgcolor') == '#bba47e' || document.body.getAttribute('bgcolor') == '#BBA47E' )) ){
1521 destacarLista(destacarJail, tagJail);
1522 }
1523
1524 if( document.location.href.match(/\/hospitalview.php/) || (document.location.href.match(/\/index.php/) && document.body.getAttribute('bgcolor') == '#ffffff') ){
1525 destacarLista(destacarHosp, tagHosp);
1526 }
1527
1528 //Send a message when going to switzerland and rehab not done
1529 if($('div.switzerland').length > 0){
1530
1531 $('a.travel-home').click(function(event){
1532 var lastRehab = GM_getValue('lastRehab', 9999999999999);
1533 var rehabDone = '' ;
1534 var now = new Date().getTime();
1535 var umahora = 60 * 60 * 1000;
1536
1537 if((now - lastRehab) < umahora && lastRehab != '9999999999999'){
1538 rehabDone = 'X';
1539 }
1540
1541 if(rehabDone != 'X'){
1542 var msg = $('<div class="delimiter"></div>').append($('<div class="msg right-round" style="color: rgb(255, 0, 0);">You haven\'t made rehab yet!</div>'));
1543 var infomsg = $('<div class="info-msg border-round"></div>)').append('<i class="info-icon"></i>')
1544 .append(msg)
1545 .css('background-color', '#FF0000');
1546 var infomsgcont = $('<div class="info-msg-cont user-info border-round m-top10"></div>').append(infomsg);
1547 $('div.travel-home-content').after(infomsgcont);
1548 }
1549 });
1550
1551 $('span.btn:contains("REHAB")').click(function(){
1552 var now = new Date().getTime();
1553 GM_setValue('lastRehab', now.toString());
1554 });
1555 }
1556
1557 //obter preços dos items nos outros paises //Artea & Nathan #drugden
1558 if(flowerdrugprice == '1'){
1559 var precoDrogas = new Array();
1560 var flor;
1561 var precoflor;
1562 var stockflor;
1563 var peluche;
1564 var precopeluche;
1565 var stockpeluche;
1566 var SPANs = document.getElementsByClassName('item-info-wrap expander');
1567
1568 for(var i = 0; i < SPANs.length; i++){
1569 var insideSPAN = SPANs[i].getElementsByTagName('span');
1570
1571 if(insideSPAN[2].innerHTML.match(/Drug/)){
1572 insideSPAN[4].getElementsByTagName('span')[0].innerHTML = '';
1573 var nomeDroga = insideSPAN[4].textContent.trim();
1574 precoDrogas[nomeDroga] = new Array();
1575 var dados = new Array();
1576 var preco = insideSPAN[8].innerHTML.match(/(\$(\d+,)*(\d+)(\.(\d+))?)/)[1];
1577 var stock = insideSPAN[11].innerHTML.match(/((\d+,)*(\d+))/)[1];
1578 precoDrogas[nomeDroga]['nome'] = nomeDroga;
1579 precoDrogas[nomeDroga]['preco'] = preco;
1580 precoDrogas[nomeDroga]['stock'] = stock;
1581 }
1582
1583 if(insideSPAN[2].innerHTML.match(/Flower/)){
1584 insideSPAN[4].getElementsByTagName('span')[0].innerHTML = '';
1585 flor = insideSPAN[4].textContent.trim();
1586 precoflor = insideSPAN[8].innerHTML.match(/(\$(\d+,)*(\d+)(\.(\d+))?)/)[1];
1587 stockflor = insideSPAN[11].innerHTML.match(/((\d+,)*(\d+))/)[1];
1588 }
1589
1590 if(insideSPAN[2].innerHTML.match(/Plushie/)){
1591 insideSPAN[4].getElementsByTagName('span')[0].innerHTML = '';
1592 peluche = insideSPAN[4].textContent.trim();
1593 precopeluche = insideSPAN[8].innerHTML.match(/(\$(\d+,)*(\d+)(\.(\d+))?)/)[1];
1594 stockpeluche = insideSPAN[11].innerHTML.match(/((\d+,)*(\d+))/)[1];
1595 }
1596
1597 }
1598
1599 var locationAll = document.body.innerHTML.match(/You are in <span class\=\"bold">(Mexico|Canada|Cayman Islands|Hawaii|United Kingdom|Argentina|Switzerland|Japan|China|South Africa|Dubai)<\/span> and have/);
1600 if(locationAll != null){
1601 var location = locationAll[1];
1602 var textoAlert = '!update ' + location;
1603 var textoFlor;
1604 var textoPeluche;
1605 for(var ii in precoDrogas){
1606 textoAlert += '\n' + precoDrogas[ii]['nome'] + ' ' + precoDrogas[ii]['preco'] + ' ' + precoDrogas[ii]['stock'];
1607 }
1608
1609 if(precoflor != null){
1610 textoAlert += '\n' + flor + ' ' + precoflor + ' ' + stockflor;
1611 }
1612 if(precopeluche != null){
1613 textoAlert += '\n' + peluche + ' ' + precopeluche + ' ' + stockpeluche;
1614 }
1615 if(textoAlert == null){
1616 textoAlert = 'No price information';
1617 }
1618
1619 var drugButton = function(){
1620 alert(textoAlert);
1621 }
1622
1623 var aTravel = document.getElementsByClassName('travel-home t-clear');
1624
1625 var newA = document.createElement('a');
1626 newA.setAttribute('class', 't-clear h c-pointer m-icon line-h24 right');
1627 newA.setAttribute('id', 'precoDrogas');
1628 newA.setAttribute('href', '#');
1629 newA.innerHTML = '<span class="icon-wrap"><i></i></span><span>Drugs/Flowers/Plushies Price</span>';
1630
1631 aTravel[0].parentNode.insertBefore(newA, aTravel[0].nextSibling);
1632
1633 elem = document.getElementById('precoDrogas');
1634 elem.addEventListener('click', drugButton, true);
1635 }
1636 }
1637 }
1638}
1639
1640
1641
1642
1643function show_prices(jNode){
1644 var link = 'http://travelrun.torncentral.com/index.php?c=';
1645
1646 if(jNode.parent().parent().parent().attr('class') == 'travel-container full-map'){
1647 var destination = jNode.find("span.bold").text();
1648
1649 switch(destination){
1650 case 'Mexico': link = link + 'm'; break;
1651 case 'Cayman Islands': link = link + 'i'; break;
1652 case 'Canada': link = link + 'c'; break;
1653 case 'Hawaii': link = link + 'h'; break;
1654 case 'United Kingdom': link = link + 'u'; break;
1655 case 'Argentina': link = link + 'a'; break;
1656 case 'Switzerland': link = link + 's'; break;
1657 case 'Japan': link = link + 'j'; break;
1658 case 'China': link = link + 'x'; break;
1659 case 'UAE': link = link + 'e'; break;
1660 case 'South Africa': link = link + 'z'; break;
1661 }
1662
1663 var doc;
1664
1665 GM_xmlhttpRequest({
1666 method: "GET",
1667 url: link,
1668 headers: {
1669 'User-agent': 'Mozilla/4.0 (compatible) Greasemonkey/0.3',
1670 'Accept': 'application/atom+xml,application/xml,text/xml',
1671 },
1672 synchronous: false,
1673 onload: function(response) {
1674 doc = document.implementation.createHTMLDocument("example");
1675 doc.documentElement.innerHTML = response.responseText;
1676
1677 var div = doc.getElementsByClassName('itemdata')[0];
1678
1679 $("#prices-dest").empty();
1680 $("#prices-dest").append(div);
1681 $("table").css({
1682 'border-top-width' : '0px',
1683 'border-right-width' : '0px',
1684 'border-bottom-width' : '0px',
1685 'border-left-width' : '0px',
1686 'width' : '100%',
1687 'border-spacing' : '1px',
1688 'display' : 'table',
1689 'border-collapse' : 'separate'
1690 });
1691 $("tbody").css({
1692 'display' : 'table-row-group',
1693 'vertical-align' : 'middle',
1694 'border-color' : 'inherit',
1695 });
1696 $("tr").css({
1697 'border-color' : 'inherit',
1698 'vertical-align' : 'inherit',
1699 'display' : 'table-row',
1700 });
1701 $("th").css({
1702 'font-weight' : 'bold',
1703 'text-align' : 'internal-center',
1704 'display' : 'table-cell',
1705 'vertical-align' : 'inherit'
1706 });
1707 $("td").css({
1708 'display' : 'table-cell',
1709 'vertical-align' : 'inherit'
1710 });
1711 }
1712 });
1713 }
1714}
1715
1716// Show prices outside in travel agency from travelrun
1717if (document.location.href.match(/travelagency\.php/) && travelrunprices == '1'){
1718
1719 waitForKeyElements("div.destination", show_prices);
1720
1721 $("<style>")
1722 .attr("type", "text/css")
1723 .html("\
1724 tr.default { background-color: grey; color: black; }\
1725 tr.drug { background-color: yellow; color: black; }\
1726 tr.flower { background-color: limegreen; color: black; }\
1727 tr.plushie { background-color: pink; color: black; }\
1728 tr.alcohol { background-color: lightcyan; color: black; }\
1729 tr.misc { background-color: grey; color: black; }\
1730 ")
1731 .appendTo("head");
1732
1733
1734 $("div.travel-agency:first").after("<br><div id='prices-dest'></div>");
1735}
1736
1737// Holder Mode: Hides any upgrade links
1738function retiraUpgrade(){
1739 if(holderMode == 1){
1740 if(document.location.href.match(/\/index\.php$/)){
1741 var compLI = $('li:contains("Congratulations! You have enough")').parent().children().length;
1742 var UL = $('li:contains("Congratulations! You have enough")').parent().text();
1743 if(UL != '' && compLI == '1'){
1744 // na mesma caixa podem aparecer 2 avisos, se só tiver um, remove a caixa e a linha hr
1745 $('div.info-msg-cont.green.border-round.m-top10').remove();
1746 $('hr.page-head-delimiter.m-top10').remove();
1747 }else{
1748 $('li:contains("Congratulations! You have enough")').remove();
1749 }
1750 }
1751 //Remover botão de upgrade
1752 $('#pointsLevel').remove();
1753 }
1754}
1755
1756if(holderMode == 1){
1757 retiraUpgrade();
1758 setInterval(retiraUpgrade, 1000);
1759}
1760
1761//Align Torn to left (thanks to tn5421[276835] and LordBusiness [2052465])
1762if(alignleft == '1'){
1763 GM_addStyle(`.d .content .container, .d .header-wrapper-top .container {
1764 margin-left: 10px !important;
1765}
1766.d #mainContainer .content-wrapper {
1767margin-left: 10px;
1768}`);
1769}
1770
1771//Adds employee last action in employee list (in companies)
1772if (document.location.href.match(/\/companies.php/)) {
1773 if($("div.details-wrap.player-info").text().match(/Director/) || player == 'alguem'){
1774 waitForKeyElements ("div.employee-list-wrap", employeeLastAction);
1775 }
1776}
1777
1778function handler_empl_last_action(){
1779 if(this.readyState == 4 && this.status == 200) {
1780 if(this.responseText != null){
1781 var httpResp = this.responseText;
1782 var profileResp = JSON.parse(httpResp);
1783
1784 if(profileResp.error != null && ( profileResp.error.code == '2' || profileResp.error.code == '12' )){
1785 var new_api_key = get_api_key();
1786 set_api_key(new_api_key);
1787 var url = this.responseURL.split('&key=');
1788 var new_url = url[0] + '&key=';
1789 profileResp = requestAPI(new_url, new_api_key);
1790 }
1791 var lastAction = profileResp.last_action.relative;
1792
1793 if( lastAction.search('day') != -1){
1794 lastAction = '<b><font color="red">' + parseInt(lastAction) + ' d</font></b>';
1795 }else if(lastAction.search('hour') != -1){
1796 lastAction = parseInt(lastAction) + ' h';
1797 }else if( lastAction.search('minute') != -1){
1798 lastAction = parseInt(lastAction) + ' m';
1799 }
1800 else{
1801 lastAction = parseInt(lastAction) + ' s';
1802 }
1803
1804 var userID = this.responseURL.match(/user\/(\d+)\?/)[1];
1805 $("#empl_" + userID).html(lastAction);
1806 }
1807 }
1808}
1809
1810var train_click;
1811
1812function employeeLastAction(jNode) {
1813 var lista = jNode.find("div.employee.icons.t-overflow");
1814
1815 $(".employee-list-wrap").css("background-color","#f2f2f2");
1816 $(".employee").css("width","155px"); //142px
1817 $(".pay").css("width","75px"); //118px
1818 $(".pay input").css("width","55px");
1819
1820 $("a.train-action").click(function(){
1821 //if clicked on train, disable last action
1822 train_click = '1';
1823 });
1824
1825 if(train_click == '1'){ //if an update is made to the table, do not check again
1826 return;
1827 }
1828
1829 lista.each( function(){
1830 var profile = $(this).find('a').attr('href');
1831 var ID = profile.match(/\/profiles.php\?XID\=(\d+)/)[1];
1832 var linkAPI = "//api.torn.com/user/" + ID + "?selections=profile&key=";
1833
1834 $(this).find('a').after( " (<span id=\"empl_" + ID + "\"><img src=\"http://qminh86it.googlepages.com/loading12.gif\"></img></span>)");
1835
1836 requestAPI(linkAPI, api_key, true, handler_empl_last_action);
1837 });
1838}
1839
1840function get_chain_count(){
1841 var apiResponse = requestAPI('//api.torn.com/user/?selections=bars&key=', api_key);
1842
1843 if(apiResponse.chain.current != 0){
1844 var time = apiResponse.chain.timeout * 1;
1845 var minutes = Math.floor(time / 60);
1846 var seconds = time - minutes * 60;
1847 if(seconds < 10)
1848 seconds = '0' + seconds;
1849
1850 //$("#chainFrame").html("Chain: " + apiResponse.chain.current + " / 100 " + minutes + ":" + seconds);
1851 $("#chainFrame").html("Chain: " + apiResponse.chain.current + " " + minutes + ":" + seconds);
1852 }
1853}
1854
1855// Add Chain counter in attacks
1856// Add chain counter while traveling
1857if(extrachainbar == '1' && ( $("#skip-to-content").text().match(/Travelling|Mexico|Canada|Cayman|Kingdom|Switzerland|UAE|Dubai|South|Argentina|Hawaii|Japan|China/) ||
1858 document.location.href.match(/\/loader.php\?sid\=attack/) ) ){
1859 var setClock;
1860 //Chain:26 / 100 04:58
1861 $("div.header-wrapper-bottom").append("<div id='chainFrame' style='height:40px;background:rgb(200, 200, 200);font-size:14px;color:black;'></div>");
1862 $("#chainFrame").width($('#tcLogo').offset().left);
1863 get_chain_count();
1864 $("#chainFrame").mouseover(function (){setClock=window.setInterval(get_chain_count,2000);});
1865 $("#chainFrame").mouseout(function(){clearInterval(setClock);});
1866}
1867
1868//Request by evilf9 - memberlist
1869if(player == 'evilf9'){
1870 //$(".menu-info-row-value.left a").text("evilfnoob");
1871 waitForKeyElements("div.faction-info-wrap>div.f-war-list", memberList);
1872}
1873
1874//fun stuff
1875/*if(player == 'evilf9' || player == 'Pidu' || player == 'The_Storm'){
1876 var my_random_value = 0 + (100 - 0) * Math.random();
1877
1878 if(my_random_value < 10){
1879
1880 var stringTest = "Foste cheddado...";
1881 var char = 0;
1882 var myfunction;
1883 $(".content.m-top10").prepend("<div id='divTeste' class='cenas' style='color:red;width:100%;text-align:center;font-size:16px;margin:20px auto;font-weight:bold;'></div>");
1884 myfunction = window.setInterval(function(){
1885 $("#divTeste").append(stringTest[char]);
1886 char++;
1887 if(char > 16){
1888 clearInterval(myfunction);
1889 }
1890 }, 500);
1891
1892 $(".cenas").css({
1893 'width': '100%',
1894 'text-align': 'center',
1895 'color': 'rgb(255, 255, 255)',
1896 'font-size': '40px',
1897 'background-color': 'rgb(51, 51, 51)',
1898 'text-shadow': 'rgb(255, 255, 255) 0px -1px 4px, rgb(255, 255, 0) 0px -2px 10px, rgb(255, 128, 0) 0px -10px 20px, rgb(255, 0, 0) 0px -18px 40px'
1899 });
1900 }
1901}*/
1902
1903function memberList(jNode){
1904 var members = [];
1905 jNode.find("ul.member-list.info-members.bottom-round.t-blue-cont.h>li>div>span.m-hide>a")
1906 .each(function(){
1907 members.push($(this).text());
1908 });
1909
1910 var textoAlert;
1911 $.each(members, function(item, val){
1912 if(textoAlert == null)
1913 textoAlert = val;
1914 else
1915 textoAlert += '\n' + val;
1916 });
1917
1918 var listaMembros = function(){
1919 alert(textoAlert);
1920 }
1921
1922 var newA = document.createElement('a');
1923 newA.setAttribute('class', 't-clear h c-pointer m-icon line-h24 right');
1924 newA.setAttribute('id', 'listaMembros');
1925 newA.setAttribute('href', '#');
1926 newA.innerHTML = '<span class="icon-wrap"><i></i></span><span>Lista Membros</span>';
1927 newA.addEventListener('click', listaMembros, true);
1928
1929 $('#skip-to-content').after(newA);
1930}
1931
1932//$("div.header-wrapper-bottom").append($("div.footer-menu.left").clone(true).css('left','30%')
1933// .css('position', 'absolute') .css("color", "#fff") .css('border', 'none')
1934// .css('font-size', '110%')
1935// );
1936//$("div.footer-menu.left:last").remove();
1937
1938// Warbase Settings
1939
1940function hide_warbase(jNode){
1941
1942 if(hideOff == '1'){
1943 jNode.find("li:has(li#icon2)").each(function(item){
1944 $(this).remove();
1945 });
1946 }
1947
1948 if(hideTravel == '1'){
1949 jNode.find("li:has(span.t-red:contains('Traveling')), li:has(span.t-red:contains('Federal')), li:has(span.t-red:contains('Fallen'))").each(function(item){
1950 $(this).remove();
1951 });
1952 }
1953
1954 if(hideHosped == '1'){
1955 jNode.find("li:has(span.t-red:contains('Hospital'))").each(function(item){
1956 $(this).remove();
1957 });
1958 }
1959
1960}
1961
1962function totalWB(jNode){
1963 jNode.after('<div class="info-msg-cont green border-round m-top10"><div class="info-msg border-round"><i class="info-icon"></i><div class="delimiter"><div class="msg right-round">Total Warbase: ' + $(".faction-respect-wars-wp").find(".member-list > li").length + '</div></div></div></div>');
1964}
1965
1966/*if(document.location.href.match(/\/factions.php\?step\=your/) && ( hideOff == '1' || hideTravel == '1' || hideHosped == '1')){
1967 waitForKeyElements("li.descriptions", hide_warbase);
1968}*/
1969
1970if(document.location.href.match(/\/factions.php\?step\=profile/) && hideFactionList == '1' && ( hideOff == '1' || hideTravel == '1' || hideHosped == '1')){
1971 waitForKeyElements("ul.member-list.bottom-round.t-blue-cont.h", hide_warbase);
1972}
1973
1974if(document.location.href.match(/\/factions.php\?step\=your/)){
1975 //Checks if OC is really ready
1976 waitForKeyElements("div.faction-crimes-wrap>div.organize-wrap>div.crimes-cont>ul.crimes-list", OC_readiness);
1977
1978 //last action in member list hover
1979 waitForKeyElements("div.faction-info-wrap", memberLastAction);
1980
1981 // Total enemies in WB //stopped working
1982 //waitForKeyElements("div.f-msg.red.m-top10", totalWB);
1983}
1984
1985function OC_readiness(jNode){
1986 jNode.children().each(function(item){
1987 if($(this).find('ul>li.status>span.t-green').length){
1988 if($(this).find('div.details-wrap>ul.details-list>li>ul.item>li.stat-red').length){
1989 $(this).find('ul>li.status>span.t-green').attr('class', 'bold t-red').html('Not Ready');
1990 }
1991 }
1992 });
1993}
1994
1995function memberLastAction(jNode) {
1996 var lista = jNode.find("div.member.icons");
1997
1998 lista.hover( function(){
1999
2000 $(this).attr('title', function(){
2001 if($(this).attr('title').length == 0){
2002 var profile = $(this).find('span>a').attr('href');
2003 var link = 'profiles.php?XID=' + profile.match(/\/profiles.php\?XID\=(\d+)/)[1];
2004 var ID = profile.match(/\/profiles.php\?XID\=(\d+)/)[1];
2005 var linkAPI = "//api.torn.com/user/" + ID + "?selections=profile&key=";
2006
2007 var profileResp = requestAPI(linkAPI, api_key);
2008 return "Last Action: " + profileResp.last_action.relative;
2009 }
2010 });
2011 }, false);
2012}
2013
2014
2015//Highlight Your nick in the chat
2016if(highlightchat == '1'){
2017 waitForKeyElements("#chatRoot", chat_highlight);
2018}
2019
2020function chat_highlight2(jNode){
2021 //if(player == 'evilf9')
2022 //$('div[class^="chat-box-content"]').css("background-color","#ff33cc");
2023 highlight_name(jNode);
2024}
2025
2026function chat_highlight(jNode){
2027 waitForKeyElements('div[class^="message_"]', chat_highlight2);
2028 highlight_name(jNode);
2029}
2030
2031function highlight_name(jNode){
2032 if(highlightchat_color == null) highlightchat_color = 'blue';
2033 jNode.find('a:contains(' + player + ')').each(function(){
2034 $(this).css("color", highlightchat_color);
2035 });
2036}
2037
2038
2039//------------------Funcoes----------------------------------------------//
2040function fmtAmount(amt) {
2041 var x = "";
2042 if (amt<0) {
2043 x = "<font color=red>$";
2044 amt *= -1;
2045 x += fmtNumber(amt);
2046 x += "</font>";
2047 } else {
2048 if (amt>0) {
2049 x = "<font color=green>$";
2050 x += fmtNumber(amt);
2051 x += "</font>";
2052 } else {
2053 x = "0";
2054 }
2055 }
2056 return x;
2057}
2058
2059function fmtNumber(n) {
2060 var x = n.toString();
2061 var y = '';
2062 var k = x.indexOf('.');
2063 var i=x.length;
2064 if(k<0) k = i;
2065 var j=0;
2066 while (i>0) {
2067 --i;
2068 y = x.substr(i, 1) + y;
2069 if(i < k){
2070 if (++j % 3 == 0) {
2071 if (i) y = ',' + y;
2072 }
2073 }
2074 }
2075 return y;
2076}
2077
2078function formatCurrency(num) {
2079 num = num.toString().replace(/\$|\,/g,'');
2080 if(isNaN(num))
2081 num = "0";
2082 sign = (num == (num = Math.abs(num)));
2083 num = Math.floor(num*100+0.50000000001);
2084 cents = num%100;
2085 num = Math.floor(num/100).toString();
2086 if(cents<10)
2087 cents = "0" + cents;
2088 for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
2089 num = num.substring(0,num.length-(4*i+3))+','+
2090 num.substring(num.length-(4*i+3));
2091// return (((sign)?'':'-') + '$' + num + '.' + cents);
2092 return (((sign)?'':'-') + '$' + num);
2093}
2094
2095function updateScript(manual){
2096 try {
2097 var ONE_DAY = 24 * 60 * 60 * 1000;
2098 var now = new Date().getTime();
2099 var lastChecked = GM_getValue('alt_lastchecked', null);
2100 if(!lastChecked)
2101 lastChecked = 0;
2102 if((now - lastChecked) < ONE_DAY && manual != '1')
2103 return;
2104 GM_setValue('alt_lastchecked', now.toString());
2105 var link = 'http://www.torntuga.com/torncity/greasemonkey/alteracoes.user.js';
2106 var randomNumber =Math.floor(Math.random()*999)+1; //Obter número random entre 1 e 999
2107 link = link + '?rfc=' + randomNumber + '.user.js';
2108
2109 GM_xmlhttpRequest({
2110 method: 'GET',
2111 url: link,
2112 onload: function(result) {
2113 if (!result.responseText.match(/@version\s+([\d.]+)/)) return;
2114 var theOtherVersion = parseFloat(RegExp.$1);
2115 var versaoActual = GM_getValue('alt_versao');
2116 if (theOtherVersion <= versaoActual){
2117 if(manual == '1')
2118 alert('There is no new version :(');
2119 return;
2120 }
2121 var mensagem = 'There is a new version of the script \'Altera' + String.fromCharCode(231) + String.fromCharCode(245) + 'es TC\'. Updates:';
2122
2123 var alt = result.responseText.match(/(\d\d\/\d\d\/\d\d)(:)?\s+(.*)/g);
2124 var diaVActual = versaoActual.slice(6,8);
2125 var mesVActual = versaoActual.slice(4,6);
2126 var anoVActual = versaoActual.slice(2,4);
2127
2128 for(var i = 0; i < alt.length; i++){
2129 var divisao = alt[i].match(/^((\d\d)\/(\d\d)\/(\d\d))(:)?\s+(.*)*/);
2130 if(dataAnterior(anoVActual,mesVActual,diaVActual, divisao[4],divisao[3],divisao[2])){
2131 mensagem += '\n- ' + divisao[6].slice(0,divisao[6].length);
2132 }
2133 }
2134
2135 mensagem += '\n\nUpdate now?';
2136
2137 if(window.confirm(mensagem)) {
2138 GM_openInTab(link);
2139 }
2140 }
2141 });
2142 } catch (ex) { }
2143}
2144
2145// ver se 1 é anterior a 2
2146function dataAnterior(a1, m1, d1, a2, m2, d2){
2147 //GM_log(d1 + '/' + m1 + '/' + a1 + ' ' + d2 + '/' + m2 + '/' + a2);
2148 if(a1<a2)
2149 return 1;
2150 else
2151 if(a1==a2){
2152 if(m1<m2)
2153 return 1;
2154 else if(m1 == m2 && d1<d2)
2155 return 1;
2156 }
2157 return 0;
2158}
2159
2160// Settings --- City
2161function settings(){
2162 var fxchkb = function(x) {
2163 GM_setValue(x.target.id, x.target.checked?'1':'0');
2164 };
2165
2166 var fxtext = function(x) {
2167 GM_setValue(x.target.id, x.target.value);
2168 };
2169
2170 var fxupdate = function(x){
2171 updateScript('1');
2172 };
2173
2174 var fxradio = function(x) {
2175 GM_setValue(x.target.id, x.target.checked?'1':'0');
2176 switch(x.target.id){
2177 case 'time12h':
2178 GM_setValue('time24h', '0');
2179 break;
2180 case 'time24h':
2181 GM_setValue('time12h', '0');
2182 break;
2183 }
2184 };
2185
2186 var versao = GM_getValue('alt_versao');
2187
2188 $('head').append('<link rel="stylesheet" href="/css/style/home.css" type="text/css" />');
2189 //$('head').append('<link rel="stylesheet" href="/css/style/preferences.min.css" type="text/css" />');
2190 //$('head').append('<link rel="stylesheet" href="/css/style/header.min.css" type="text/css" />');
2191 //$('head').append('<link rel="stylesheet" href="/css/style/faction_controls.css" type="text/css" />');
2192
2193 $('#tab-menu').append('<hr class="page-head-delimiter m-top10 m-bottom10">');
2194 $('#tab-menu').append('<div class="sortable-box t-blue-cont h "><div class="title-black active top-round"><div class="arrow-wrap"></div>Alteracoes/Torn City Enhancer Configuration</div></div>');
2195 $('#tab-menu').append('<div class="content m-top10"><div class="sortable-list left" id="column1"> <div class="sortable-box t-blue-cont h"><div class="title-black top-round active"><div class="arrow-wrap"></div>Main Options</div><div style="display: block;" class="bottom-round"><div class="cont-gray bottom-round"><ul class="info-cont-wrap">\
2196 <li><span class="desc" title="Hides the level upgrade links"><input type="checkbox" id="holderMode"> Holder Mode</span></li>\
2197 <li><span class="desc" title="Removes bounties from the list that cannot be claimed"><input type="checkbox" id="removerBounties"> Remove unavailable bounties</span></li>\
2198 <li><span class="desc"><input type="checkbox" id="destacarJail"> Highlight people in Jail with tag <input type="text" id="tagJail" size="4" maxlength="5"></span></li>\
2199 <li><span class="desc"><input type="checkbox" id="destacarHosp"> Highlight people in Hospital with tag <input type="text" id="tagHosp" size="4" maxlength="5"></span></li>\
2200 <li><span class="desc"><input type="checkbox" id="highlightOut"> Highlight people abroad with tag <input type="text" id="tagOut" size="4" maxlength="5"></span></li>\
2201 <li class="un-visible"><span class="desc"><input type="checkbox" id="lastaction"> Show Last Action/Location in other faction members list</span></li>\
2202 <li><span class="desc" title="Opens a window with the current stock prices, if you wish to export to an excel sheet, for example"><input type="checkbox" id="resprecos"> (Stock market) Show summary prices button</span></li>\
2203 <li><span class="desc" title="Opens a window with the current prices of the external city, for #drugden channel usage"><input type="checkbox" id="flowerdrugprice"> Show flower/drug/plushie price button outside</span></li>\
2204 <li class="un-visible"><input type="checkbox" id="sfsstock"> (Stock market) Show shares for sale in main page</li>\
2205 <li><span class="desc"><input type="checkbox" id="percStats"> Add battle stats percentage</span></li>\
2206 <li><span class="desc"><input type="checkbox" id="effstats"> Add effective battle stats</span></li>\
2207 <li><span class="desc" title="Adds the next merit and the crimes left in Criminal Record in Home page"><input type="checkbox" id="crimeMerits"> Add crimes left for next merit</span></li>\
2208 <li class="un-visible"><input type="checkbox" id="respfaction"> Show respect won in faction members list</li>\
2209 <li><span class="desc"><input type="checkbox" id="hidemap"> Hide images from map for easier city finds</span></li>\
2210 <li><span class="desc"><input type="checkbox" id="flowerprices"> Add flower prices in Home from Travelrun</span></li>\
2211 <li><span class="desc"><input type="checkbox" id="plushieprices"> Add plushie prices in Home from Travelrun</span></li>\
2212 <li><span class="desc" title="Get the latest prices from Travelrun and shows them when clicking in a destination"><input type="checkbox" id="travelrunprices"> Add outside prices in Travel Agency from Travelrun</span></li>\
2213 <!--<li><input type="checkbox" id="sortitems"> Sort items by category</li>-->\
2214 <li><span class="desc" title="Adds a new block in profile with personal stats"><input type="checkbox" id="personalstats"> Add Personal Stats on profile (select stats on the right)</span></li>\
2215 <li><span class="desc" title="Removes crimes from crime page"><input type="checkbox" id="removecrimes"> Remove crimes from Crime list (select crimes on the right)</span></li>\
2216 <li><span class="desc"><input type="checkbox" id="redirectgym"> Redirect to gym after Xanax/FHC taken</span></li>\
2217 <li><span class="desc"><input type="checkbox" id="highlightchat"> Highlight your nick in the chat with the color <select id="highlightchat_color"><option value="blue">Blue</option><option value="Gray">Gray</option><option value="green">Green</option><option value="#cc9900">Gold</option><option value="Brown">Brown</option><option value="Orange">Orange</option><option value="DeepPink">DeepPink</option></select></span></li>\
2218 <li><span class="desc" title="Removes table borders in the new layout"><input type="checkbox" id="removeborders"> Remove table borders in Home and Profiles</span></li>\
2219 <li><span class="desc" title="Counts the position of a company and shows a table with the results"><input type="checkbox" id="positioncounter"> Add a position counter in company profile page</span></li>\
2220 <li><span class="desc" title="Removes bust confirmation"><input type="checkbox" id="expressbust"> Express Bust</span></li>\
2221 <li><span class="desc" title="Aligns Torn menus to left side of screen"><input type="checkbox" id="alignleft"> Align Torn to left</span></li>\
2222 <li><span class="desc" title="Removes players in a faction from userlist"><input type="checkbox" id="factionless"> Remove players in a faction from Userlist</span></li>\
2223 <li><span class="desc" title="Removes players in a company from userlist"><input type="checkbox" id="companyless"> Remove players in a company from Userlist</span></li>\
2224 <li><span class="desc" title="Select if you want to see time like 1PM or 13:00"> Time Format <input type="radio" name="timeformat" id="time12h"> 12h <input type="radio" name="timeformat" id="time24h"> 24h</span></li>\
2225 </ul></div></div></div>\
2226 <div class="sortable-box t-blue-cont h"><div class="title-black top-round active"><div class="arrow-wrap"></div>Add Links in Sidebar</div><div style="display: block;" class="bottom-round"><div class="cont-gray bottom-round"><ul class="info-cont-wrap">\
2227 <li><span class="desc"><input type="checkbox" id="lraces"> Races</span></li>\
2228 <li><span class="desc"><input type="checkbox" id="lstockmarket"> Stock Market</span></li>\
2229 <li><span class="desc"><input type="checkbox" id="lpoker"> Poker</span></li>\
2230 <li><span class="desc"><input type="checkbox" id="lbookies"> Bookies</span></li>\
2231 <li><span class="desc"><input type="checkbox" id="lrroulette"> Russian Roulette</span></li>\
2232 <li><span class="desc"><input type="checkbox" id="lwheels"> Spin the Wheel</span></li>\
2233 <!--<li><input type="checkbox" id="lstocks"> Stocks in Hospital</li>\
2234 <li><span class="desc"><input type="checkbox" id="lnotepad"> Notepad in Hospital</li>-->\
2235 <li><span class="desc"><input type="checkbox" id="lbounties"> Bounties</span></li>\
2236 <li><span class="desc"><input type="checkbox" id= "useTravAg" name="tipoViag"> Travel Agency</span></li>\
2237 <li><span class="desc"><input type="checkbox" id= "lvault" name="lvault"> Vault</span></li>\
2238 </ul></div></div></div><!-- se retirar este ultimo div ele passa para o lado direito!!!-->\
2239 <div class="sortable-box t-blue-cont h"><div class="title-black top-round active"><div class="arrow-wrap"></div>Shortcuts</div><div style="display: block;" class="bottom-round"><div class="cont-gray bottom-round"><ul class="info-cont-wrap">\
2240 <li><span class="desc">Ex: Name: Notepad Link: notebook.php</span></li>\
2241 <li></li>\
2242 <li></li>\
2243 <li><span class="desc"><div class="inputs-wrap"><input class="count m-top10" type="checkbox" id="lactivo1"> <input type="text" id="nomeL1" size="10"> \
2244 <input type="text" id="link1" size="35"></div></span></li>\
2245<li><span class="desc"><input type="checkbox" id="lactivo2"> <input type="text" id="nomeL2" size="10"> \
2246 <input type="text" id="link2" size="35"></span></li>\
2247<li><span class="desc"><input type="checkbox" id="lactivo3"> <input type="text" id="nomeL3" size="10"> \
2248 <input type="text" id="link3" size="35"></span></li>\
2249<li><span class="desc"><input type="checkbox" id="lactivo4"> <input type="text" id="nomeL4" size="10"> \
2250 <input type="text" id="link4" size="35"></span></li>\
2251<li><span class="desc"><input type="checkbox" id="lactivo5"> <input type="text" id="nomeL5" size="10"> \
2252 <input type="text" id="link5" size="35"></span></li>\
2253 </ul></div></div></div>\
2254 <div class="sortable-box t-blue-cont h"><div class="title-black top-round active"><div class="arrow-wrap"></div>Warbase</div><div style="display: block;" class="bottom-round"><div class="cont-gray bottom-round"><ul class="info-cont-wrap">\
2255 <li><span class="desc"><input type="checkbox" id="hideOff"> Hide Offline Enemies</span></li>\
2256 <li><span class="desc"><input type="checkbox" id="hideTravel"> Hide Travelling/Fed Jailed/Fallen Enemies</span></li>\
2257 <li><span class="desc"><input type="checkbox" id="hideHosped"> Hide Hosped Enemies</span></li>\
2258 <li><span class="desc"><input type="checkbox" id="hideFactionList"> Apply this settings also in other faction member list</span></li>\
2259 <li><span class="desc" title="Adds an extra chain counter on top of page, it is updated when you leave your mouse over it for 2 seconds"><input type="checkbox" id="extrachainbar"> Add Extra chain counter</span></li>\
2260 <li><span class="desc"><input type="checkbox" id="chainAlert"> Chain alert at <select id="chainAlert_time"><option value="03:00">03:00</option><option value="02:30">02:30</option><option value="02:00">02:00</option><option value="01:30">01:30</option><option value="01:00">01:00</option></select></span></li>\
2261 </ul></div></div></div>\
2262 </div>\
2263 <div class="sortable-list right ui-sortable" id="column0">\
2264 <div class="sortable-box t-blue-cont h"><div class="title-black top-round active"><div class="arrow-wrap"></div>Latest Version ' + versao + '</div><div style="display: block;" class="bottom-round"><div class="cont-gray10 bottom-round"><ul class="info-cont-wrap">\
2265 <li><div class="btn-wrap silver"><div class="btn"><input type="submit" id="checkUpdate" class="c-pointer update" value="Check for Update"></div></div></li>\
2266 <li class="last" style="line-height: 1.35;">Script build by <a href="profiles.php?XID=51498">MaGnO[51498]</a>. No need for a donation, just suggestions are welcome!</li>\
2267 </ul></div></div></div>\
2268 <div class="sortable-box t-blue-cont h"><div class="title-black top-round active"><div class="arrow-wrap"></div>Hide Icons</div><div style="display: block;" class="bottom-round">\
2269 <div style="float:left; width:193px;" class="cont-gray bottom-round"><ul class="info-cont-wrap">\
2270 <li><span class="desc"><input type="checkbox" id="osex"> Sex</span></li>\
2271 <li><span class="desc"><input type="checkbox" id="odonator"> Donator/Subscriber</span></li>\
2272 <li><span class="desc"><input type="checkbox" id="omarried"> Married To</span></li>\
2273 <li><span class="desc"><input type="checkbox" id="ojob"> Job/Company</span></li>\
2274 <li><span class="desc"><input type="checkbox" id="ofaction"> Faction</span></li>\
2275 <li><span class="desc"><input type="checkbox" id="obank"> Bank</span></li>\
2276 <li><span class="desc"><input type="checkbox" id="ostock"> Stock Market</span></li>\
2277 <li><span class="desc"><input type="checkbox" id="oeduc"> Education</span></li>\
2278 <li><span class="desc"><input type="checkbox" id="obooster"> Booster Cooldown</span></li>\
2279 <li><span class="desc"><input type="checkbox" id="omedical"> Medical Cooldown</span></li>\
2280 <li><span class="desc"><input type="checkbox" id="odrug"> Drug Cooldown</span></li>\
2281 <li><span class="desc"><input type="checkbox" id="olevel100"> Level 100</span></li>\
2282 </ul></div>\
2283 <div style="float:right; width:193px;" class="cont-gray bottom-round">\
2284 <ul class="info-cont-wrap">\
2285 <li><span class="desc"><input type="checkbox" id="otrade"> Trades</span></li>\
2286 <li><span class="desc"><input type="checkbox" id="orace"> Race</span></li>\
2287 <li><span class="desc"><input type="checkbox" id="oitem"> Items in bazaar/auction/market</span></li>\
2288 <li><span class="desc"><input type="checkbox" id="opoints"> Points</span></li>\
2289 <li><span class="desc"><input type="checkbox" id="oloan"> Loan</span></li>\
2290 <li><span class="desc"><input type="checkbox" id="obounty"> Bounty</span></li>\
2291 <li><span class="desc"><input type="checkbox" id="obookie"> Bookie Collection</span></li>\
2292 <li><span class="desc"><input type="checkbox" id="ohosp"> Hospital</span></li>\
2293 <li><span class="desc"><input type="checkbox" id="ojail"> Jail</span></li>\
2294 <li><span class="desc"><input type="checkbox" id="ollife"> Low Life</span></li>\
2295 <li><span class="desc"><input type="checkbox" id="obook"> Books</span></li>\
2296 <li><span class="desc" style="height:16px;"></span></li>\
2297 </ul></div>\
2298 <div style="clear:both;"></div>\
2299 </div></div>\
2300 <div class="sortable-box t-blue-cont h"><div class="title-black top-round active"><div class="arrow-wrap"></div>Remove Links from Sidebar</div><div style="display: block;" class="bottom-round">\
2301 <div style="float:left; width:193px;" class="cont-gray bottom-round">\
2302 <ul class="info-cont-wrap">\
2303 <li><span class="desc"><input type="checkbox" id="rhome"> Home</span></li>\
2304 <li><span class="desc"><input type="checkbox" id="ritems"> Items</span></li>\
2305 <li><span class="desc"><input type="checkbox" id="rcity"> City</span></li>\
2306 <li><span class="desc"><input type="checkbox" id="rjob"> Job</span></li>\
2307 <li><span class="desc"><input type="checkbox" id="rgym"> Gym</span></li>\
2308 <li><span class="desc"><input type="checkbox" id="rproperties"> Properties</span></li>\
2309 <li><span class="desc"><input type="checkbox" id="reducation"> Education</span></li>\
2310 <li><span class="desc"><input type="checkbox" id="rcrimes"> Crimes</span></li>\
2311 <li><span class="desc"><input type="checkbox" id="rmissions"> Missions</span></li>\
2312 </ul></div>\
2313 <div style="float:right; width:193px;" class="cont-gray bottom-round">\
2314 <ul class="info-cont-wrap">\
2315 <li><span class="desc"><input type="checkbox" id="rnewspaper"> Newspaper</span></li>\
2316 <li><span class="desc"><input type="checkbox" id="rjail"> Jail</span></li>\
2317 <li><span class="desc"><input type="checkbox" id="rhospital"> Hospital</span></li>\
2318 <li><span class="desc"><input type="checkbox" id="rcasino"> Casino</span></li>\
2319 <li><span class="desc"><input type="checkbox" id="rforums"> Forums</span></li>\
2320 <li><span class="desc"><input type="checkbox" id="rhof"> Hall of Fame</span></li>\
2321 <li><span class="desc"><input type="checkbox" id="rfaction"> My Faction</span></li>\
2322 <li><span class="desc"><input type="checkbox" id="rcitizens"> Recruit Citizens</span></li>\
2323 <li><span class="desc"><input type="checkbox" id="rrules"> Rules</span></li>\
2324 </ul></div>\
2325 <div style="clear:both;"></div></div>\
2326 </div>\
2327 <div class="sortable-box t-blue-cont h"><div class="title-black top-round active"><div class="arrow-wrap"></div>Personal Stats (activate on main options)</div><div style="display: block;" class="bottom-round">\
2328 <div style="float:left; width:193px;" class="cont-gray bottom-round">\
2329 <ul class="info-cont-wrap">\
2330 <li><span class="desc"><input type="checkbox" id="psattackswon"> Attacks Won</span></li>\
2331 <li><span class="desc"><input type="checkbox" id="psdefendswon"> Defends Won</span></li>\
2332 <li><span class="desc"><input type="checkbox" id="psmoneymugged"> Money Mugged</span></li>\
2333 <li><span class="desc"><input type="checkbox" id="pshighestlevel"> Highest Level Beaten</span></li>\
2334 <li><span class="desc"><input type="checkbox" id="pskillstreak"> Best Kill Streak</span></li>\
2335 <li><span class="desc"><input type="checkbox" id="pstotalrespect"> Total Respect Gained</span></li>\
2336 <li><span class="desc"><input type="checkbox" id="pspeoplebusted"> People Busted</span></li>\
2337 <li><span class="desc"><input type="checkbox" id="pspeoplebailed"> People Bailed</span></li>\
2338 <li><span class="desc"><input type="checkbox" id="pscriminaloffences"> Criminal Offences</span></li>\
2339 <li><span class="desc"><input type="checkbox" id="pstimestravelled"> Times Travelled</span></li>\
2340 <li><span class="desc"><input type="checkbox" id="psrevives"> People Revived</span></li>\
2341 <li><span class="desc"><input type="checkbox" id="psbloodwithdrawn"> Blood withdrawn</span></li>\
2342 <li><span class="desc"><input type="checkbox" id="psbooksread"> Books Read</span></li>\
2343 </ul></div>\
2344 <div style="float:right; width:193px;" class="cont-gray bottom-round">\
2345 <ul class="info-cont-wrap">\
2346 <li><span class="desc"><input type="checkbox" id="psecstasy"> Ecstasy Taken</span></li>\
2347 <li><span class="desc"><input type="checkbox" id="psxanax"> Xanax Taken</span></li>\
2348 <li><span class="desc"><input type="checkbox" id="psvicodin"> Vicodin Taken</span></li>\
2349 <li><span class="desc"><input type="checkbox" id="pslsd"> LSD Taken</span></li>\
2350 <li><span class="desc"><input type="checkbox" id="psmissioncredits"> Mission Credits Earned</span></li>\
2351 <li><span class="desc"><input type="checkbox" id="psnetworth"> Networth</span></li>\
2352 <li><span class="desc"><input type="checkbox" id="pslogins"> Logins</span></li>\
2353 <li><span class="desc"><input type="checkbox" id="psreffils"> Energy Reffils</span></li>\
2354 <li><span class="desc"><input type="checkbox" id="psenhancers"> Stat Enhancers Used</span></li>\
2355 <li><span class="desc"><input type="checkbox" id="psdonator"> Days Been Donator</span></li>\
2356 <li><span class="desc"><input type="checkbox" id="pscandyeaten"> Candy Eaten</span></li>\
2357 <li><span class="desc"><input type="checkbox" id="psalcohol"> Alcohol Drunk</span></li>\
2358 <li><span class="desc"><input type="checkbox" id="psdrinks"> Energy Drinks Drunk</span></li>\
2359 </ul></div>\
2360 <div style="clear:both;"></div></div>\
2361 </div>\
2362 \
2363 <div class="sortable-box t-blue-cont h"><div class="title-black top-round active"><div class="arrow-wrap"></div>Show only this crimes:</div><div style="display: block;" class="bottom-round">\
2364 <div style="float:left; width:193px;" class="cont-gray bottom-round">\
2365 <ul class="info-cont-wrap">\
2366 <li><span class="desc"><input type="checkbox" id="crime2"> Search for Cash (-2)</span></li>\
2367 <li><span class="desc"><input type="checkbox" id="crime3"> Sell Copied Media (-3)</span></li>\
2368 <li><span class="desc"><input type="checkbox" id="crime4"> Shoplift (-4)</span></li>\
2369 <li><span class="desc"><input type="checkbox" id="crime5"> Pickpocket (-5)</span></li>\
2370 <li><span class="desc"><input type="checkbox" id="crime6"> Larceny (-6)</span></li>\
2371 <li><span class="desc"><input type="checkbox" id="crime7"> Armed Robberies (-7)</span></li>\
2372 <li><span class="desc"><input type="checkbox" id="crime8"> Transport Drugs (-8)</span></li>\
2373 <li><span class="desc"><input type="checkbox" id="crime9"> Plant Virus (-9)</span></li>\
2374 <li><span class="desc"><input type="checkbox" id="crime10"> Assassination (-10)</span></li>\
2375 </ul></div>\
2376 <div style="float:right; width:193px;" class="cont-gray bottom-round">\
2377 <ul class="info-cont-wrap">\
2378 <li><span class="desc"><input type="checkbox" id="crime11"> Arson (-11)</span></li>\
2379 <li><span class="desc"><input type="checkbox" id="crime12"> Grand Theft Auto (-12)</span></li>\
2380 <li><span class="desc"><input type="checkbox" id="crime13"> Pawn Shop (-13)</span></li>\
2381 <li><span class="desc"><input type="checkbox" id="crime14"> Counterfeiting (-14)</span></li>\
2382 <li><span class="desc"><input type="checkbox" id="crime15"> Kidnapping (-15)</span></li>\
2383 <li><span class="desc"><input type="checkbox" id="crime16"> Arms Trafficking (-16)</span></li>\
2384 <li><span class="desc"><input type="checkbox" id="crime17"> Bombings (-17)</span></li>\
2385 <li><span class="desc"><input type="checkbox" id="crime18"> Hacking (-18)</span></li>\
2386 <li><span class="desc" style="height:16px;"></span></li>\
2387 </ul></div>\
2388 <div style="clear:both;"></div></div>\
2389 </div>\
2390 \
2391 </div></div>\
2392 </div></div>');
2393
2394 $('#tab-menu').append("<style>.d .sortable-list .info-cont-wrap .desc { overflow: visible; }</style>");
2395
2396
2397 var elem;
2398 $("#holderMode").prop('checked', (holderMode == '1' ? true : false) ).click(fxchkb);
2399 $("#removerBounties").prop('checked', (removerBounties == '1' ? true : false) ).click(fxchkb);
2400 $("#resprecos").prop('checked', (resumoprecosb == '1' ? true : false) ).click(fxchkb);
2401 $("#flowerdrugprice").prop('checked', (flowerdrugprice == '1' ? true : false) ).click(fxchkb);
2402 $("#percStats").prop('checked', (percStats == '1' ? true : false) ).click(fxchkb);
2403 $("#effstats").prop('checked', (effstats == '1' ? true : false)).click(fxchkb);
2404 $("#crimeMerits").prop('checked', (crimeMerits == '1' ? true : false) ).click(fxchkb);
2405
2406 $("#hidemap").prop('checked', (hidemap == '1' ? true : false) ).click(fxchkb);
2407 $("#flowerprices").prop('checked', (flowerprices == '1' ? true : false) ).click(fxchkb);
2408 $("#plushieprices").prop('checked', (plushieprices == '1' ? true : false) ).click(fxchkb);
2409 $("#travelrunprices").prop('checked', (travelrunprices == '1' ? true : false) ).click(fxchkb);
2410 $("#sortitems").prop('checked', (sortitems == '1' ? true : false) ).click(fxchkb);
2411 $("#extrachainbar").prop('checked', (extrachainbar == '1' ? true : false) ).click(fxchkb);
2412 $("#personalstats").prop('checked', (personalstats == '1' ? true : false) ).click(fxchkb);
2413 $("#removecrimes").prop('checked', (removecrimes == '1' ? true : false) ).click(fxchkb);
2414 $("#redirectgym").prop('checked', (redirectgym == '1' ? true : false) ).click(fxchkb);
2415 $("#removeborders").prop('checked', (removeborders == '1' ? true : false) ).click(fxchkb);
2416 $("#positioncounter").prop('checked', (positioncounter == '1' ? true : false) ).click(fxchkb);
2417 $("#expressbust").prop('checked', (expressbust == '1' ? true : false) ).click(fxchkb);
2418 $("#alignleft").prop('checked', (alignleft == '1' ? true : false)).click(fxchkb);
2419 $("#factionless").prop('checked', (factionless == '1' ? true : false) ).click(fxchkb);
2420 $("#companyless").prop('checked', (companyless == '1' ? true : false) ).click(fxchkb);
2421 $("#highlightchat").prop('checked', (highlightchat == '1' ? true : false) ).click(fxchkb);
2422 $("#highlightchat_color").find("option[value='" + highlightchat_color + "']").attr("selected", true);
2423 $("#highlightchat_color").change(fxtext);
2424 $("#destacarJail").prop('checked', (destacarJail == '1' ? true : false) ).click(fxchkb);
2425 $("#tagJail").attr('value', tagJail).change(fxtext);
2426 $("#destacarHosp").prop('checked', (destacarHosp == '1' ? true : false) ).click(fxchkb);
2427 $("#tagHosp").attr('value', tagHosp).change(fxtext);
2428 $("#highlightOut").prop('checked', (highlightOut == '1' ? true : false) ).click(fxchkb);
2429 $("#tagOut").attr('value', tagOut).change(fxtext);
2430 $("#time12h").prop('checked', (time12h == '1' ? true : false) ).click(fxradio);
2431 $("#time24h").prop('checked', (time24h == '1' ? true : false) ).click(fxradio);
2432
2433 $("#checkUpdate").click(fxupdate);
2434
2435 $("#lraces").prop('checked', (lraces == '1' ? true : false) ).click(fxchkb);
2436 $("#lstockmarket").prop('checked', (lstockmarket == '1' ? true : false) ).click(fxchkb);
2437 $("#lpoker").prop('checked', (lpoker == '1' ? true : false) ).click(fxchkb);
2438 $("#lbookies").prop('checked', (lbookies == '1' ? true : false) ).click(fxchkb);
2439 $("#lrroulette").prop('checked', (lrroulette == '1' ? true : false) ).click(fxchkb);
2440 $("#lwheels").prop('checked', (lwheels == '1' ? true : false) ).click(fxchkb);
2441 $("#lstocks").prop('checked', (lstocks == '1' ? true : false) ).click(fxchkb);
2442 $("#lnotepad").prop('checked', (lnotepad == '1' ? true : false) ).click(fxchkb);
2443 $("#lbounties").prop('checked', (lbounties == '1' ? true : false) ).click(fxchkb);
2444 $("#sfsstock").prop('checked', (sfsstock == '1' ? true : false) ).click(fxchkb);
2445 $("#useTravAg").prop('checked', (useTravAg == '1' ? true : false) ).click(fxchkb);
2446 $("#lvault").prop('checked', (lvault == '1' ? true : false) ).click(fxchkb);
2447
2448 for(var ii=1; ii <= 5; ii++){
2449 var nome = "lactivo" + ii;
2450 $("#" + nome).prop('checked', ( eval(nome) == '1' ? true : false) ).click(fxchkb);
2451
2452 nome = "nomeL" + ii;
2453 $("#" + nome).attr('value', eval(nome)).change(fxtext);
2454
2455 nome = "link" + ii;
2456 $("#" + nome).attr('value', eval(nome)).change(fxtext);
2457 }
2458
2459 //Warbase Settings
2460 $("#hideOff").prop('checked', (hideOff == '1' ? true : false) ).click(fxchkb);
2461 $("#hideTravel").prop('checked', (hideTravel == '1' ? true : false) ).click(fxchkb);
2462 $("#hideHosped").prop('checked', (hideHosped == '1' ? true : false) ).click(fxchkb);
2463 $("#hideFactionList").prop('checked', (hideFactionList == '1' ? true : false) ).click(fxchkb);
2464 $("#chainAlert").prop('checked', (chainAlert == '1' ? true : false) ).click(fxchkb);
2465 $("#chainAlert_time").find("option[value='" + chainAlert_time + "']").attr("selected", true);
2466 $("#chainAlert_time").change(fxtext);
2467
2468 //Hide Icons
2469 $("#osex").prop('checked', (osex == '1' ? true : false) ).click(fxchkb);
2470 $("#odonator").prop('checked', (odonator == '1' ? true : false) ).click(fxchkb);
2471 $("#omarried").prop('checked', (omarried == '1' ? true : false) ).click(fxchkb);
2472 $("#ojob").prop('checked', (ojob == '1' ? true : false) ).click(fxchkb);
2473 $("#ofaction").prop('checked', (ofaction == '1' ? true : false) ).click(fxchkb);
2474 $("#obank").prop('checked', (obank == '1' ? true : false) ).click(fxchkb);
2475 $("#ostock").prop('checked', (ostock == '1' ? true : false) ).click(fxchkb);
2476 $("#oeduc").prop('checked', (oeduc == '1' ? true : false) ).click(fxchkb);
2477 $("#obooster").prop('checked', (obooster == '1' ? true : false) ).click(fxchkb);
2478 $("#omedical").prop('checked', (omedical == '1' ? true : false) ).click(fxchkb);
2479 $("#odrug").prop('checked', (odrug == '1' ? true : false) ).click(fxchkb);
2480 $("#olevel100").prop('checked', (olevel100 == '1' ? true : false) ).click(fxchkb);
2481 $("#otrade").prop('checked', (otrade == '1' ? true : false) ).click(fxchkb);
2482 $("#orace").prop('checked', (orace == '1' ? true : false) ).click(fxchkb);
2483 $("#oitem").prop('checked', (oitem == '1' ? true : false) ).click(fxchkb);
2484 $("#opoints").prop('checked', (opoints == '1' ? true : false) ).click(fxchkb);
2485 $("#oloan").prop('checked', (oloan == '1' ? true : false) ).click(fxchkb);
2486 $("#obounty").prop('checked', (obounty == '1' ? true : false) ).click(fxchkb);
2487 $("#obookie").prop('checked', (obookie == '1' ? true : false) ).click(fxchkb);
2488 $("#ohosp").prop('checked', (ohosp == '1' ? true : false) ).click(fxchkb);
2489 $("#ojail").prop('checked', (ojail == '1' ? true : false) ).click(fxchkb);
2490 $("#ollife").prop('checked', (ollife == '1' ? true : false) ).click(fxchkb);
2491 $("#obook").prop('checked', (obook == '1' ? true : false) ).click(fxchkb);
2492
2493 //Remove Links
2494 $("#rhome").prop('checked', (rhome == '1' ? true : false) ).click(fxchkb);
2495 $("#ritems").prop('checked', (ritems == '1' ? true : false) ).click(fxchkb);
2496 $("#rcity").prop('checked', (rcity == '1' ? true : false) ).click(fxchkb);
2497 $("#rjob").prop('checked', (rjob == '1' ? true : false) ).click(fxchkb);
2498 $("#rgym").prop('checked', (rgym == '1' ? true : false) ).click(fxchkb);
2499 $("#rproperties").prop('checked', (rproperties == '1' ? true : false) ).click(fxchkb);
2500 $("#reducation").prop('checked', (reducation == '1' ? true : false) ).click(fxchkb);
2501 $("#rcrimes").prop('checked', (rcrimes == '1' ? true : false) ).click(fxchkb);
2502 $("#rmissions").prop('checked', (rmissions == '1' ? true : false) ).click(fxchkb);
2503 $("#rnewspaper").prop('checked', (rnewspaper == '1' ? true : false) ).click(fxchkb);
2504 $("#rjail").prop('checked', (rjail == '1' ? true : false) ).click(fxchkb);
2505 $("#rhospital").prop('checked', (rhospital == '1' ? true : false) ).click(fxchkb);
2506 $("#rcasino").prop('checked', (rcasino == '1' ? true : false) ).click(fxchkb);
2507 $("#rforums").prop('checked', (rforums == '1' ? true : false) ).click(fxchkb);
2508 $("#rhof").prop('checked', (rhof == '1' ? true : false) ).click(fxchkb);
2509 $("#rfaction").prop('checked', (rfaction == '1' ? true : false) ).click(fxchkb);
2510 $("#rcitizens").prop('checked', (rcitizens == '1' ? true : false) ).click(fxchkb);
2511 $("#rrules").prop('checked', (rrules == '1' ? true : false) ).click(fxchkb);
2512
2513 //Personal Stats
2514 $("#psattackswon").prop('checked', (psattackswon == '1' ? true : false) ).click(fxchkb);
2515 $("#psdefendswon").prop('checked', (psdefendswon == '1' ? true : false) ).click(fxchkb);
2516 $("#psmoneymugged").prop('checked', (psmoneymugged == '1' ? true : false) ).click(fxchkb);
2517 $("#pshighestlevel").prop('checked', (pshighestlevel == '1' ? true : false) ).click(fxchkb);
2518 $("#pskillstreak").prop('checked', (pskillstreak == '1' ? true : false) ).click(fxchkb);
2519 $("#pstotalrespect").prop('checked', (pstotalrespect == '1' ? true : false) ).click(fxchkb);
2520 $("#pspeoplebusted").prop('checked', (pspeoplebusted == '1' ? true : false) ).click(fxchkb);
2521 $("#pspeoplebailed").prop('checked', (pspeoplebailed == '1' ? true : false) ).click(fxchkb);
2522 $("#pscriminaloffences").prop('checked', (pscriminaloffences == '1' ? true : false) ).click(fxchkb);
2523 $("#pstimestravelled").prop('checked', (pstimestravelled == '1' ? true : false) ).click(fxchkb);
2524 $("#psrevives").prop('checked', (psrevives == '1' ? true : false) ).click(fxchkb);
2525 $("#psbloodwithdrawn").prop('checked', (psbloodwithdrawn == '1' ? true : false) ).click(fxchkb);
2526 $("#psbooksread").prop('checked', (psbooksread == '1' ? true : false) ).click(fxchkb);
2527 $("#psecstasy").prop('checked', (psecstasy == '1' ? true : false) ).click(fxchkb);
2528 $("#psxanax").prop('checked', (psxanax == '1' ? true : false) ).click(fxchkb);
2529 $("#psvicodin").prop('checked', (psvicodin == '1' ? true : false) ).click(fxchkb);
2530 $("#pslsd").prop('checked', (pslsd == '1' ? true : false) ).click(fxchkb);
2531 $("#psmissioncredits").prop('checked', (psmissioncredits == '1' ? true : false) ).click(fxchkb);
2532 $("#psnetworth").prop('checked', (psnetworth == '1' ? true : false) ).click(fxchkb);
2533 $("#pslogins").prop('checked', (pslogins == '1' ? true : false) ).click(fxchkb);
2534 $("#psreffils").prop('checked', (psreffils == '1' ? true : false) ).click(fxchkb);
2535 $("#psenhancers").prop('checked', (psenhancers == '1' ? true : false) ).click(fxchkb);
2536 $("#psdonator").prop('checked', (psdonator == '1' ? true : false) ).click(fxchkb);
2537 $("#pscandyeaten").prop('checked', (pscandyeaten == '1' ? true : false) ).click(fxchkb);
2538 $("#psalcohol").prop('checked', (psalcohol == '1' ? true : false) ).click(fxchkb);
2539 $("#psdrinks").prop('checked', (psdrinks == '1' ? true : false) ).click(fxchkb);
2540
2541 //Remove Crimes
2542 $("#crime2").prop('checked', (crime2 == '1' ? true : false) ).click(fxchkb);
2543 $("#crime3").prop('checked', (crime3 == '1' ? true : false) ).click(fxchkb);
2544 $("#crime4").prop('checked', (crime4 == '1' ? true : false) ).click(fxchkb);
2545 $("#crime5").prop('checked', (crime5 == '1' ? true : false) ).click(fxchkb);
2546 $("#crime6").prop('checked', (crime6 == '1' ? true : false) ).click(fxchkb);
2547 $("#crime7").prop('checked', (crime7 == '1' ? true : false) ).click(fxchkb);
2548 $("#crime8").prop('checked', (crime8 == '1' ? true : false) ).click(fxchkb);
2549 $("#crime9").prop('checked', (crime9 == '1' ? true : false) ).click(fxchkb);
2550 $("#crime10").prop('checked', (crime10 == '1' ? true : false) ).click(fxchkb);
2551 $("#crime11").prop('checked', (crime11 == '1' ? true : false) ).click(fxchkb);
2552 $("#crime12").prop('checked', (crime12 == '1' ? true : false) ).click(fxchkb);
2553 $("#crime13").prop('checked', (crime13 == '1' ? true : false) ).click(fxchkb);
2554 $("#crime14").prop('checked', (crime14 == '1' ? true : false) ).click(fxchkb);
2555 $("#crime15").prop('checked', (crime15 == '1' ? true : false) ).click(fxchkb);
2556 $("#crime16").prop('checked', (crime16 == '1' ? true : false) ).click(fxchkb);
2557 $("#crime17").prop('checked', (crime17 == '1' ? true : false) ).click(fxchkb);
2558 $("#crime18").prop('checked', (crime18 == '1' ? true : false) ).click(fxchkb);
2559}
2560
2561// funcao para adicionar um link ao menu:
2562// no - elemento anterior ao objecto a adicionar
2563// endereço - string com url
2564// texto - texto do link
2565// nivel - profundidade do link relativamente ao menu
2566// target - atributo target do link
2567function addLink(no, endereco, texto, nivel, target){
2568 var novoLink = document.createElement('a');
2569 var novoLI = document.createElement('div');
2570 var novoDiv = document.createElement('div');
2571
2572 novoLink.setAttribute('href', endereco);
2573
2574 if(target != null)
2575 novoLink.setAttribute('target', target);
2576
2577 novoLink.innerHTML = '<span>' + ' ' + texto+'</span>';
2578
2579 novoDiv.setAttribute('class', row_class);
2580 novoDiv.style.height = "18px";
2581 novoDiv.style.paddingTop = "6px";
2582 novoDiv.appendChild(novoLink);
2583
2584 novoLI.setAttribute('class', link_class);
2585
2586 novoLI.appendChild(novoDiv);
2587
2588 no.parentNode.insertBefore(novoLI, no.nextSibling);
2589
2590 return novoLink;
2591}
2592
2593function requestPage(link, modo, handler){
2594 var httpRequest = new XMLHttpRequest();
2595 httpRequest.onreadystatechange = handler;
2596 httpRequest.open('GET', link, modo);
2597 try{ httpRequest.send(null); } catch(x){ //alert(x);
2598 };
2599 return httpRequest.responseText;
2600}
2601
2602
2603function requestPage2(link){
2604 GM_xmlhttpRequest({
2605 method: "GET",
2606 url: link,
2607 headers: {
2608 'User-agent': 'Mozilla/4.0 (compatible) Greasemonkey/0.3',
2609 'Accept': 'application/atom+xml,application/xml,text/xml',
2610 },
2611 synchronous: false,
2612 onload: function(response) {
2613 return response.responseText;
2614 }
2615 });
2616}
2617
2618function requestAPI(link, api_key, modo, handler){
2619 var requestLink = link + api_key;
2620 var listJSON = requestPage(requestLink, modo, handler);
2621
2622 if(handler == null){
2623 var list = JSON.parse(listJSON);
2624
2625 //{"error":{"code":2,"error":"Incorrect Key"}}
2626 if(list.error != null){
2627 if(list.error.code == '2' || list.error.code == '12'){
2628 //get current API Key
2629 var new_api_key = get_api_key();
2630 set_api_key(new_api_key);
2631 list = requestAPI(link, new_api_key);
2632 }
2633 }
2634 return list;
2635 }
2636
2637}
2638
2639function fmtperc(x) {
2640 var y = x * 10000;
2641 y = Math.floor(y + 0.5) + 0.5;
2642 y /= 100;
2643 y += 0.00001;
2644 var yy = y.toString();
2645 var dotpos = yy.indexOf('.');
2646 return yy.substr(0, dotpos + 3);
2647}
2648
2649function get_api_key(){
2650 var preferencesPage = $(requestPage('preferences.php'));
2651 return preferencesPage.find('#newapi').val();
2652}
2653
2654function set_api_key(key){
2655 api_key = key;
2656 GM_setValue('api_key', key);
2657}
2658///
2659
2660//Fix table borders
2661if( removeborders == '1'){
2662 $("<style>")
2663 .attr("type", "text/css")
2664 .html("\
2665 .d .sortable-list .info-cont-wrap li { padding: 2px 0px; border: 0px; }\
2666 .d .sortable-list .info-cont-wrap .divider { border: 0px; }\
2667 .d .sortable-list .battle .info-cont-wrap .desc { border: 0px; }\
2668 ")
2669 .appendTo("head");
2670
2671 $("body").append("<style>.d .profile-wrapper .profile-container.basic-info ul.basic-list li, .d .profile-wrapper .profile-container.personal-info ul li {padding: 2px 0px;border: 0px;}.d .profile-wrapper .user-information-section{ border: 0px;}</style>");
2672}
2673
2674//Add total money in bazaar
2675function showBazaarTotal(){
2676 if($("#totalItems").length == 0) {
2677 $(".bazaar-page-wrap.bazaar-main-wrap").prepend("<div id='totalItems'></div>");
2678 }
2679 var totalItems = 0;
2680 $("ul.items-list li:not(.empty)").each(function() {
2681 var price = $(this).find(".price").html();
2682 if(price != null){
2683 price = parseInt(price.replace(/(\$|,)/g, ''));
2684 var quantity = parseInt($(this).find(".instock").html().replace(/,/g, ''));
2685 totalItems += price*quantity;
2686 }
2687 });
2688 $("#totalItems").html("<div class='border-round' style='background-color: #f2f2f2; padding:5px; width: 250px; font-size:1.1em;'><b>Total Value:</b> <span style='color: #678c00;'>$"+fmtNumber(totalItems)+"</span></div>");
2689}
2690
2691if(document.location.href.match(/\/bazaar.php/) ){
2692 waitForKeyElements(".items-list", showBazaarTotal);
2693}
2694
2695//Add total items and worth in display
2696function showDisplayTotal(){
2697 var totalItems = 0;
2698 $("ul.display-cabinet li").each(function() {
2699 var quantity = ($(this).find(".b-item-amount").html());
2700 if(quantity != null){
2701 quantity = parseInt(quantity.replace('x', ''));
2702 totalItems += quantity;
2703 }
2704
2705 });
2706
2707 if($(".delimiter > .msg").length == 0){
2708 var apiResponse = requestAPI('//api.torn.com/user/?selections=networth&key=', api_key);
2709 $(".display-main-page").prepend('<div class="info-msg-cont border-round m-top10 r2996"><div class="info-msg border-round"><i class="info-icon"></i><div class="delimiter"><div class="msg right-round"><div>Total of <b>'+fmtNumber(totalItems)+'</b> items with an estimated value of <span class="t-green"><b>$'+fmtNumber(apiResponse.networth.displaycase)+'</b></span></div></div></div></div></div>');
2710 }else{
2711 var apiResponse = requestAPI('//api.torn.com/user/?selections=networth&key=', api_key);
2712 $(".delimiter > .msg").append('<div>Total of <b>'+fmtNumber(totalItems)+'</b> items with an estimated value of <span class="t-green"><b>$'+fmtNumber(apiResponse.networth.displaycase)+'</b></span></div>');
2713 //$(".delimiter > .msg").append("<div>There is a total of <b>"+fmtNumber(totalItems)+"</b> items</div>");
2714 }
2715
2716}
2717
2718if(document.location.href.match(/\/displaycase.php/)){
2719 waitForKeyElements("ul.display-cabinet > li.clear", showDisplayTotal);
2720}
2721
2722//Add position counter in companies (Tkx to Pidu)
2723function unique(array){
2724 return array.filter(function(el, index, arr) {
2725 return index === arr.indexOf(el);
2726 });
2727}
2728
2729function createEmployeesRatio(jNode){
2730 var elementsToParse = $(jNode).find(".rank.t-overflow");
2731 var jobsArray = new Array();
2732 $(elementsToParse).each(function(){
2733 jobsArray.push($(this).html().replace('<span class="t-show bold">Rank:</span> ','').replace(/[^a-zA-Z0-9\s]/g, '') .replace(/^\s+|\s+$/, '').replace(/\s+/g, ''));
2734 });
2735 var jobsUniqueArray = unique(jobsArray);
2736 var finalArray = new Array();
2737
2738 $(jobsUniqueArray).each(function(){
2739 var positionToAttach = {};
2740 positionToAttach["position"] = this.toString();
2741 positionToAttach["count"] = jobsArray.toString().match(new RegExp(this.toString(), 'g')).length;
2742 finalArray.push(positionToAttach);
2743 });
2744
2745 $(".employees-wrap").append('<hr class="delimiter-999 m-top10 m-bottom10">');
2746 var newBox = $('<div class="title-black top-round"><ul class="title"><li style="width: 300px;">Job Title</li><li style="width: 150px; padding-left: 10px; border-left: 2px solid #CCC;">Total ('+jobsArray.length+')</li><li style="width: 150px;padding-left: 10px; border-left: 2px solid #CCC;">Percentage (aprox.)</li><li class="clear"></li></ul></div>');
2747 $(".employees-wrap").append(newBox);
2748 $(".employees-wrap").append( '<ul id="table2" class="employees-list cont-gray bottom-round"></ul>' );
2749 $(finalArray).each(function(i, val){
2750 var percentage = parseFloat(Math.round((val.count)/(jobsArray.length)*100));
2751 $("#table2").append( $('<li><ul class="item"><li style="width: 300px; padding-left: 10px;">'+val.position+'</li><li style="width: 150px; padding-left: 10px; border-left: 2px solid #CCC;">'+val.count+'</li><li style="width: 150px; padding-left: 10px; border-left: 2px solid #CCC;">'+percentage+'%</li><div class="clear"></div></ul></li>') );
2752 });
2753}
2754
2755if(positioncounter == '1'){
2756 if(document.location.href.match(/\/joblist.php\#(\/|!)p=corpinfo/) ){
2757 waitForKeyElements(".employees-wrap", createEmployeesRatio);
2758 }
2759}
2760
2761// Add more links in attack logs (by Destroys)
2762/*if(document.location.href.match(/\/loader.php\?sid\=attackLog/)){
2763 //alert('ja');
2764 $("a.back.t-clear.h.c-pointer.m-icon").each(function(){
2765 //console.log($(this).text());
2766 //<span class="area-desktop___29MUo right"> <a href="/blacklist.php"> <i class="enemies-icon___TGyKF icon___3LLDF"> </i> <span>Enemies</span> </a> </span>
2767 $(this).before($("<a></a>").attr('href', 'blacklist.php').text('Blacklist').addClass('t-clear h c-pointer m-icon line-h24 right'));
2768
2769 console.log($('span.attacking-events-attack-join').length);
2770 alert($('span.attacking-events-attack-join').first().next().text());
2771
2772
2773 });
2774 }*/
2775
2776//Adds some more statistics to bookies
2777if(document.location.href.match(/\/bookies.php/) ){
2778 waitForKeyElements("#your-stats", bookie_statistics);
2779
2780 waitForKeyElements(".bookie-date-boxes ul.poplist>li", bookie_bet);
2781}
2782
2783function bookie_bet(jNode){
2784 console.log('entrou');
2785 console.log($(jNode).html());
2786}
2787
2788function bookie_statistics(jNode){
2789 var money_won = 0, money_lost = 0, bets_made = 0, bets_won = 0;
2790 var removed = 0;
2791 var nodeInsert, color;
2792 $(jNode).find("ul.cont-gray > li").each(function(){
2793 var stat_node = $(this).find("li.stat:first");
2794 var stat_value_node = $(this).find("li.stat-value:first");
2795 var stat_value = stat_value_node.text().replace(/[^0-9.]/g, '') * 1;
2796 var won_perc;
2797
2798 if(stat_node.text().match(/Bets made/)){
2799 bets_made = stat_value;
2800 }
2801
2802 if(stat_node.text().match(/Bets won/)){
2803 won_perc = Math.round(10000 * stat_value/bets_made) / 100;
2804 stat_value_node.append("<span> (" + won_perc + "%)</span>");
2805 }
2806
2807 if(stat_node.text().match(/Bets lost/)){
2808 won_perc = Math.round(10000 * stat_value/bets_made) / 100;
2809 stat_value_node.append("<span> (" + won_perc + "%)</span>");
2810 }
2811
2812 if(stat_node.text().match(/Bets refunded/)){
2813 won_perc = Math.round(10000 * stat_value/bets_made) / 100;
2814 stat_value_node.append("<span> (" + won_perc + "%)</span>");
2815 }
2816
2817 if(stat_node.text().match(/Total money won/)){
2818 money_won = stat_value;
2819 }
2820 if(stat_node.text().match(/Total money lost/)){
2821 money_lost = stat_value;
2822 nodeInsert = stat_node.parent().parent();
2823 }
2824 if(stat_node.text() == '' && removed == 0){
2825 stat_node.parent().parent().remove();
2826 removed = 1;
2827 }
2828 });
2829
2830 if(money_won - money_lost > 0){
2831 color = 'green';
2832 }else color = 'red';
2833
2834 nodeInsert.append("<li><ul class='item'><li class='stat'>Profit<span class='m-show'>:</span></li><li class='stat-value'><b><font color='" + color + "'>" +
2835 formatCurrency(money_won - money_lost) + "</font></b></li><li class='clear'></li></ul></li>");
2836}
2837
2838
2839//Adds an audible alert for chains
2840const a=new AudioContext() // browsers limit the number of concurrent audio contexts, so you better re-use'em
2841var intervalID;
2842
2843function beep(vol, freq, duration){
2844 const v=a.createOscillator();
2845 const u=a.createGain();
2846 v.connect(u);
2847 v.frequency.value=freq;
2848 v.type="square";
2849 u.connect(a.destination);
2850 u.gain.value=vol*0.01;
2851 v.start(a.currentTime);
2852 v.stop(a.currentTime+duration*0.001);
2853}
2854
2855function convertk(number){
2856 if(number.indexOf('k') > -1){
2857 number = parseFloat(number) * 1000;
2858 }
2859 return number;
2860}
2861
2862function checkChainTimer(){
2863 if($("#barChain").length){
2864 const currentChainMax = convertk($("#barChain").find("p[class^='bar-value']").text().split('/')[1]);
2865 const currentTime = $("#barChain").find("p:last").text();
2866 if(currentChainMax > 10 && currentTime < chainAlert_time){
2867 beep(100, 520, 200);
2868 }
2869 if(currentTime == '00:00'){
2870 clearInterval(intervalID);
2871 }
2872 }
2873}
2874
2875if(chainAlert == '1'){
2876 intervalID = window.setInterval(function(){ checkChainTimer() }, 10000);
2877}
2878
2879// PARA UASR LINK COM SOM
2880function playSound(url) {
2881 var a = new Audio(url);
2882 a.play();
2883}
2884
2885
2886// Search filter
2887function searchFilter(jNode){
2888 $(jNode).each(function(){
2889 if(($(this).find("li#icon9").length || $(this).find("li#icon74").length ) && factionless == '1'){
2890 $(this).remove();
2891 }
2892
2893 if(($(this).find("li#icon73").length || $(this).find("li#icon27").length ) && companyless == '1'){
2894 $(this).remove();
2895 }
2896 });
2897}
2898
2899if(document.location.href.match(/\/userlist.php\?/) ){
2900 if(factionless == '1' || companyless == '1'){
2901 waitForKeyElements("ul.user-info-list-wrap > li:not(.last)", searchFilter);
2902 }
2903}