Advertisement
Guest User

Untitled

a guest
Nov 15th, 2017
682
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 196.98 KB | None | 0 0
  1. /*
  2. * Copyright (c) 2007-2017 OmertaBeyond Dev Team
  3. *
  4. * OmertaBeyond is free software: you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation, either version 3 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * OmertaBeyond is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with OmertaBeyond. If not, see <http://www.gnu.org/licenses/>.
  16. *
  17. */
  18.  
  19. // ==UserScript==
  20. // @name Omerta Beyond
  21. // @id Omerta Beyond
  22. // @version 2.2.3
  23. // @date 06-10-2017
  24. // @description Omerta Beyond 2.2 (We're back to reclaim the throne ;))
  25. // @homepageURL https://www.omertabeyond.net/
  26. // @namespace v4.omertabeyond.com
  27. // @updateURL https://raw.githubusercontent.com/OmertaBeyond/OBv2/master/ob.meta.js
  28. // @supportURL https://github.com/OmertaBeyond/OBv2/issues
  29. // @icon https://raw.githubusercontent.com/OmertaBeyond/OBv2/master/images/logo.small.png
  30. // @screenshot https://raw.githubusercontent.com/OmertaBeyond/OBv2/master/images/logo.small.png
  31. // @author OBDev Team <info@omertabeyond.com>
  32. // @author vBm <vbm@omertabeyond.com>
  33. // @author Dopedog <dopedog@omertabeyond.com>
  34. // @author Rix <rix@omertabeyond.com>
  35. // @author MrWhite <mrwhite@omertabeyond.com>
  36. // @author MurderInc <murderinc@omertabeyond.com>
  37. // @author Sebbe <sebbe@omertabeyond.com>
  38. // @author Brainscrewer <brainscrewer@omertabeyond.com>
  39. // @author semitom <tom.gankema@gmail.com>
  40. // @license GNU General Public License v3
  41. // @contributionURL https://www.patreon.com/bePatron?u=7718354
  42. // @contributionAmount $1.00
  43. // @encoding UTF-8
  44. // @priority 1
  45. // @require https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js
  46. // @require https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.2/jquery-ui.min.js
  47. // @require https://cdnjs.cloudflare.com/ajax/libs/howler/2.0.4/howler.min.js
  48. // @include http://*.barafranca.com/*
  49. // @include https://*.barafranca.com/*
  50. // @include http://barafranca.com/*
  51. // @include https://barafranca.com/*
  52. // @include http://*.barafranca.nl/*
  53. // @include https://*.barafranca.nl/*
  54. // @include http://barafranca.nl/*
  55. // @include https://barafranca.nl/*
  56. // @include http://*.barafranca.us/*
  57. // @include https://*.barafranca.us/*
  58. // @include http://barafranca.us/*
  59. // @include https://barafranca.us/*
  60. // @include http://*.barafranca.gen.tr/*
  61. // @include https://*.barafranca.gen.tr/*
  62. // @include http://barafranca.gen.tr/*
  63. // @include https://barafranca.gen.tr/*
  64. // @include http://omerta.com.tr/*
  65. // @include https://omerta.com.tr/*
  66. // @include http://*.omerta.com.tr/*
  67. // @include https://*.omerta.com.tr/*
  68. // @include http://*.omerta.dm/*
  69. // @include https://*.omerta.dm/*
  70. // @include http://omerta.dm/*
  71. // @include https://omerta.dm/*
  72. // @include http://*.omerta.pt/*
  73. // @include https://*.omerta.pt/*
  74. // @include http://omerta.pt/*
  75. // @include https://omerta.pt/*
  76. // @include https://*.omerta.land*
  77. // @exclude http://*/game-register.php*
  78. // @exclude https://*/game-register.php*
  79. // @grant GM_xmlhttpRequest
  80. // @grant GM.xmlHttpRequest
  81. // @grant unsafeWindow
  82. // @connect gm.omertabeyond.net
  83. // @connect self
  84. // ==/UserScript==
  85. // ==OpenUserJS==
  86. // @author vBm
  87. // @collaborator Gwildor
  88. // @collaborator MurderInc
  89. // @collaborator Sebbe
  90. // @collaborator Brainscrewer
  91. // @collaborator Ivdbroek85
  92. // ==/OpenUserJS==
  93.  
  94. /*
  95. * Define constants for our website
  96. */
  97.  
  98. var OB_API_WEBSITE = 'https://gm.omertabeyond.net';
  99. var OB_API_NEW_WEBSITE = 'https://api.omertabeyond.net';
  100. var OB_NEWS_WEBSITE = 'https://news.omertabeyond.net';
  101. var OB_RIX_WEBSITE = 'https://rix.omertabeyond.net';
  102. var OB_CDN_URL = 'https://d1oi19aitxwcck.cloudfront.net';
  103. var OB_VERSION = '2.2.3';
  104.  
  105. /*
  106. * Define crucial functions and variables
  107. */
  108.  
  109. // Greasemonkey 4+ compatibility
  110. if (typeof unsafeWindow == 'undefined' && typeof window.wrappedJSObject != 'undefined') {
  111. unsafeWindow = window.wrappedJSObject;
  112. }
  113.  
  114. function whatV(hostname) {
  115. hostname = hostname || window.location.hostname;
  116. if (/(.*).omerta.land$/.test(hostname)) {
  117. return 'dev';
  118. }
  119.  
  120. switch (hostname) {
  121. case 'www.omerta3.com':
  122. case 'omerta3.com':
  123. case 'www.barafranca.com':
  124. case 'barafranca.com':
  125. case 'www.barafranca.us':
  126. case 'barafranca.us':
  127. return 'com';
  128. case 'omerta.dm':
  129. case 'www.omerta.dm':
  130. return 'dm';
  131. case 'www.barafranca.nl':
  132. case 'barafranca.nl':
  133. return 'nl';
  134. case 'www.omerta.com.tr':
  135. case 'omerta.com.tr':
  136. return 'tr';
  137. case 'omerta.pt':
  138. case 'www.omerta.pt':
  139. return 'pt';
  140. default:
  141. return undefined;
  142. }
  143. }
  144.  
  145. var v = whatV();
  146. var ranks = ['Empty-suit', 'Delivery Boy', 'Delivery Girl', 'Picciotto', 'Shoplifter', 'Pickpocket', 'Thief', 'Associate', 'Mobster', 'Soldier', 'Swindler', 'Assassin', 'Local Chief', 'Chief', 'Bruglione', 'Capodecina', 'Godfather', 'First Lady'];
  147. var cities = ['Detroit', 'Chicago', 'Palermo', 'New York', 'Las Vegas', 'Philadelphia', 'Baltimore', 'Corleone'];
  148.  
  149. function randomString(length) {
  150. var charset = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
  151. var result = '';
  152. if (window.crypto && window.crypto.getRandomValues) {
  153. values = new Uint32Array(length);
  154. window.crypto.getRandomValues(values);
  155. for (var i = 0; i < length; i++) {
  156. result += charset[values[i] % charset.length];
  157. }
  158. return result;
  159. }
  160. for (var i = 0; i < length; i++) {
  161. result += charset[Math.floor(Math.random() * charset.length)];
  162. }
  163. return result;
  164. }
  165.  
  166. if (localStorage.getItem('ob_uid') === null) {
  167. localStorage.setItem('ob_uid', randomString(9));
  168. }
  169.  
  170. window.addEventListener('error', function(e) {
  171. $.post(OB_API_WEBSITE + '/?p=jserror', {
  172. message: e.message,
  173. stack: (e.error !== null ? e.error.stack : null),
  174. filename: e.filename,
  175. line: e.lineno,
  176. game_version: v,
  177. ob_version: OB_VERSION,
  178. ob_uid: localStorage.getItem('ob_uid')
  179. });
  180. });
  181.  
  182. /*
  183. * Settings helpers
  184. */
  185.  
  186. function getV(name, standard) {
  187. return (localStorage[name + '_' + v] || standard);
  188. }
  189.  
  190. function setV(name, value) {
  191. return (localStorage[name + '_' + v] = value);
  192. }
  193.  
  194. function getA(name) {
  195. return (JSON.parse(localStorage[name + '_' + v]));
  196. }
  197.  
  198. if (localStorage['prefs_' + v]) {
  199. var prefs = getA('prefs');
  200. } else {
  201. var prefs = {};
  202. }
  203.  
  204. if (localStorage['sets_' + v]) {
  205. var sets = getA('sets');
  206. } else {
  207. var sets = {};
  208. }
  209.  
  210. function setA(name, pref, value) {
  211. if (name === 'prefs') {
  212. prefs[pref] = value;
  213. return (localStorage[name + '_' + v] = JSON.stringify(prefs));
  214. }
  215. if (name === 'sets') {
  216. sets[pref] = value;
  217. return (localStorage[name + '_' + v] = JSON.stringify(sets));
  218. }
  219. }
  220.  
  221. function clearUserData() {
  222. var permanent = {
  223. ob_uid: localStorage.getItem('ob_uid'),
  224. ob_skip_version: localStorage.getItem('ob_skip_version'),
  225. ob_last_update_prompt: localStorage.getItem('ob_last_update_prompt'),
  226. ob_last_version: localStorage.getItem('ob_last_version')
  227. };
  228. localStorage.clear();
  229. for (var key in permanent) {
  230. if (permanent.hasOwnProperty(key)) {
  231. localStorage.setItem(key, permanent[key]);
  232. }
  233. }
  234. }
  235.  
  236. function assetUrl(path) {
  237. return OB_API_WEBSITE + '/gh/OBv2/v' + OB_VERSION + path;
  238. }
  239.  
  240. /*
  241. * Helper functions
  242. */
  243.  
  244. function rand(min, max) {
  245. return Math.floor(((max - min) + 1) * Math.random()) + min;
  246. }
  247.  
  248. function array_sum(array) {
  249. return array.reduce(function (a, b) {
  250. return (a + b);
  251. });
  252. }
  253.  
  254. function iMin(array) {
  255. return array.indexOf(Math.min.apply({}, array));
  256. }
  257.  
  258. function on_page(str) {
  259. if (window.location.hash.indexOf(str) != -1) {
  260. return true;
  261. }
  262. return false;
  263. }
  264.  
  265. function time() {
  266. return Math.floor(parseInt(new Date().getTime(), 10) / 1000);
  267. }
  268.  
  269. function GetParam(name) {
  270. var results = new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)').exec(window.location.href);
  271. return results === null ? 0 : (results[1] || 0);
  272. }
  273.  
  274. function isVisible(node) {
  275. var win = $(window);
  276. var viewport = {
  277. top: win.scrollTop(),
  278. left: win.scrollLeft()
  279. };
  280. viewport.right = viewport.left + win.width();
  281. viewport.bottom = viewport.top + win.height();
  282.  
  283. var bounds = node.offset();
  284. bounds.right = bounds.left + node.outerWidth();
  285. bounds.bottom = bounds.top + node.outerHeight();
  286.  
  287. return (!(viewport.right < bounds.left || viewport.left > bounds.right || viewport.bottom < bounds.top || viewport.top > bounds.bottom));
  288. }
  289.  
  290. // show footer div only when last tr is not visible
  291. function toggleFooterVisibility() {
  292. if (isVisible($('tr:has(input[name="shipcity"])'))) {
  293. $('#footer').css('display', 'none');
  294. } else {
  295. $('#footer').css('display', 'block');
  296. }
  297. }
  298.  
  299. function voteNow(save) {
  300. $('a[name="forticket"]').each(function () {
  301. window.open(this);
  302. });
  303. if (save) { // store last voting time
  304. setV('lastvote', time());
  305. }
  306. }
  307.  
  308. function delMsg(what, name) {
  309. $('tr[class*="color"]').each(function () {
  310. var msgTr = $(this);
  311. var msgTitle = msgTr.find('td:eq(1)').text().replace(/\s/g, '').replace(/(\[\d+\])/g, '');
  312. var thismsgid = msgTr.find('td:eq(1)').find('a').attr('href').split('iMsgId=')[1];
  313. name = name.replace(/\s/g, '').replace(/(\[\d+\])/g, '');
  314. if (what == 'id') {
  315. if (name == thismsgid) {
  316. $.get('//' + document.location.hostname + '/BeO/webroot/index.php?module=Mail&action=delMsg&iId=' + thismsgid + '&iParty=2', function () {
  317. $('font[color="red"]').text('Message deleted.');
  318. });
  319. msgTr.hide();
  320. msgTr.next().hide();
  321. }
  322. } else if (what == 'name') {
  323. if (name == msgTitle) {
  324. $.get('//' + document.location.hostname + '/BeO/webroot/index.php?module=Mail&action=delMsg&iId=' + thismsgid + '&iParty=2', function () {
  325. $('font[color="red"]').text('Message deleted.');
  326. });
  327. msgTr.hide();
  328. msgTr.next().hide();
  329. }
  330. }
  331. });
  332. }
  333.  
  334. function commafy(number) {
  335. var str = (number + '').split('.'),
  336. dec = str[1] || '',
  337. number = str[0].replace(/(\d)(?=(\d{3})+\b)/g, '$1,');
  338. return (dec) ? number + '.' + dec : number;
  339. }
  340.  
  341. function getPow(name, i, def) {
  342. var info = getV(name, '' + def);
  343. var w;
  344. if (name == 'bninfo') {
  345. w = 2; // set width of buckets
  346. } else if (name == 'prefs') {
  347. w = 1;
  348. }
  349. return (1 * info.substr((i * w), w)); // return int version of bucket
  350. }
  351.  
  352. function setPow(name, i, value) {
  353. var info = getV(name, '0');
  354. var w;
  355. if (name == 'bninfo') {
  356. w = 2; // set width of buckets
  357. } else if (name == 'prefs') {
  358. w = 1;
  359. }
  360. i = i * w; // set string index
  361. value += ''; // toString
  362. while (value.length < w) {
  363. value = '0' + value; // pad with zeros
  364. }
  365. if (i > 0 && (i + w) < info.length) {
  366. info = info.substring(0, i) + value + info.substring(i + w); // value goes in middle
  367. } else if (i === 0) {
  368. info = value + info.substring(w); // value goes at beginning
  369. } else if ((i + w) >= info.length) {
  370. info = info.substring(0, i) + value; // value goes at end
  371. } else {
  372. return;
  373. }
  374. setV(name, info); // store string
  375. }
  376.  
  377. function bnUpdate() {
  378. var nick, rank, bloodType, city, ride;
  379.  
  380. nick = unsafeWindow.omerta.character.info.name();
  381. rank = unsafeWindow.omerta.character.progress.rank();
  382. bloodType = unsafeWindow.omerta.character.info.bloodtype();
  383. city = unsafeWindow.omerta.character.game.city();
  384. var possessions = unsafeWindow.omerta.modules.UserInformation.data.possessions;
  385. if (possessions) {
  386. $.each(possessions, function(i) {
  387. if (possessions[i].type == 'plane') {
  388. ride = possessions[i].name_owned;
  389. }
  390. });
  391. }
  392.  
  393. setV('bloodType', bloodType);
  394. setV('nick', nick);
  395.  
  396. // define max b/n judging by rank
  397. var maxBooze = [1, 2, 2, 5, 7, 10, 15, 20, 25, 30, 35, 40, 45, 50, 60, 70, 70, 70];
  398. var maxNarcs = [0, 0, 0, 1, 2, 4, 5, 7, 8, 10, 11, 13, 14, 16, 17, 20, 20, 20];
  399. for (var booze = 0, narc = 0, i = 0; i <= 17; i++) {
  400. if (ranks[i] == rank) {
  401. booze = maxBooze[i];
  402. narc = maxNarcs[i];
  403. break;
  404. }
  405. }
  406. setPow('bninfo', 0, narc);
  407. setPow('bninfo', 1, booze);
  408.  
  409. // parse city to ID
  410. for (var cityCode = 0, i = 0; i < 8; i++) {
  411. if (city == cities[i]) {
  412. cityCode = i + 4;
  413. break;
  414. }
  415. }
  416. setPow('bninfo', 2, cityCode); // save
  417.  
  418. // parse plane to ID
  419. var rides = ['none', 'geen', 'Fokker DR-1', 'Havilland DH 82A', 'Fleet 7', 'Douglas DC-3'];
  420. for (var plane = 0, i = 0; i <= 5; i++) {
  421. if (rides[i] == ride) {
  422. plane = [0, 0, 1, 2, 3, 4][i];
  423. break;
  424. }
  425. }
  426. setPow('bninfo', 3, plane); // save
  427. }
  428.  
  429. var soundPlaying = false;
  430. var soundQueue = [];
  431.  
  432. function playNextSound() {
  433. if (soundQueue.length > 0) {
  434. soundPlaying = true;
  435. var sound = new Howl({
  436. src: [ soundQueue.shift() ],
  437. onend: function() {
  438. window.setTimeout(playNextSound, 250);
  439. }
  440. });
  441. sound.play();
  442. } else {
  443. soundPlaying = false;
  444. }
  445. }
  446.  
  447. function playSound(topic) {
  448. if (prefs['use_tts']) {
  449. src = OB_CDN_URL + '/sounds/tts/' + topic + '.mp3';
  450. } else {
  451. src = OB_CDN_URL + '/sounds/beep.mp3';
  452. }
  453. soundQueue.push(src);
  454. if (!soundPlaying) {
  455. playNextSound();
  456. }
  457. }
  458.  
  459. function CheckBmsg() {
  460. setTimeout(function () {
  461. var lastbmsg = getV('lastbmsg', 0);
  462. $.get(OB_API_WEBSITE + '/?p=bmsg&v=' + v + '&last=' + lastbmsg, function (response) {
  463. var deaths = response['deaths'].length;
  464. var news = response['news'].length;
  465. if (news == 1 && (prefs['bmsgNews'] || prefs['bmsgNews_sound'])) {
  466. var bmsgNewsTxt = 'A new article is posted ' + OB_NEWS_WEBSITE + '\n\n';
  467. var bmsgNewsTitle = response['news'][0]['title'];
  468. bmsgNewsTxt += response['news'][0]['preview'];
  469.  
  470. if (prefs['bmsgNews']) {
  471. var notification = new Notification(bmsgNewsTitle, {
  472. dir: 'auto',
  473. lang: '',
  474. body: bmsgNewsTxt,
  475. tag: 'news',
  476. icon: assetUrl('/images/red-star.png')
  477. });
  478. notification.onclose = function () {
  479. setTimeout(CheckBmsg(), 60000);
  480. };
  481. notification.onclick = function () {
  482. window.open(OB_NEWS_WEBSITE + '/' + response['news'][0]['id']);
  483. notification.close();
  484. };
  485.  
  486. var autoCloseSecs = parseInt(sets['autoCloseNotificationsSecs'] || 0, 10);
  487. if (autoCloseSecs > 0) {
  488. setTimeout(function() {
  489. notification.close();
  490. }, autoCloseSecs * 1000);
  491. }
  492. }
  493.  
  494. if (prefs['bmsgNews_sound']) {
  495. playSound('news');
  496. }
  497. setV('lastbmsg', response['news'][0]['ts']);
  498. } else if ((prefs['bmsgDeaths'] || prefs['bmsgDeaths_sound']) && (deaths >= 1)) {
  499. var bmsgDeathsTxt = response['deaths'].length + ' people died:\n\n';
  500. var bmsgDeathsTitle = 'Deaths! (' + v + ')';
  501. var am = (response['deaths'].length < 10 ? response['deaths'].length : 10);
  502. for (var i = 0; i < am; i++) {
  503. var bmsgD = new Date(response['deaths'][i]['ts'] * 1000);
  504. var bmsgTime = (bmsgD.getHours() < 10 ? '0' : '') + bmsgD.getHours() + ':' + (bmsgD.getMinutes() < 10 ? '0' : '') + bmsgD.getMinutes() + ':' + (bmsgD.getSeconds() < 10 ? '0' : '') + bmsgD.getSeconds();
  505. var bmsgExtra = (response['deaths'][i]['akill'] == 1) ? '(A)' : (response['deaths'][i]['bf'] == 1) ? '(BF)' : '';
  506. var bmsgFam = (response['deaths'][i]['fam'] === '') ? '(none)' : '(' + response['deaths'][i]['fam'] + ')';
  507. bmsgDeathsTxt += bmsgExtra + ' ' + bmsgTime + ' ' + response['deaths'][i]['name'] + ' ' + response['deaths'][i]['rank_text'] + ' ' + bmsgFam + '\n';
  508. }
  509.  
  510. if (prefs['bmsgDeaths']) {
  511. var notification = new Notification(bmsgDeathsTitle, {
  512. dir: 'auto',
  513. lang: '',
  514. body: bmsgDeathsTxt,
  515. tag: 'deaths',
  516. icon: assetUrl('/images/rip.png')
  517. });
  518. notification.onclose = function () {
  519. setTimeout(CheckBmsg(), 60000);
  520. };
  521. notification.onclick = function () {
  522. unsafeWindow.omerta.GUI.container.loadPage('./BeO/webroot/index.php?module=Statistics&action=global_stats');
  523. window.focus();
  524. notification.close();
  525. };
  526.  
  527. var autoCloseSecs = parseInt(sets['autoCloseNotificationsSecs'] || 0, 10);
  528. if (autoCloseSecs > 0) {
  529. setTimeout(function() {
  530. notification.close();
  531. }, autoCloseSecs * 1000);
  532. }
  533.  
  534. }
  535.  
  536. if (prefs['bmsgDeaths_sound']) {
  537. playSound('death');
  538. }
  539.  
  540. setV('lastbmsg', response['deaths'][0]['ts']);
  541. }
  542. setTimeout(function () {
  543. CheckBmsg();
  544. }, 60000);
  545. });
  546. }, 0);
  547. }
  548.  
  549. var scheduledNotifications = [];
  550. var notificationsArray = [];
  551.  
  552. function ScheduleNotification(topic, firesAt, title, text, tag, callbackUrl, beyondIcon) {
  553. if ((prefs['notify_' + topic] || prefs['notify_' + topic + '_sound']) && !scheduledNotifications.hasOwnProperty(topic)) {
  554. var timeout = parseInt(firesAt, 10) - unsafeWindow.omerta.Clock.getTime() / 1000;
  555. if (timeout > 0) {
  556. scheduledNotifications[topic] = true;
  557. setTimeout(function() {
  558. delete scheduledNotifications[topic];
  559. if (prefs['notify_' + topic]) {
  560. SendNotification(title, text, tag, callbackUrl, beyondIcon);
  561. }
  562. if (prefs['notify_' + topic + '_sound']) {
  563. playSound(topic);
  564. }
  565. }, timeout * 1000);
  566. }
  567. }
  568. }
  569.  
  570. function SendNotification(title, text, tag, callbackUrl, beyondIcon) {
  571. var notification = new Notification(title, {
  572. dir: 'auto',
  573. lang: '',
  574. body: text,
  575. tag: tag,
  576. icon: beyondIcon
  577. });
  578. notification.onclick = function () {
  579. if (callbackUrl !== null) {
  580. unsafeWindow.omerta.GUI.container.loadPage(callbackUrl);
  581. }
  582. window.focus();
  583. notification.close();
  584. };
  585.  
  586. // Automatically close notification
  587. var autoCloseSecs = parseInt(sets['autoCloseNotificationsSecs'] || 0, 10);
  588. if (autoCloseSecs > 0) {
  589. setTimeout(function() {
  590. notification.close();
  591. delete notificationsArray[tag];
  592. }, autoCloseSecs * 1000);
  593. }
  594.  
  595. notificationsArray[tag] = notification;
  596. }
  597.  
  598. function CheckServiceVariable() {
  599.  
  600. var intervalId = setInterval(function() {
  601. var serviceData = unsafeWindow.omerta.services.account.data;
  602.  
  603. if (serviceData.logout) {
  604. clearInterval(intervalId);
  605. return;
  606. }
  607.  
  608. if (prefs['notify_health'] || prefs['notify_health_sound']) {
  609. var newHealth = parseFloat(serviceData.progressbars.health);
  610. var oldHealth = parseFloat(getV('serviceHealth', 0));
  611. if (oldHealth > 0 && (oldHealth > newHealth)) {
  612. var healthText = 'You lost ' + (oldHealth - newHealth) + ' health!';
  613. var healthTitle = 'Health (' + v + ')';
  614. if (prefs['notify_health']) {
  615. SendNotification(healthTitle, healthText, 'health', './BeO/webroot/index.php?module=Bloodbank', assetUrl('/images/red-star.png'));
  616. }
  617. if (prefs['notify_health_sound']) {
  618. playSound('health');
  619. }
  620. }
  621.  
  622. setV('serviceHealth', newHealth);
  623. }
  624.  
  625. // check for new messages if they want them
  626. if (serviceData.messages.inbox.length > 0 && (prefs['notify_messages'] || prefs['notify_messages_sound'])) {
  627. var lastMessage = parseInt(getV('lastMessage', 0), 10);
  628.  
  629. var totalMessages = 0;
  630. $.each(serviceData.messages.inbox, function(i, val) {
  631. var id = parseInt(val.id, 10);
  632. if (lastMessage === id) {
  633. return false;
  634. }
  635. totalMessages += 1;
  636. });
  637.  
  638. if (totalMessages !== 0) {
  639. var msgId = parseInt(serviceData.messages.inbox[0].id, 10);
  640. var msgTitle = '';
  641. var msgText = '';
  642. var callbackUrl = './BeO/webroot/index.php?module=Mail&action=showMsg&iMsgId=';
  643.  
  644. setV('lastMessage', msgId);
  645. if (totalMessages === 1) {
  646. msgText = 'Message: ' + serviceData.messages.inbox[0].msg.replace(/<br \/>/g, '');
  647. msgTitle = 'New message from ' + serviceData.messages.inbox[0].frm + ': ' + serviceData.messages.inbox[0].sbj + ' (' + v + ')';
  648. callbackUrl = callbackUrl + msgId;
  649. } else {
  650. msgText = 'You have got ' + totalMessages + ' new messages';
  651. msgTitle = 'New messages (' + v + ')';
  652. callbackUrl = './BeO/webroot/index.php?module=Mail&action=inbox';
  653. }
  654. if (prefs['notify_messages']) {
  655. SendNotification(msgTitle, msgText, 'Mail', callbackUrl, assetUrl('/images/red-star.png'));
  656. }
  657. if (prefs['notify_messages_sound']) {
  658. playSound('messages');
  659. }
  660. }
  661. }
  662.  
  663. // check for new alerts if they want them
  664. if (serviceData.messages.alert.length > 0 && (prefs['notify_alerts'] || prefs['notify_alerts_sound'])) {
  665. // msgId -1 is a friend request
  666. var lastAlert = parseInt(getV('lastAlert', 0), 10);
  667. var totalAlerts = 0;
  668. $.each(serviceData.messages.alert, function(i, val) {
  669. var id = (val.id ? parseInt(val.id, 10) : -1);
  670. if (lastAlert === id) {
  671. return false;
  672. }
  673. totalAlerts += 1;
  674. });
  675.  
  676. if (totalAlerts !== 0) {
  677. var msgId = (serviceData.messages.alert[0].id ? parseInt(serviceData.messages.alert[0].id, 10) : -1);
  678. var alertTitle = '';
  679. var alertText = '';
  680. var callbackUrl = './BeO/webroot/index.php?module=Mail&action=showMsg&iMsgId=';
  681. setV('lastAlert', msgId);
  682. if (totalAlerts === 1) {
  683. // If it's a friend request, it has no msg or id
  684. if (serviceData.messages.alert[0].sbj !== 'Friend Request(s)') {
  685. alertText = 'Alert: ' + serviceData.messages.alert[0].msg.replace(/<br \/>/g, '');
  686. alertTitle = 'Alert! ' + serviceData.messages.alert[0].sbj + ' (' + v + ')';
  687. callbackUrl = callbackUrl + msgId;
  688. } else {
  689. alertText = 'Alert: You got a new friend request!';
  690. alertTitle = 'Alert! ' + serviceData.messages.alert[0].sbj + ' (' + v + ')';
  691. callbackUrl = serviceData.messages.alert[0].link;
  692. }
  693. } else {
  694. alertText = 'You have got ' + totalAlerts + ' new alerts';
  695. alertTitle = 'Alert! (' + v + ')';
  696. callbackUrl = './BeO/webroot/index.php?module=Mail&action=inbox';
  697. }
  698. if (prefs['notify_alerts']) {
  699. SendNotification(alertTitle, alertText, 'alert', callbackUrl, assetUrl('/images/red-star.png'));
  700. }
  701. if (prefs['notify_alerts_sound']) {
  702. playSound('alerts');
  703. }
  704. }
  705. }
  706.  
  707. ScheduleNotification(
  708. 'gta',
  709. $('[data-cooldown="car"] input').attr('data-knob-timeend'),
  710. (v == 'nl' ? 'Steel een auto (' + v + ')' : 'Nick a car (' + v + ')'),
  711. (v == 'nl' ? 'Je kunt weer een auto stelen' : 'You can nick a car'),
  712. 'Car',
  713. '/?module=Cars',
  714. assetUrl('/images/red-star.png')
  715. );
  716.  
  717. ScheduleNotification(
  718. 'crime',
  719. $('[data-cooldown="crime"] input').attr('data-knob-timeend'),
  720. (v == 'nl' ? 'Misdaad (' + v + ')' : 'Crime (' + v + ')'),
  721. (v == 'nl' ? 'Je kunt weer een misdaad doen' : 'You can do a crime'),
  722. 'Crime',
  723. '/?module=Crimes',
  724. assetUrl('/images/red-star.png')
  725. );
  726.  
  727. ScheduleNotification(
  728. 'travel',
  729. $('[data-cooldown="travel"] input').attr('data-knob-timeend'),
  730. (v == 'nl' ? 'Reizen (' + v + ')' : 'Travel (' + v + ')'),
  731. (v == 'nl' ? 'Je kunt reizen' : 'You can travel'),
  732. 'Travel',
  733. '/?module=Travel',
  734. assetUrl('/images/red-star.png')
  735. );
  736.  
  737. ScheduleNotification(
  738. 'bullets',
  739. $('[data-cooldown="bullets"] input').attr('data-knob-timeend'),
  740. (v == 'nl' ? 'Kogels (' + v + ')' : 'Bullets (' + v + ')'),
  741. (v == 'nl' ? 'Je kunt kogels kopen' : 'You can buy bullets'),
  742. 'Bullets',
  743. '/bullets2.php',
  744. assetUrl('/images/red-star.png')
  745. );
  746. }, 5000);
  747. }
  748.  
  749. function getOmertaTime() {
  750. if (typeof unsafeWindow.omerta.server.clock !== 'undefined') {
  751. return unsafeWindow.omerta.server.clock.getTime();
  752. }
  753.  
  754. if (typeof unsafeWindow.omerta.Clock !== 'undefined') {
  755. return unsafeWindow.omerta.Clock.getTime();
  756. }
  757.  
  758. return Date.now();
  759. }
  760.  
  761. var versionHasLogger = v == 'com' || v == 'nl' || v == 'dm' || v == 'pt';
  762. var boozenames = ['NO BOOZE', 'Wine', 'Beer', 'Rum', 'Cognac', 'Whiskey', 'Amaretto', 'Port'];
  763. var narcnames = ['NO NARCS', 'Morphine', 'Marijuana', 'Glue', 'Heroin', 'Opium', 'Cocaine', 'Tabacco'];
  764.  
  765. function calcRaidResult(profit, protection) {
  766. return profit * (110 - protection) / 1000;
  767. }
  768.  
  769. // function to parse date string (09-07-2014 09:30:54)
  770. function datestringParse(dateString) {
  771. var dateTime = dateString.split(' ');
  772. var date = dateTime[0].split('-');
  773. var dd = date[0];
  774. var mm = date[1] - 1;
  775. var yyyy = date[2];
  776.  
  777. var time = dateTime[1].split(':');
  778. var h = time[0];
  779. var m = time[1];
  780. var s = parseInt(time[2], 10); // get rid of that 00.0;
  781.  
  782. return new Date(yyyy, mm, dd, h, m, s);
  783. }
  784.  
  785. /**
  786. * Checks if the user is alive
  787. * @param {[String]} user
  788. * @return {Boolean}
  789. */
  790. function checkUserAlive(user, callback) {
  791. $.getJSON(OB_API_NEW_WEBSITE + '/domains/' + v + '/versions/latest/users/' + user, function (data) {
  792. callback(data['alive']);
  793. });
  794. }
  795.  
  796. // ---------------- NickReader ----------------
  797. var nickReaderIcon = assetUrl('/images/magnifier.png');
  798. var loadingIcon = assetUrl('/images/loading.png');
  799. function parseGrab(html, url) {
  800. var body = html.slice(html.indexOf('</head>') + 7);
  801. // make sure all requests are handled separately
  802. var ident = url.split('=')[1];
  803. // Check for clicklimit
  804. if (body.indexOf('You reached your click limit.') == -1) {
  805. // Add placeholder div
  806. $('body').append(
  807. $('<div>').attr('id', 'XHRDiv' + ident).html(body).hide()
  808. );
  809.  
  810. // grabbing keys
  811. var keys = [];
  812. $('#XHRDiv' + ident + ' > center > table#user > tbody > tr > td.subtableheader').each(function (n) {
  813. keys[n] = $.trim($(this).text());
  814. });
  815. keys.shift();
  816.  
  817. // grabbing values
  818. var vals = [];
  819. $('#XHRDiv' + ident + ' > center > table#user > tbody > tr > td.profilerow').each(function (n) {
  820. vals[n] = $.trim($(this).text());
  821. });
  822. vals.pop();
  823. vals.shift(); vals.shift();
  824.  
  825. // parse certain values to make them fit within the popup
  826. vals = vals.map(function(col) {
  827. // Limit status
  828. if (col.indexOf(' online ') != -1) {
  829. return col.slice(0, col.indexOf(' online ') + 7);
  830. }
  831. // Limit HP
  832. if (/\(Click|\(Klik/.test(col)) {
  833. return col.slice(0, col.indexOf('('));
  834. }
  835. // Limit family string
  836. if (col.indexOf('(CapoRegime:') != -1) {
  837. return col.slice(0, col.indexOf('('));
  838. }
  839. // Limit marital status
  840. if (/Married Couple:|Getrouwd stel:/.test(col)) {
  841. return col.split(/Married |Getrouwd /)[1];
  842. }
  843. return col;
  844. }).filter(function(col) {
  845. // Filter friends, SMS and organised crimes from vals
  846. return !/ Friends| vrienden/.test(col) && col.indexOf('Send SMS') == -1 && col.indexOf('Available') == -1 && col.indexOf('Tired') == -1 && col.indexOf('Beschikbaar') == -1 && col.indexOf('Moe') == -1;
  847. });
  848.  
  849. keys = keys.filter(function(col) {
  850. // Filter friends, SMS and organised crimes from keys
  851. return !/Friends:|Vrienden:/.test(col) && !/Heist Status:/.test(col) && !/Organised Crime Status:|Georganiseerde Misdaad Status:/.test(col) && col.indexOf('SMS Status') == -1;
  852. });
  853.  
  854. // Create table
  855. $('#' + ident).attr('name', 'done').empty().append(
  856. $('<table>').attr({
  857. id: 'NRtable'
  858. }),
  859. $('<img>').attr('src', nickReaderIcon).addClass('NRicon')
  860. );
  861.  
  862. // Add keys and values to table
  863. for (var i = 0; i < keys.length; i++) {
  864. $('#NRtable').append(
  865. $('<tr>').append(
  866. $('<td>').attr('height', '15').text(keys[i]),
  867. $('<td>').text(vals[i])
  868. )
  869. );
  870. }
  871.  
  872. // Remove the placeholder div
  873. $('#XHRDiv' + ident).remove();
  874.  
  875. // End the process
  876. $('#proc').text(0);
  877. } else {
  878. $('#' + ident).text('Clicklimit, please try again...');
  879. $('#proc').text(0);
  880. }
  881. }
  882.  
  883. function checkNRdiv(url, nickId) {
  884. // is the NR activated?
  885. var on = ($('#shft').text() == '1' ? 1 : 0);
  886. // default is to add popup
  887. var go = 1;
  888. // check for an existing popup
  889. if ($('#' + nickId).length > 0) {
  890. var popup = $('#' + nickId);
  891. if (on) { // if it's there, let's see it
  892. popup.css('display', 'block');
  893. }
  894. go = 0; // we found a popup already
  895. // check for any empty values
  896. if (popup.html().indexOf('<td></td></tr>') != -1) {
  897. popup.remove();
  898. go = 1; // it's no good though
  899. }
  900. // check if it's loaded yet (clicklimit)
  901. if ($('#' + nickId).attr('name') == 'loading') {
  902. popup.remove();
  903. go = 1; // it's no good though
  904. }
  905. }
  906. // yes we may proceed to add the popup
  907. if (go && on) {
  908. $('body').append(
  909. $('<div>').attr('id', nickId).addClass('NRinfo').text('Loading info..').append(
  910. $('<img>').attr('src', loadingIcon)
  911. )
  912. );
  913.  
  914. // add follow the mouse
  915. $(window).mousemove(function(mouse) {
  916. var divH = $('#' + nickId).height();
  917. var divW = $('#' + nickId).width();
  918.  
  919. var X = mouse.pageX;
  920. var Y = mouse.pageY;
  921. var plusX = 20;
  922. var plusY = 20;
  923.  
  924. if (X + divW + 20 > $(window).width()) { // if box falls of the right
  925. plusX = -20 - divW;
  926. }
  927. if (Y + divH + 20 > $(window).innerHeight()) { // if box falls of the bottom
  928. plusY = -20 - divH;
  929. }
  930. $('#' + nickId).css('left', X + plusX);
  931. $('#' + nickId).css('top', Y + plusY);
  932. });
  933.  
  934. // add popup to page
  935. $('#' + nickId).attr('name', 'loading');
  936.  
  937. // check if there isn't a process running already, otherwise grab the HTML
  938. if ($('#proc').text() === '0') {
  939. $.get(url, function(data) {
  940. parseGrab(data, url);
  941. });
  942. $('#proc').text(1);
  943. } else {
  944. $('#' + nickId).text('Wait for the previous..');
  945. }
  946. }
  947. }
  948.  
  949. function nickReader() {
  950. var nicks = $('a[href*="user.php"]:not([href*="&jh="])');
  951. if (nicks.length > 0) {
  952. // don't run this part twice
  953. if ($('#NRstatus').length === 0) {
  954. $('#game_header_marquee').append(
  955. $('<div>').attr('id', 'NRstatus').css({
  956. position: 'relative',
  957. display: 'none'
  958. }).append(
  959. $('<center>').append(
  960. $('<img>').attr('src', nickReaderIcon),
  961. $('<b>').text('Nickreader enabled')
  962. )
  963. )
  964. );
  965.  
  966. // setup shift event checker
  967. if ($('#shft').length === 0) {
  968. $('body').append(
  969. $('<div>').attr('id', 'shft').text('0').hide()
  970. );
  971. }
  972.  
  973. // setup process checker
  974. if ($('#proc').length === 0) {
  975. $('body').append(
  976. $('<div>').attr('id', 'proc').text('0').hide()
  977. );
  978. }
  979.  
  980. // add shift keydown handler
  981. $(window).keydown(function(event) {
  982. var key = event.which;
  983. if (key == 16) {
  984. if ($('#shft').text() === '0') {
  985. $('#NRstatus').show('slow');
  986. $('#shft').text(1);
  987. } else {
  988. $('#NRstatus').hide('slow');
  989. $('#shft').text(0);
  990. $('#proc').text(0);
  991. $('div[id^="XHRDiv"]').remove();
  992. }
  993. }
  994. });
  995. }
  996. // add mouse event checkers
  997. nicks.each(function() {
  998. if ($(this).attr('href').search('cpuser') == -1) {
  999. var nickId = $(this).attr('href').split('=')[1];
  1000. $(this).mouseover(function() {
  1001. checkNRdiv($(this).attr('href'), nickId);
  1002. });
  1003. $(this).mouseout(function() {
  1004. if ($('#' + nickId)) {
  1005. $('#' + nickId).remove();
  1006. }
  1007. });
  1008. }
  1009. });
  1010. // focus on frame so 'shift' event is noticed
  1011. $(window).focus();
  1012. }
  1013. }
  1014.  
  1015. /*
  1016. * Chat listener
  1017. */
  1018. if (document.getElementById('omerta_chat') !== null && typeof MutationObserver != 'undefined') {
  1019. var firstMessageTs;
  1020. var chatObserver = new MutationObserver(function(mutations) {
  1021. mutations.forEach(function(mutation) {
  1022. for (var i = 0; i < mutation.addedNodes.length; i++) {
  1023. var node = mutation.addedNodes[i];
  1024. if (node.nodeType == 1 && !node.hasAttribute('data-beyond-fired') && $(node).hasClass('user-message-text')) {
  1025. node.setAttribute('data-beyond-fired', true);
  1026. if (typeof firstMessageTs == 'undefined') {
  1027. firstMessageTs = $.now();
  1028. }
  1029. var isBufferedMessage = firstMessageTs >= $.now() - 500;
  1030. var sender = $(node).find('.msg-author');
  1031. var messageText = $(node).find('.msg-content');
  1032. if (!isBufferedMessage && $(node).hasClass('msg-hilight')) {
  1033. if (prefs['notify_highlight']) {
  1034. SendNotification('Your name was mentioned in the chat', sender.text() + messageText.text(), 'Chat', null, assetUrl('/images/red-star.png'));
  1035. }
  1036. if (prefs['notify_highlight_sound']) {
  1037. playSound('highlight');
  1038. }
  1039. }
  1040. }
  1041. }
  1042. });
  1043. });
  1044.  
  1045. chatObserver.observe(document.getElementById('omerta_chat'), {
  1046. attributes: false,
  1047. childList: true,
  1048. subtree: true,
  1049. characterData: false
  1050. });
  1051. }
  1052.  
  1053. /**
  1054. * Check if a word is in a string
  1055. * @param {[String]} s Haystack
  1056. * @param {[String]} word Needle
  1057. * @return {[Booleon]}
  1058. */
  1059. function wordInString(s, word) {
  1060. return new RegExp('\\b' + word + '\\b', 'i').test(s);
  1061. }
  1062.  
  1063. function proxyImage(node) {
  1064. $(node).attr('src', $(node).attr('src').replace(/https?:\/\/i\.imgur\.com/, 'https://gm.omertabeyond.net/imgur'));
  1065. }
  1066.  
  1067. function displayUpdate(release) {
  1068. $('body').append(
  1069. $('<div>').attr(
  1070. 'id',
  1071. 'ob_update_dialog'
  1072. ).attr(
  1073. 'title',
  1074. 'Omerta Beyond: Update Available'
  1075. ).append(
  1076. $('<h3>').text('Version ' + release.version + ' of Omerta Beyond has been released.'),
  1077. $('<h3>').text('Release Notes:'),
  1078. $('<p>').html(release.release_notes)
  1079. )
  1080. );
  1081.  
  1082. $('#ob_update_dialog').dialog({
  1083. resizable: false,
  1084. height: 'auto',
  1085. width: 480,
  1086. modal: true,
  1087. buttons: {
  1088. 'Download Update': function() {
  1089. window.open(release.url, '_blank');
  1090. $(this).dialog('close');
  1091. },
  1092. 'Skip this version': function() {
  1093. localStorage.setItem('ob_skip_version', release.version);
  1094. $(this).dialog('close');
  1095. }
  1096. }
  1097. });
  1098. }
  1099.  
  1100. function sendBeacon() {
  1101. $.post(OB_API_NEW_WEBSITE + '/addon_beacon', {
  1102. addon_beacon: {
  1103. uid: localStorage.getItem('ob_uid'),
  1104. addon_version: OB_VERSION,
  1105. domain: v
  1106. }
  1107. }, function(data) {
  1108. if (data.update_available) {
  1109. if (data.release.version == localStorage.getItem('ob_skip_version')) {
  1110. // user has chosen to skip this version
  1111. return;
  1112. }
  1113. if (localStorage.getItem('ob_last_update_prompt') >= new Date().getTime() - 86400000) {
  1114. // update dialog has already been shown in the past 24 hours
  1115. return;
  1116. }
  1117. localStorage.setItem('ob_last_update_prompt', new Date().getTime());
  1118. displayUpdate(data.release);
  1119. }
  1120. });
  1121. }
  1122.  
  1123. function showReleaseNotes() {
  1124. if (localStorage.getItem('ob_last_version') == OB_VERSION) {
  1125. return;
  1126. }
  1127. $.get(OB_API_NEW_WEBSITE + '/addon_release/' + OB_VERSION, function(release) {
  1128. $('body').append(
  1129. $('<div>').attr(
  1130. 'id',
  1131. 'ob_updated_dialog'
  1132. ).attr(
  1133. 'title',
  1134. 'Omerta Beyond: Update Installed'
  1135. ).append(
  1136. $('<h3>').text('OmertaBeyond was updated to Version ' + release.version + '.'),
  1137. $('<h3>').text('Release Notes:'),
  1138. $('<p>').html(release.release_notes)
  1139. )
  1140. );
  1141.  
  1142. $('#ob_updated_dialog').dialog({
  1143. resizable: false,
  1144. height: 'auto',
  1145. width: 480,
  1146. modal: true,
  1147. buttons: {
  1148. Close: function() {
  1149. $(this).dialog('close');
  1150. }
  1151. }
  1152. });
  1153. localStorage.setItem('ob_last_version', OB_VERSION);
  1154. });
  1155. }
  1156.  
  1157. /*
  1158. * for maximum forwards-compatibility, trigger the beacon code on either the
  1159. * main container being present, or the "omerta" variable being set
  1160. */
  1161. if (document.getElementById('game_container') !== null || typeof unsafeWindow.omerta !== 'undefined') {
  1162. sendBeacon();
  1163. showReleaseNotes();
  1164. }
  1165.  
  1166. /*
  1167. * Main game listener
  1168. */
  1169.  
  1170. if (document.getElementById('game_container') !== null) {
  1171. var mutationObserver = window.MutationObserver || window.WebKitMutationObserver || window.MozMutationObserver;
  1172.  
  1173. if (mutationObserver) {
  1174. var observer = new MutationObserver(function(mutations) {
  1175. mutations.forEach(function(mutation) {
  1176. for (var i = 0; i < mutation.addedNodes.length; i++) {
  1177. var node = mutation.addedNodes[i];
  1178. if (node.nodeType == 1 && !node.hasAttribute('data-beyond-fired')) {
  1179. node.setAttribute('data-beyond-fired', true);
  1180. gameContainerChanged(node);
  1181. }
  1182. }
  1183. });
  1184. });
  1185.  
  1186. observer.observe(document.getElementById('game_container'), {
  1187. attributes: false,
  1188. childList: true,
  1189. characterData: false
  1190. });
  1191. } else {
  1192. // jeez, get a new browser ;(
  1193. // falling back to DOMNodeInserted event
  1194. document.getElementById('game_container').addEventListener('DOMNodeInserted', function(event) {
  1195. if (event.target.nodeType != 1) {
  1196. return false;
  1197. }
  1198.  
  1199. if ($(event.target).attr('data-beyond-fired') !== undefined) {
  1200. return false;
  1201. }
  1202.  
  1203. if ($(event.target).attr('id') == 'recaptcha-popup') {
  1204. return false;
  1205. }
  1206.  
  1207. $(event.target).attr('data-beyond-fired', 'true');
  1208. gameContainerChanged(event.target);
  1209. }, true);
  1210. }
  1211.  
  1212. var gameContainerChanged = function(node) {
  1213. var nn = node.tagName.toLowerCase();
  1214. var nid = node.getAttribute('id');
  1215. var nclass = node.className;
  1216. var wlh = window.location.hash;
  1217.  
  1218. $(node).find('img').each(function() {
  1219. proxyImage(this);
  1220. });
  1221.  
  1222. // unbind events
  1223. if (!on_page('garage.php') && !on_page('module=Cars')) {
  1224. $(window).unbind('scroll');
  1225. $('#game_wrapper_container div#footer').remove();
  1226. }
  1227. if (!on_page('action=showMsg')) {
  1228. $(window).unbind('keydown');
  1229. }
  1230. // Disable nickreader when going to other page
  1231. if ($('#shft').length > 0) {
  1232. $('#shft').remove();
  1233. }
  1234. if ($('#proc').length > 0) {
  1235. $('#proc').remove();
  1236. }
  1237. if ($('.NRinfo').length > 0) {
  1238. $('.NRinfo').remove();
  1239. }
  1240. if ($('#NRstatus').length > 0) {
  1241. $('#NRstatus').remove();
  1242. }
  1243.  
  1244. // hitting the click limit means the page won't contain what we expect. ignore it.
  1245. if ($(node).filter(':contains("You reached your click limit."), :contains("Je hebt jouw kliklimiet bereikt.")').length > 0) {
  1246. return;
  1247. }
  1248.  
  1249. // autofocus on long pages with button at the bottom causes annoying scroll
  1250. var isAutofocusBlacklist = on_page('module=Mail') || on_page('forums');
  1251. if (!isAutofocusBlacklist && $('input[type=submit]').length == 1) {
  1252. $('input[type=submit]').focus();
  1253. }
  1254.  
  1255. if (on_page('jail.php')) {
  1256. if ($('#game_container form').length == 2) {
  1257. // self-bust page - focus on bustout button
  1258. $('input[type=submit]:eq(1)').focus();
  1259. } else {
  1260. // regular jail page, focus on top bustout button
  1261. $('input[type=submit]:first').focus();
  1262. }
  1263. }
  1264.  
  1265. /*
  1266. * add end time tooltip to every countdown
  1267. * causes issues with Greasemonkey 2+, disabling till issue is fixed
  1268. * addEndTimeTooltip(node);
  1269. */
  1270.  
  1271. // ---------------- FAMILY PAGE ----------------
  1272. if (on_page('family.php') && nn == 'center') {
  1273. nickReader();
  1274. // add HR, Deaths and Worth
  1275. var famid = wlh.split('=')[1];
  1276. var famIdFromImg = $('img[src*="family_image.php"]:last').attr('src').match(/\d+/g)[0];
  1277. var famname = $('td.profilerow').text().trim().split(' ')[0].trim().toLowerCase();
  1278. var url = (famid === famIdFromImg) ? 'id=' + famid : 'ing=' + famname;
  1279. var ownfam = getV('family', '');
  1280.  
  1281. // Count rows
  1282. var tr = $('table.thinline:eq(0) tr').length;
  1283.  
  1284. // add HQ space to members
  1285. var hq = $('table.thinline:eq(0) tr:eq(' + (tr - 3) + ') td:last').text();
  1286. var members = $('table.thinline:eq(0) tr:eq(' + (tr - 5) + ') td:last').text();
  1287. $('table.thinline:eq(0) tr:eq(' + (tr - 5) + ') td:last').text(members + '/' + hq);
  1288.  
  1289. // add color to HQ space
  1290. var hqperc = ((members / hq) * 100);
  1291. $('table.thinline:eq(0) tr:eq(' + (tr - 5) + ') td:last').css({
  1292. background: 'linear-gradient(to right, rgba(46, 188, 0, 1) ' + hqperc + '%, rgba(46, 188, 0, 0) ' + hqperc + '%)'
  1293. });
  1294.  
  1295. // add color to donating %
  1296. var doperc = $('table.thinline:eq(0) tr:eq(' + (tr - 4) + ') td:last').text().split(' (')[0].trim();
  1297. $('table.thinline:eq(0) tr:eq(' + (tr - 4) + ') td:last').css({
  1298. background: 'linear-gradient(to right, rgba(46, 188, 0, 1) ' + doperc + ', rgba(46, 188, 0, 0) ' + doperc + ')'
  1299. });
  1300.  
  1301. // add color to rank progress
  1302. if (famname == ownfam.toLowerCase()) {
  1303. var rankperc = $('table.thinline:eq(0) tr:last td:last').text().split(' (')[1].replace(')', '').trim();
  1304. $('table.thinline:eq(0) tr:last td:last').css({
  1305. background: 'linear-gradient(to right, rgba(46, 188, 0, 1) ' + rankperc + ', rgba(46, 188, 0, 0) ' + rankperc + ')'
  1306. });
  1307. }
  1308.  
  1309. // get tops
  1310. var tops = [];
  1311. $('table.thinline:eq(0) > tbody > tr > td:has(a)').each(function () {
  1312. tops.push($(this).text().trim());
  1313. });
  1314.  
  1315. var nTop = tops.length; // # tops
  1316. var SorC = (nTop == 3) ? 2 : /Consi/.test($('table.thinline:eq(0) tr:eq(7) td:first').text()); // Sotto or Consi
  1317. var don = tops[0];
  1318. var sotto = (nTop > 1 && (nTop == 3 || SorC === false)) ? tops.pop() : null;
  1319. var cons = (nTop > 1 && (nTop == 3 || SorC === true)) ? tops.pop() : null;
  1320.  
  1321. // get capos
  1322. var capos = [];
  1323. $('table.thinline:last > tbody > tr > td > a.tableheader').each(function () {
  1324. capos.push($(this).text());
  1325. });
  1326.  
  1327. // get object owners
  1328. var objects = [];
  1329. $('table.thinline:eq(2) > tbody > tr > td:has(a)').each(function () {
  1330. objects.push($(this).text());
  1331. });
  1332.  
  1333. $('#game_container a[href*="user.php"]').each(function () {
  1334. var n = $(this).text(); // nick
  1335. var vip = '';
  1336. if (n == don) {
  1337. $(this).html(n + '<small><sup>[D]</sup></small>');
  1338. vip = '[D]';
  1339. }
  1340. if (n == sotto) {
  1341. $(this).html(n + '<small><sup>[S]</sup></small>');
  1342. vip = '[S]';
  1343. }
  1344. if (n == cons) {
  1345. $(this).html(n + '<small><sup>[C]</sup></small>');
  1346. vip = '[C]';
  1347. }
  1348. if ($.inArray(n, capos) != -1) {
  1349. if (n != don) {
  1350. $(this).html(n + '<small><sup>' + vip + '(c)</sup></small>');
  1351. vip = vip + '(c)';
  1352. }
  1353. }
  1354. if ($.inArray(n, objects) != -1) {
  1355. if (n != don) {
  1356. $(this).html(n + '<small><sup>' + vip + '(o)</sup></small>');
  1357. vip = vip + '(o)';
  1358. }
  1359. }
  1360. });
  1361.  
  1362. if (versionHasLogger) {
  1363. $.getJSON(OB_API_WEBSITE + '/?p=stats&w=fampage&v=' + v + '&' + url, function (data) {
  1364. // Family position and worth
  1365. $('td.subtableheader').first().closest('tr').after(
  1366. $('<tr>').append(
  1367. $('<td>').addClass('subtableheader').text('Position:'),
  1368. $('<td>').addClass('profilerow').text('#' + data['pos'] + ' - Worth: ' + data['worth'] + '')
  1369. )
  1370. );
  1371.  
  1372. // add HR
  1373. $('table.thinline').first().find('tbody').append(
  1374. $('<tr>').append(
  1375. $('<td>').addClass('subtableheader').text('Ranks:'),
  1376. $('<td>').addClass('profilerow').append(
  1377. $('<table>').attr('width', '100%').append(
  1378. $('<tr>').append($('<td>').text('Godfather/First Lady:'), $('<td>').addClass('bold').text(data['hr']['gf'])),
  1379. $('<tr>').append($('<td>').text('Capodecina:'), $('<td>').addClass('bold').text(data['hr']['cd'])),
  1380. $('<tr>').append($('<td>').text('Bruglione:'), $('<td>').addClass('bold').text(data['hr']['brug'])),
  1381. $('<tr>').append($('<td>').text('Chief:'), $('<td>').addClass('bold').text(data['hr']['chief'])),
  1382. $('<tr>').append($('<td>').text('Local Chief:'), $('<td>').addClass('bold').text(data['hr']['lc'])),
  1383. $('<tr>').append($('<td>').text('Assassin:'), $('<td>').addClass('bold').text(data['hr']['assa'])),
  1384. $('<tr>').append($('<td>').text('Swindler:'), $('<td>').addClass('bold').text(data['hr']['swin'])),
  1385. $('<tr>').append($('<td>').attr('colspan', '2').append($('<hr />'))),
  1386. $('<tr>').append($('<td>').text('Total points:'), $('<td>').addClass('bold').text(data['hr']['pts']))
  1387. )
  1388. )
  1389. )
  1390. );
  1391.  
  1392. setTimeout(function () {
  1393. // Family deaths
  1394. $('table.thinline:eq(1)').closest('td').append(
  1395. $('<br />'),
  1396. $('<table>').addClass('thinline').css('width', '100%').attr('cellspacing', '0').attr('cellpadding', '2').attr('rules', 'none').append(
  1397. $('<tr>').append(
  1398. $('<td>').addClass('tableheader').attr('colspan', '100%').text('Last family deaths')
  1399. ),
  1400. $('<tr>').append(
  1401. $('<td>').attr('colspan', '100%').attr('bgcolor', 'black').attr('height', '1')
  1402. ),
  1403. $('<tr>').append(
  1404. $('<td>').addClass('bold').css('width', '28%').attr('align', 'left').text('Name'),
  1405. $('<td>').addClass('bold').attr('align', 'center').text('Rank'),
  1406. $('<td>').addClass('bold').attr('align', 'center').text('Date'),
  1407. $('<td>').addClass('bold').css('text-align', 'right').text('Ago')
  1408. )
  1409. )
  1410. );
  1411. if (v === 'com') {
  1412. $('<div>').addClass('dlContainer').append(
  1413. $('<a>').attr({
  1414. href: OB_NEWS_WEBSITE + '/deathslog/latest/' + famid,
  1415. target: '_blank'
  1416. }).append(
  1417. $('<img>').addClass('brcImg').attr({
  1418. src: assetUrl('/images/changelog.png'),
  1419. title: 'View full deathslog'
  1420. })
  1421. )
  1422. ).appendTo($('table.thinline:eq(2)>tbody>tr:eq(0)>td'));
  1423. }
  1424.  
  1425. var deaths_body = $('table.thinline:eq(2)').find('tbody');
  1426. if (data['deaths']) {
  1427. $.each(data['deaths'], function (k, v) {
  1428. var extra = (v['Akill'] == 1) ? '(<b>A</b>) ' : (v['BF'] == 1) ? '(<b>BF</b>) ' : '';
  1429. deaths_body.append(
  1430. $('<tr>').append(
  1431. $('<td>').html(extra).append(
  1432. $('<a>').attr('href', 'user.php?name=' + v['Name']).text(v['Name'])
  1433. ),
  1434. $('<td>').attr('align', 'center').append(
  1435. $('<a>').attr('href', OB_API_WEBSITE + '/?p=history&v=' + v + '&name=' + v['Name']).text(v['Rank'])
  1436. ),
  1437. $('<td>').attr('align', 'center').text(v['Date']),
  1438. $('<td>').css('text-align', 'right').text(v['Agod'] + 'd ' + v['Agoh'] + 'h ' + v['Agom'] + 'm')
  1439. )
  1440. );
  1441. });
  1442. } else {
  1443. deaths_body.append(
  1444. $('<tr>').append(
  1445. $('<td>').addClass('red').css('text-align', 'center').attr('colspan', '4').text('There are no deaths yet!')
  1446. )
  1447. );
  1448. }
  1449.  
  1450. // add Famlog
  1451. $('table.thinline:eq(1)').closest('td').append(
  1452. $('<br />'),
  1453. $('<table>').addClass('thinline').css('width', '100%').attr('cellspacing', '0').attr('cellpadding', '2').attr('rules', 'none').append(
  1454. $('<tr>').append(
  1455. $('<td>').addClass('tableheader').attr('colspan', '100%').text('Last family changes')
  1456. ),
  1457. $('<tr>').append(
  1458. $('<td>').attr('colspan', '100%').attr('bgcolor', 'black').attr('height', '1')
  1459. ),
  1460. $('<tr>').append(
  1461. $('<td>').addClass('bold').css('width', '28%').attr('align', 'left').text('Date'),
  1462. $('<td>').addClass('bold').attr('align', 'left').text('Change')
  1463. )
  1464. )
  1465. );
  1466. if (v === 'com') {
  1467. $('<div>').addClass('dlContainer').append(
  1468. $('<a>').attr({
  1469. href: OB_NEWS_WEBSITE + '/famlog/latest/' + famid,
  1470. target: '_blank'
  1471. }).append(
  1472. $('<img>').addClass('brcImg').attr({
  1473. src: assetUrl('/images/changelog.png'),
  1474. title: 'View full changelog'
  1475. })
  1476. )
  1477. ).appendTo($('table.thinline:eq(3)>tbody>tr:eq(0)>td'));
  1478. }
  1479.  
  1480. var changes_body = $('table.thinline:eq(3)').find('tbody');
  1481. if (data['changes']) {
  1482. $.each(data['changes'], function (k, v) {
  1483. changes_body.append(
  1484. $('<tr>').append(
  1485. $('<td>').css('width', '28%').attr('align', 'left').attr('valign', 'top').text(v['date']),
  1486. $('<td>').attr('align', 'left').text(v['text'])
  1487. )
  1488. );
  1489. });
  1490. } else {
  1491. changes_body.append(
  1492. $('<tr>').append(
  1493. $('<td>').addClass('red').css('text-align', 'center').attr('colspan', '2').text('There are no changes yet!')
  1494. )
  1495. );
  1496. }
  1497. }, 0);
  1498. });
  1499. }
  1500. }
  1501. // ---------------- My account ----------------
  1502. if (on_page('/information.php') && nn == 'table') {
  1503. var interest = parseInt(getV('interest', 0), 10);
  1504. var banktleft = parseInt(getV('banktleft', 0), 10);
  1505. // Update info
  1506. bnUpdate();
  1507. // Grab busts for Jail page
  1508. var bos;
  1509. // Save Will
  1510. var timestamp = getV('willTimestamp');
  1511. var checkTimestamp = $.now() - (1000 * 30 * 60);
  1512. var willTR = $('.thinline:eq(0)>tbody>tr>td a[href^="/user.php?nick="]:eq(1)');
  1513. var willName = unsafeWindow.omerta.character.info.testament();
  1514. willName = willTR.text().replace(/,/g, '').trim();
  1515.  
  1516. var appendDead = function() {
  1517. willTR.append('<span class="red"> | Dead!</span>');
  1518. };
  1519.  
  1520. // Let's skip doing this if the will has not been set.
  1521. if (getV('willTimestamp', 0) <= checkTimestamp && willName != '') {
  1522. checkUserAlive(willName, function(isAlive) {
  1523. setV('willTimestamp', $.now());
  1524. if (!isAlive) {
  1525. setV('deadWillName', willName);
  1526. appendDead();
  1527. }
  1528. });
  1529. } else {
  1530. var deadWillName = getV('deadWillName');
  1531.  
  1532. // If the person in the will has been changed it shouldn't be shown anymore
  1533. if (willName != '' && deadWillName == willName) {
  1534. appendDead();
  1535. }
  1536. }
  1537.  
  1538. bos = $('.thinline:eq(5)>tbody>tr:eq(1)>td:last').text().replace(/,/g, '');
  1539. setV('bustouts', bos);
  1540.  
  1541. // Interest reminder
  1542. if (!$('#interestRow').length) {
  1543. var inbank = $('.thinline:eq(4)>tbody>tr:eq(2)>td:last>a').html().replace(/\D/g, '');
  1544. if (inbank > 0 && interest > 0) {
  1545. var timestamp = Math.round(parseInt(new Date().getTime(), 10) / 1000);
  1546. var left = (banktleft - timestamp);
  1547. var bankTr = $('<tr>').attr({id: 'interestRow'}).append(
  1548. $('<td>').html('<b>Interest</b>'),
  1549. $('<td>').html('<a href="/bank.php">$ ' + commafy(interest) + '</a> (<span data-timeleft="' + left + '">Now!</span>)')
  1550. );
  1551. $('.thinline:eq(4)').append(bankTr);
  1552. }
  1553. }
  1554.  
  1555. // Tell how old the account is
  1556. var startElem;
  1557. $('table.thinline:eq(0)>tbody>tr>td:nth-child(2)').each(function() {
  1558. if (/^(\d{2})-(\d{2})-(\d{4}) (\d{2}):(\d{2}):(\d{2})$/.test($(this).text())) {
  1559. startElem = $(this);
  1560. }
  1561. });
  1562. if (startElem !== null) {
  1563. var startDate = datestringParse(startElem.text());
  1564. var diff = Math.abs(Date.now() - startDate.getTime());
  1565. var diffDays = Math.ceil(diff / (1000 * 3600 * 24));
  1566. var startDay = startDate.getDate() >= 10 ? startDate.getDate() : '0' + startDate.getDate();
  1567. var startMonth = startDate.getMonth() + 1 >= 10 ? (startDate.getMonth() + 1) : '0' + (startDate.getMonth() + 1);
  1568. var previousText = startElem.text();
  1569. startElem.html(startDay + '-' + startMonth + '-' + startDate.getFullYear() + ' (' + (diffDays - 1) + ' days old)').click(function() {
  1570. var currentText = $(this).text();
  1571. $(this).text(previousText);
  1572. previousText = currentText;
  1573. });
  1574. }
  1575.  
  1576. // car
  1577. var carAttempts = parseInt($('table.thinline:eq(5)>tbody>tr:eq(3)>td:last').text().replace(',', ''), 10);
  1578. var successCars = parseInt(getV('carSuccess', 0), 10);
  1579. if (successCars >= 1) {
  1580. var successRate = (successCars / carAttempts) * 100;
  1581. var earned = getV('carMoney', 0);
  1582. var newText = '<tr><td><b>Car nicking success</b></td><td>' + successCars + ' (' + successRate.toFixed(2) + '%, $' + commafy(earned) + ')</td></tr>';
  1583. $('table.thinline:eq(5)>tbody>tr:eq(3)').after(newText);
  1584. }
  1585.  
  1586. // crime stats
  1587. var crimeAttempts = parseInt($('table.thinline:eq(5)>tbody>tr:eq(2)>td:last').text().replace(',', ''), 10);
  1588. var successCrimes = parseInt(getV('crimeSuccess', 0), 10);
  1589. if (successCrimes >= 1) {
  1590. var successRate = (successCrimes / crimeAttempts) * 100;
  1591. var earned = getV('crimeMoney', 0);
  1592. var newText = '<tr><td><b>Crime success</b></td><td>' + successCrimes + ' (' + successRate.toFixed(2) + '%, $' + commafy(earned) + ')</td></tr>';
  1593. $('table.thinline:eq(5)>tbody>tr:eq(2)').after(newText);
  1594. }
  1595.  
  1596. // Visual improvement
  1597.  
  1598. $('.thinline:eq(4)>tbody>tr:eq(2)>td:first').html('<a href="/bank.php"><b>In bank account</b></a>');
  1599.  
  1600. ScheduleNotification(
  1601. 'heist',
  1602. $('.thinline:eq(1)>tbody>tr:eq(3) [data-time-end]').attr('data-time-end'),
  1603. 'Heist (' + v + ')',
  1604. (v == 'nl' ? 'Je kunt weer heisten' : 'You can do a heist again'),
  1605. 'heist',
  1606. '/?module=Heist',
  1607. assetUrl('/images/red-star.png')
  1608. );
  1609.  
  1610. ScheduleNotification(
  1611. 'oc',
  1612. $('.thinline:eq(1)>tbody>tr:eq(4) [data-time-end]').attr('data-time-end'),
  1613. 'Organised Crime (' + v + ')',
  1614. (v == 'nl' ? 'Je kunt weer een georganiseerde misdaad doen' : 'You can do an organised crime again'),
  1615. 'oc',
  1616. '/?module=OC',
  1617. assetUrl('/images/red-star.png')
  1618. );
  1619.  
  1620. ScheduleNotification(
  1621. 'moc',
  1622. $('.thinline:eq(1)>tbody>tr:eq(5) [data-time-end]').attr('data-time-end'),
  1623. 'Mega Organised Crime (' + v + ')',
  1624. (v == 'nl' ? 'Je kunt weer een mega georganiseerde misdaad doen' : 'You can do a mega organised crime again'),
  1625. 'moc',
  1626. '/?module=MegaOC',
  1627. assetUrl('/images/red-star.png')
  1628. );
  1629.  
  1630. ScheduleNotification(
  1631. 'kill',
  1632. $('.thinline:eq(1)>tbody>tr:eq(8) [data-time-end]').attr('data-time-end'),
  1633. 'Next Kill (' + v + ')',
  1634. (v == 'nl' ? 'Je kunt weer een moordpoging doen' : 'You can make a kill attempt again'),
  1635. 'kill',
  1636. '/?module=Detectives',
  1637. assetUrl('/images/red-star.png')
  1638. );
  1639.  
  1640. ScheduleNotification(
  1641. 'race',
  1642. $('a[href="/races.php"] [data-time-end]').attr('data-time-end'),
  1643. 'Car Race (' + v + ')',
  1644. (v == 'nl' ? 'Je kunt weer racen' : 'You can race again'),
  1645. 'race',
  1646. '/races.php',
  1647. assetUrl('/images/red-star.png')
  1648. );
  1649.  
  1650. ScheduleNotification(
  1651. 'blood',
  1652. $('.thinline:eq(1)>tbody>tr:eq(10) [data-time-end]').attr('data-time-end'),
  1653. 'Blood Buy (' + v + ')',
  1654. (v == 'nl' ? 'Je kunt weer bloed kopen' : 'You can buy blood again'),
  1655. 'blood',
  1656. '/?module=Bloodbank',
  1657. assetUrl('/images/red-star.png')
  1658. );
  1659.  
  1660. ScheduleNotification(
  1661. 'raid',
  1662. $('.thinline:eq(1)>tbody>tr:eq(11) [data-time-end]').attr('data-time-end'),
  1663. 'Spot Raid (' + v + ')',
  1664. (v == 'nl' ? 'Je kunt weer een spot overvallen' : 'You can raid a spot again'),
  1665. 'raid',
  1666. '/?module=Spots',
  1667. assetUrl('/images/red-star.png')
  1668. );
  1669. }
  1670. // ---------------- NEW My account ----------------
  1671. if (on_page('module=UserInformation')) {
  1672. // Check for dead player in testament
  1673. var willTs = getV('willTimestamp', 0);
  1674. var checkWillTs = $.now() - (1000 * 10 * 60);
  1675. var willName = unsafeWindow.omerta.character.info.testament();
  1676. var willTr = $('div.gangster-info-body li:eq(2) a span');
  1677.  
  1678. if (willName !== '') {
  1679. if (willTs <= checkWillTs) {
  1680. checkUserAlive(willName, function(isAlive) {
  1681. setV('willTimestamp', $.now());
  1682. if (!isAlive) {
  1683. setV('deadWillName', willName);
  1684. willTr.append($('<span>').addClass('red').text(' | Dead!'));
  1685. }
  1686. });
  1687. } else {
  1688. var deadWillName = getV('deadWillName');
  1689. if (deadWillName == willName) {
  1690. willTr.append($('<span>').addClass('red').text(' | Dead!'));
  1691. }
  1692. }
  1693. }
  1694.  
  1695. // Tell how old the account is
  1696. var startElem = $('div.gangster-info-body li:eq(5) a span');
  1697. var startDate = unsafeWindow.omerta.character.info.startdate();
  1698. var diff = Math.abs(Date.now() - startDate.getTime());
  1699. var diffDays = Math.ceil(diff / (1000 * 3600 * 24));
  1700. var startDay = startDate.getDate() >= 10 ? startDate.getDate() : '0' + startDate.getDate();
  1701. var startMonth = startDate.getMonth() + 1 >= 10 ? (startDate.getMonth() + 1) : '0' + (startDate.getMonth() + 1);
  1702. var previousText = startElem.html();
  1703. startElem.html(startDay + '-' + startMonth + '-' + startDate.getFullYear() + ' (' + (diffDays - 1) + ' days old)').click(function() {
  1704. var currentText = $(this).html();
  1705. $(this).html(previousText);
  1706. previousText = currentText;
  1707. });
  1708. // Update info
  1709. setTimeout(function () {
  1710. bnUpdate();
  1711. }, 2000);
  1712. }
  1713. // -------------------- Jail --------------------
  1714. if (on_page('/jail.php') && nn == 'form' && prefs['jailHL']) {
  1715. if (getV('fam_colour', '') === '' || getV('friends_colour', '') === '') {
  1716. unsafeWindow.omerta.GUI.container.loadPage('/jail_settings.php');
  1717. }
  1718. var bos;
  1719. if (!unsafeWindow.omerta.modules.UserInformation.data.hasOwnProperty('actions_stats')) {
  1720. bos = parseInt(getV('bustouts', 0), 10);
  1721. } else {
  1722. bos = Math.max(parseInt(getV('bustouts', 0), 10), unsafeWindow.omerta.modules.UserInformation.data.actions_stats[0].value);
  1723. }
  1724. var jailHL_sel = sets['jailHL_sel'] || 'highest';
  1725. var jailHL_other = parseInt(sets['jailHL_other'] || 9, 10);
  1726. var jailHL_friends = parseInt(sets['jailHL_friends'] || 5, 10);
  1727. var jailHL_own_lackey = parseInt(sets['jailHL_own_lackey'] || 7, 10);
  1728. var jailHL_fr_lackey = parseInt(sets['jailHL_fr_lackey'] || 8, 10);
  1729. var jailHL_other_lackey = parseInt(sets['jailHL_other_lackey'] || 11, 10);
  1730.  
  1731. var rows = $('tr[bgcolor]').length;
  1732. var prior = null;
  1733. // list for inmates with lowest priority
  1734. var bustlist = [];
  1735. var priority;
  1736. // Build new row on top
  1737. $('#game_container > form > center > table.thinline > tbody').prepend($('<tr>').attr('id', 'HLrow').css('border-bottom', '1px solid #000'));
  1738. // Loop inmates
  1739. $('tr[bgcolor]').each(function () {
  1740. // Skip nobust
  1741. if (getV('nobust', 0)) {
  1742. var nobust = getV('nobust').toLowerCase().split(',');
  1743. var fam = $(this).find('td:eq(1) > font').text().toLowerCase();
  1744. var name = $(this).find('td:eq(0) > font > a > font').text().toLowerCase();
  1745. if ((fam.length > 0 && $.inArray(fam, nobust) != -1) || $.inArray(name, nobust) != -1) {
  1746. $(this).find('td').css('text-decoration', 'line-through');
  1747. $(this).attr('nobust', true);
  1748. return;
  1749. }
  1750. }
  1751. if ($(this).find('td:eq(0)>font>span').text() === '') {
  1752. // normal player
  1753. if ($(this).attr('bgcolor') !== '') {
  1754. // friends, family or custom group
  1755. if (getV('custom_groups', '').indexOf($(this).attr('bgcolor')) > 0) {
  1756. // custom group
  1757. var cg = getV('custom_groups', '').split('|');
  1758. cg.pop();
  1759. for (var i = 0; i < cg.length; i++) {
  1760. var g = cg[i].split(':');
  1761. if (g[1] == $(this).attr('bgcolor')) {
  1762. var cg_prio = parseInt(sets['jailHL_' + g[0]], 10);
  1763. priority = cg_prio;
  1764. if (!prior || priority <= prior) {
  1765. if (!prior || priority < prior) {
  1766. prior = priority;
  1767. bustlist = [];
  1768. }
  1769. bustlist.push($(this));
  1770. }
  1771. }
  1772. }
  1773. } else if ($(this).attr('bgcolor') == getV('fam_colour') || $(this).attr('bgcolor') == getV('friends_colour')) {
  1774. // friends or family
  1775. priority = jailHL_friends;
  1776. if (!prior || priority <= prior) {
  1777. if (!prior || priority < prior) {
  1778. prior = priority;
  1779. bustlist = [];
  1780. }
  1781. bustlist.push($(this));
  1782. }
  1783. }
  1784. } else {
  1785. // other
  1786. priority = jailHL_other;
  1787. if (!prior || priority <= prior) {
  1788. if (!prior || priority < prior) {
  1789. prior = priority;
  1790. bustlist = [];
  1791. }
  1792. bustlist.push($(this));
  1793. }
  1794. }
  1795. } else {
  1796. // lackey
  1797. if ($(this).attr('bgcolor') !== '') {
  1798. // friend, family or custom group
  1799. if (getV('custom_groups', '').indexOf($(this).attr('bgcolor')) > 0) {
  1800. // custom group
  1801. var cg = getV('custom_groups', '').split('|');
  1802. cg.pop();
  1803. for (var i = 0; i < cg.length; i++) {
  1804. var g = cg[i].split(':');
  1805. if (g[1] == $(this).attr('bgcolor')) {
  1806. var cg_prio = parseInt(sets['jailHL_' + g[0] + '_lackey'], 10);
  1807. priority = cg_prio;
  1808. if (!prior || priority <= prior) {
  1809. if (!prior || priority < prior) {
  1810. prior = priority;
  1811. bustlist = [];
  1812. }
  1813. bustlist.push($(this));
  1814. }
  1815. }
  1816. }
  1817. } else if ($(this).attr('bgcolor') == getV('fam_colour') || $(this).attr('bgcolor') == getV('friends_colour')) {
  1818. // friends or family
  1819. priority = jailHL_fr_lackey;
  1820. if (!prior || priority <= prior) {
  1821. if (!prior || priority < prior) {
  1822. prior = priority;
  1823. bustlist = [];
  1824. }
  1825. bustlist.push($(this));
  1826. }
  1827. }
  1828. } else {
  1829. // other
  1830. if ($(this).find('td:eq(0) > font > a').text() == getV('nick', '')) {
  1831. // own
  1832. priority = jailHL_own_lackey;
  1833. if (!prior || priority <= prior) {
  1834. if (!prior || priority < prior) {
  1835. prior = priority;
  1836. bustlist = [];
  1837. }
  1838. bustlist.push($(this));
  1839. }
  1840. } else {
  1841. // other
  1842. priority = jailHL_other_lackey;
  1843. if (!prior || priority <= prior) {
  1844. if (!prior || priority < prior) {
  1845. prior = priority;
  1846. bustlist = [];
  1847. }
  1848. bustlist.push($(this));
  1849. }
  1850. }
  1851. }
  1852. }
  1853. }).click(function () {
  1854. // Add selected on top
  1855. $('#HLrow').html($(this).html());
  1856. $('#HLrow').css('background-color', $(this).attr('bgcolor'));
  1857. $(this).find('input[name="bust"]').attr('checked', true);
  1858. });
  1859. if (bustlist.length > 0) {
  1860. var bustthis;
  1861. if (jailHL_sel === 'lowest') {
  1862. bustthis = bustlist[bustlist.length - 1];
  1863. } else if (jailHL_sel === 'random') {
  1864. bustthis = bustlist[rand(0, (bustlist.length - 1))];
  1865. } else {
  1866. bustthis = bustlist[0];
  1867. }
  1868.  
  1869. // select inmate
  1870. $('#HLrow').html(bustthis.html());
  1871. $('#HLrow').css('background-color', bustthis.attr('bgcolor'));
  1872. bustthis.find('input[name="bust"]').attr('checked', true);
  1873. }
  1874.  
  1875. $('tr[bgcolor][nobust]').find('input[name="bust"]').attr('checked', false);
  1876. // Add successful BO to total
  1877. var bustMsg = (v == 'nl' ? 'Je hebt deze gangster' : 'You busted this person');
  1878. var bustFriendMsg = (v == 'nl' ? 'celmaat uit de gevangenis' : 'cellmate out of jail');
  1879. if ($('#game_container:contains("' + bustMsg + '")').length) {
  1880. if ($('#game_container:contains("' + bustFriendMsg + '")').length) {
  1881. bos = (bos + 1);
  1882. }
  1883. bos = (bos + 1);
  1884. setV('bustouts', bos);
  1885. }
  1886. // Add amount of inmates and bustouts
  1887. $('#game_container tr:first').prepend(
  1888. $('<td>').css('width', '46%').append(
  1889. $('<span>').text('In jail: ' + rows),
  1890. $('<br />'),
  1891. $('<span>').text('Bustouts: ' + bos)
  1892. )
  1893. );
  1894. $('#game_container tr:first table').css('margin-left', '0');
  1895. }
  1896.  
  1897. // Shit we're busted!
  1898. if (on_page('/jail.php') && nn == 'table') {
  1899. var bo_hotkey = sets['bo_hotkey'] || '/';
  1900. // Add buyout hotkey
  1901. if ($('input[name="buymeout"]').length) {
  1902. $('input[name="buymeout"]').attr('accesskey', bo_hotkey);
  1903. }
  1904. // Go back to jail when time is over
  1905. if ($('#game_container span').attr('data-timeleft')) {
  1906. $('#game_container span').on('DOMSubtreeModified', function() {
  1907. if ($('#game_container span').attr('data-timeleft') == -1) {
  1908. unsafeWindow.omerta.GUI.container.loadPage(window.location.hash.substr(1));
  1909. }
  1910. });
  1911. }
  1912. }
  1913. // Save omerta jail settings
  1914. if (on_page('/jail_settings.php') && nn == 'form') {
  1915. // check if already saved
  1916. if ($('form[name="jailcolours"]').attr('saving') != 'done') {
  1917. // save omerta defaults
  1918. setV('friends_colour', $('select[name="friends_colour_select"]').val());
  1919. setV('fam_colour', $('select[name="fam_colour_select"]').val());
  1920. // cycle custom groups
  1921. var i = 1;
  1922. var custom_groups = '';
  1923. $('#game_container form center div').not('#creategroup').each(function() {
  1924. var group_name = $(this).attr('id');
  1925. var group_colour = $(this).find('select[name="editgroup_colour_select' + i + '"]').find('option:eq(0)').val();
  1926. custom_groups = custom_groups + group_name + ':' + group_colour + '|';
  1927. i++;
  1928. });
  1929. // save custom groups
  1930. setV('custom_groups', custom_groups);
  1931.  
  1932. $('form[name="jailcolours"]').attr('saving', 'done');
  1933. }
  1934. }
  1935. // ---------------- 1-click voter ----------------
  1936. if (on_page('/vfo.php') && nn == 'center') {
  1937. $('a[href*="votelot.php"]').attr('name', 'forticket');
  1938.  
  1939. $('td.tableheader:first').html(
  1940. $('<span>').addClass('orange').css({
  1941. cursor: 'pointer'
  1942. }).attr({
  1943. id: 'votelink',
  1944. title: ''
  1945. }).text($('td.tableheader:first').text())
  1946. ).click(function () {
  1947. voteNow(false);
  1948. });
  1949. var lastVote = getV('lastvote', 0); // get last voting time
  1950. if (lastVote === 0) {
  1951. if (confirm('You haven\'t used the 1-click voter yet!\nDo you want to use it now?')) {
  1952. voteNow(true);
  1953. }
  1954. } else { // not first run
  1955. var till = (parseInt(lastVote, 10) + 86400) - time(); // time till next vote
  1956. var msg = '';
  1957. if (till <= 0) { // user can vote again so ask
  1958. var ago = time() - lastVote; // time since last vote
  1959. msg += 'You haven\'t used the 1-click voter today!' + '\n' + 'Since you last used the 1-click voter, it\'s been:\n';
  1960. msg += Math.floor(ago / 86400) + ' days, '; // days
  1961. msg += Math.floor((ago % 86400) / 3600) + ' hours, '; // hours
  1962. msg += Math.floor((ago % 3600) / 60) + ' minutes and '; // minutes
  1963. msg += Math.floor(ago % 60) + ' seconds.'; // seconds
  1964. msg += '\n' + 'Do you want to use the 1-click voter now?';
  1965. } else { // can't vote yet
  1966. msg += 'You can\'t vote again yet!\nPlease wait another:\n';
  1967. msg += Math.floor(till / 3600) + ' hours, '; // hours
  1968. msg += Math.floor((till % 3600) / 60) + ' minutes and '; // minutes
  1969. msg += Math.floor(till % 60) + ' seconds.'; // seconds
  1970. msg += '\n' + 'Do you still want to vote?';
  1971. }
  1972. if (confirm(msg)) {
  1973. voteNow(true);
  1974. }
  1975. }
  1976. }
  1977. // ---------------- Group Crimes ----------------
  1978. // GroupCrime general accept focus
  1979. if (on_page('module=GroupCrimes') && nn == 'center') {
  1980. // focus on accept
  1981. $('a').filter(function () {
  1982. return (/Accept/i).test($(this).text());
  1983. }).focus();
  1984. // focus on transfer
  1985. $('a').filter(function () {
  1986. return (/Make Transfer/i).test($(this).text());
  1987. }).focus();
  1988. }
  1989. // Heist LE autoform
  1990. if (on_page('module=Heist') && nn == 'center') {
  1991. $('input[name="bullets"]').val('50');
  1992. $('select[name="gun"]').val('real');
  1993. if (GetParam('driver')) {
  1994. var dr = GetParam('driver');
  1995. $('input[name="driver"]').val(dr);
  1996. $('input[type="submit"]').focus();
  1997. } else {
  1998. $('input[name="driver"]').focus();
  1999. }
  2000. }
  2001. // OC accept focus
  2002. if (on_page('/orgcrime2.php') && nn == 'br') {
  2003. // focus on accept
  2004. $('a').filter(function () {
  2005. return (/Yes/i).test($(this).text());
  2006. }).focus();
  2007. }
  2008. // OC Participants autoform
  2009. if (on_page('?takepart=yes') && nn == 'form') {
  2010. // WE
  2011. $('input[name="bulletz"]').val('100');
  2012. $('select[name="guns"]').val('2');
  2013. // EE
  2014. $('input:radio[name="exploz"]').prop('checked', true);
  2015. // ALL
  2016. $('input[type="submit"]').focus();
  2017. }
  2018. // MOC Participants autoform
  2019. if (on_page('module=MegaOC') && nn == 'form') {
  2020. // WE
  2021. $('input[type="text"]').val('500');
  2022. // EE
  2023. $('input:radio:eq(2)').prop('checked', true);
  2024. // ALL
  2025. $('input[type="submit"]').focus();
  2026. }
  2027. // Raid LE autoform
  2028. if (on_page('module=Spots') && nn == 'form') {
  2029. var kind_text = (v == 'nl' ? 'Soort' : 'Kind');
  2030. var text_real = 'Real';
  2031. var text_fake = 'Fake';
  2032. var raid_setting = getV('raid_setting', 'real_raid');
  2033.  
  2034. $('table.thinline tr').eq(4).after($('<tr>').append(
  2035. $('<td>').html('<b>' + kind_text + '</b>'),
  2036. $('<td>').text(text_real).append(
  2037. $('<input>').attr({
  2038. type: 'radio',
  2039. class: 'real_raid',
  2040. checked: (raid_setting == 'real_raid') ? true : false
  2041. })
  2042. ).append(
  2043. text_fake
  2044. ).append(
  2045. $('<input>').attr({
  2046. type: 'radio',
  2047. class: 'fake_raid',
  2048. checked: (raid_setting == 'fake_raid') ? true : false
  2049. })
  2050. )
  2051. ));
  2052.  
  2053. if (raid_setting == 'fake_raid') {
  2054. $('input[name="bullets"]').val('0');
  2055. } else {
  2056. $('input[name="bullets"]').val('200');
  2057. }
  2058.  
  2059. $('input[type=radio]').change(function() {
  2060. setV('raid_setting', $(this).attr('class'));
  2061. raid_setting = getV('raid_setting');
  2062.  
  2063. if (raid_setting == 'fake_raid') {
  2064. $('input[name="bullets"]').val('0');
  2065. } else {
  2066. $('input[name="bullets"]').val('200');
  2067. }
  2068.  
  2069. $('input[type=radio]:checked').not(this).prop('checked', false);
  2070. });
  2071.  
  2072. if (GetParam('driver')) {
  2073. var dr = GetParam('driver');
  2074. $('input[name="driver"]').val(dr);
  2075. } else {
  2076. $('input[name="driver"]').focus();
  2077. }
  2078. }
  2079. // ---------------- Mail ----------------
  2080. // Inbox
  2081. if ((on_page('action=inbox') || on_page('action=delMsg') || (on_page('module=Mail') && !on_page('action='))) && nn == 'center') {
  2082. // save unread msg and msg ids
  2083. var msg = $('td[style="cursor:pointer;cursor:hand"]').length;
  2084. var unreadmsg = $('tr.color2').length;
  2085. var id = [];
  2086. for (var i = 0; i < msg; i++) { // find first open spot
  2087. id[i] = $('a[href*="showMsg"]:eq(' + i + ')').attr('href').split('?')[1].match(/\d+/g);
  2088. setV('msgids', id.join(',')); // join and save values
  2089. }
  2090. var unreadid = [];
  2091. for (var a = 0; a < unreadmsg; a++) { // find first open spot
  2092. unreadid[a] = $('tr.color2 > td:eq(1) > a').attr('href').split('?')[1].match(/\d+/g);
  2093. setV('unread', unreadid.join(',')); // join and save values
  2094. }
  2095. // delete and reply icons
  2096. var num = 1;
  2097. setTimeout(function () {
  2098. $('tr[class*="color"]').each(function () {
  2099. var id = $(this).children('td:eq(1)').children('a').attr('href').split('?')[1].match(/\d+/g)[0];
  2100. if ($(this).attr('class') == 'color2') {
  2101. $(this).children('td:eq(0)').append(
  2102. $('<img />').addClass('inboxImg unread').attr({
  2103. src: assetUrl('/images/delete.png'),
  2104. title: 'Delete'
  2105. }).click(function () {
  2106. delMsg('id', id);
  2107. })
  2108. );
  2109. } else {
  2110. $(this).children('td:eq(0)').append(
  2111. $('<img />').addClass('inboxImg').attr({
  2112. src: assetUrl('/images/delete.png'),
  2113. title: 'Delete'
  2114. }).click(function () {
  2115. delMsg('id', id);
  2116. })
  2117. );
  2118. }
  2119. if ($(this).children('td:eq(2)').children('a').length) { // add reply icon
  2120. $(this).children('td:eq(0)').append(
  2121. $('<a>').attr('href', 'BeO/webroot/index.php?module=Mail&action=sendMsg&iReply=' + id).html(
  2122. $('<img />').addClass('inboxImg').attr({
  2123. src: assetUrl('/images/reply.png'),
  2124. title: 'Reply'
  2125. })
  2126. )
  2127. );
  2128. }
  2129. if (num < 11) { // add msg hotkeys
  2130. var mailTitle = $(this).children('td:eq(1)').children();
  2131. mailTitle.html('[' + (num == 10 ? 0 : num) + '] ' + mailTitle.html());
  2132. mailTitle.attr('accesskey', (num == 10 ? 0 : num));
  2133. num++;
  2134. }
  2135. });
  2136. }, 0);
  2137. // hotkeys for system delete
  2138. var keys = ['-', '=', '[', ']', ';', '\''];
  2139. var selectors = $('td[align="right"][colspan="100%"] > a');
  2140. for (i = -1; ++i < selectors.length;) {
  2141. $('td[align="right"][colspan="100%"] > a:eq(' + i + ')').attr({
  2142. accesskey: keys[i],
  2143. title: 'Hotkey: ' + keys[i]
  2144. });
  2145. }
  2146. // select all button
  2147. $('td[align="right"][colspan="100%"]').prepend(
  2148. $('<span>').css('float', 'left').append(
  2149. $('<input />').attr({
  2150. type: 'button',
  2151. value: '(Un)Select All'
  2152. }).click(function () {
  2153. $('[name="selective[]"]').each(function () {
  2154. $(this).prop('checked', !$(this).prop('checked'));
  2155. });
  2156. })
  2157. )
  2158. );
  2159. // add custom system delete
  2160. // Declare translation variables
  2161.  
  2162. var lottery_text = (v == 'nl' ? 'Super Loterij' : 'Super Lottery');
  2163. var target_not_found_text = (v == 'nl' ? 'Doelwit niet gevonden' : 'Target not found');
  2164. var target_found_text = (v == 'nl' ? 'Doelwit gevonden' : 'Target found');
  2165. var promoted_text = (v == 'nl' ? 'Gepromoveerd' : 'Promoted');
  2166. var obay_higherbid_text = (v == 'nl' ? 'Obay hoger bod informatie' : 'Obay higher bid information');
  2167.  
  2168.  
  2169. $('td[align="right"][colspan="100%"] > a:eq(0)').before($('<br />'));
  2170. $('td[align="right"][colspan="100%"]').append(
  2171. $('<br />'),
  2172. $('<span>').text('Delete System: '),
  2173. $('<span>').css('cursor', 'pointer').text(lottery_text).click(function () {
  2174. delMsg('name', lottery_text);
  2175. }),
  2176. $('<span>').text(' | '),
  2177. $('<span>').css('cursor', 'pointer').text(target_not_found_text).click(function () {
  2178. delMsg('name', target_not_found_text);
  2179. }),
  2180. $('<span>').text(' | '),
  2181. $('<span>').css('cursor', 'pointer').text(target_found_text).click(function () {
  2182. delMsg('name', target_found_text);
  2183. }),
  2184. $('<span>').text(' | '),
  2185. $('<span>').css('cursor', 'pointer').text(promoted_text).click(function () {
  2186. delMsg('name', promoted_text);
  2187. }),
  2188. $('<span>').text(' | '),
  2189. $('<span>').css('cursor', 'pointer').text(obay_higherbid_text).click(function () {
  2190. delMsg('name', obay_higherbid_text);
  2191. })
  2192. );
  2193. }
  2194.  
  2195. // Outbox
  2196. if (on_page('action=outbox') && nn == 'center') {
  2197. setTimeout(function () {
  2198. $('a[href*="showSentMsg"]').each(function () {
  2199. var id = $(this).attr('href').split('?')[1].match(/\d+/g)[0];
  2200. $(this).parent().prepend(
  2201. $('<img />').addClass('inboxImg').attr({
  2202. src: assetUrl('/images/delete.png'),
  2203. title: 'Delete'
  2204. }).click(function () {
  2205. $.get('//' + document.location.hostname + '/BeO/webroot/index.php?module=Mail&action=delMsg&iId=' + id + '&iParty=1', function () {
  2206. $('font[color="red"]').text('Message deleted.');
  2207. });
  2208.  
  2209. $(this).closest('tr').hide();
  2210. $(this).closest('tr').next().hide();
  2211. })
  2212. );
  2213. });
  2214. }, 0);
  2215. }
  2216.  
  2217. // Show message
  2218. if (on_page('action=showMsg') && nn == 'center') {
  2219. var id = wlh.split('iMsgId=')[1].match(/\d+/g)[0];
  2220. var ids = getV('msgids', '').split(',');
  2221. for (var i = 0; i < ids.length; i++) {
  2222. if (ids[i] == id) {
  2223. var next = ids[i - 1];
  2224. var prev = ids[i + 1];
  2225. }
  2226. }
  2227. // check unread msg and grab obay bullets
  2228. var unread = getV('unread', '').split(',');
  2229. for (var x = 0; x < unread.length; ++x) {
  2230. if (unread[x] !== '' && unread[x] == id) { // msg is unread
  2231. var msgTyp = $('tr.tableitem').text().split(/Type:|Soort:/);
  2232. if (msgTyp.length > 1) {
  2233. var msgTyp = msgTyp[1].split(/Sent:|Verzonden:/)[0];
  2234. }
  2235. var arr = $('table.thinline > tbody > tr:eq(7) > td').html().split(' ');
  2236. var bulletmsg = new RegExp('Obay bid succesful');
  2237. if (bulletmsg.test(msgTyp)) { // grab obay bullets from message
  2238. setV('obaybul', (getV('obaybul', 0) + parseInt(arr[2], 10)));
  2239. }
  2240. // resave unread msg's, without our msg
  2241. var str = '';
  2242. for (var y = 0; y < unread.length; ++y) {
  2243. if (unread[y] !== '' && unread[y] != id) {
  2244. str += ',' + unread[y];
  2245. }
  2246. }
  2247. setV('unread', str.substr(1));
  2248. x = unread.length; // not needed to continue because we found our id
  2249. }
  2250. }
  2251. // add previous and next arrows
  2252. setTimeout(function () {
  2253. $('table.thinline > tbody > tr > td.tableheader:eq(1)').append(
  2254. $('<span>').css({
  2255. float: 'right',
  2256. 'padding-top': '2px'
  2257. }).append(
  2258. $('<a>').attr({
  2259. id: 'prev',
  2260. href: '/BeO/webroot/index.php?module=Mail&action=showMsg&iMsgId=' + prev
  2261. }).append(
  2262. $('<img>').addClass('inboxImg').attr({
  2263. title: 'Previous',
  2264. src: assetUrl('/images/prev.png')
  2265. })
  2266. )
  2267. ).append(
  2268. $('<a>').attr({
  2269. id: 'next',
  2270. href: '/BeO/webroot/index.php?module=Mail&action=showMsg&iMsgId=' + next
  2271. }).append(
  2272. $('<img>').addClass('inboxImg').attr({
  2273. title: 'Next',
  2274. src: assetUrl('/images/next.png')
  2275. })
  2276. )
  2277. )
  2278. );
  2279. for (var j = 0; j < ids.length; j++) {
  2280. if (ids[j] == id) {
  2281. if (j === 0) {
  2282. $('a#next').css('visibility', 'hidden');
  2283. }
  2284. if (j == ids.length - 1) {
  2285. $('a#prev').css('visibility', 'hidden');
  2286. }
  2287. }
  2288. }
  2289. }, 0);
  2290. // replace reply and delete links
  2291. var linkz = $('table.thinline > tbody > tr:eq(9) > td > a');
  2292. if (linkz.length == 1) {
  2293. setTimeout(function () {
  2294. $('table.thinline > tbody > tr:eq(9) > td > a').html(
  2295. $('<img />').addClass('inboxImg').attr({
  2296. src: assetUrl('/images/delete.png'),
  2297. title: 'Delete ([)'
  2298. })
  2299. ).attr('accesskey', '[');
  2300. }, 0);
  2301. } else {
  2302. setTimeout(function () {
  2303. $('table.thinline > tbody > tr:eq(9) > td > a:first').html(
  2304. $('<img />').addClass('inboxImg').attr({
  2305. src: assetUrl('/images/delete.png'),
  2306. title: 'Delete ([)'
  2307. })
  2308. ).attr('accesskey', '[');
  2309. $('table.thinline > tbody > tr:eq(9) > td > a:last').html(
  2310. $('<img />').addClass('inboxImg').attr({
  2311. src: assetUrl('/images/reply.png'),
  2312. title: 'Reply (])'
  2313. })
  2314. ).attr('accesskey', ']');
  2315. }, 0);
  2316. }
  2317. // Add arrow hotkeys
  2318. $(window).keydown(function (event) {
  2319. var key = event.which;
  2320. if (key == 39) { // right, reply
  2321. unsafeWindow.omerta.GUI.container.loadPage('./BeO/webroot/index.php?module=Mail&action=sendMsg&iReply=' + id);
  2322. }
  2323. if (key == 38 && id != ids[0]) { // up, select previous
  2324. unsafeWindow.omerta.GUI.container.loadPage('./BeO/webroot/index.php?module=Mail&action=showMsg&iMsgId=' + next);
  2325. }
  2326. if (key == 40 && id != ids[ids.length - 1]) { // down, select next
  2327. unsafeWindow.omerta.GUI.container.loadPage('./BeO/webroot/index.php?module=Mail&action=showMsg&iMsgId=' + prev);
  2328. }
  2329. if (key == 37) { // left, delete
  2330. unsafeWindow.omerta.GUI.container.loadPage('./BeO/webroot/index.php?module=Mail&action=delMsg&iId=' + id + '&iParty=2');
  2331. }
  2332. });
  2333. }
  2334. // focus on text area
  2335. if (on_page('iReply=') && nn == 'center') {
  2336. $('textarea').focus();
  2337. }
  2338. // redirect on send message
  2339. if (on_page('action=sendMsg') && nn == 'b') { // needs testing
  2340. if ($('font:eq(0)').text().indexOf('Message sent to') != -1) {
  2341. setTimeout(function () {
  2342. $('a[href*="inbox"]')[0].click();
  2343. }, 1000);
  2344. }
  2345. }
  2346. // ---------------- Bank ----------------
  2347. if (on_page('/bank.php') && nn == 'center') {
  2348. // auto reload after transfer
  2349. if ($('#game_container center').html().search('<table') == -1) {
  2350. setTimeout(function () {
  2351. unsafeWindow.omerta.GUI.container.loadPage(window.location.hash.substr(1));
  2352. }, 1000);
  2353. }
  2354. // Add amount of interest next to %
  2355. if ($('table.thinline:eq(1) > tbody > tr:eq(1) > td:eq(1)').length) { // check for banked money
  2356. var money = $('table.thinline:eq(1) > tbody > tr:eq(1) > td:eq(1)').text();
  2357. var rx = $('table.thinline:eq(1) > tbody > tr:eq(3) > td:eq(1)').text(); // get received amount
  2358. var tmp = 1 * rx.replace(/\D/g, '') - 1 * money.replace(/\D/g, ''); // calculate interest
  2359. $('table.thinline:eq(1) > tbody > tr:eq(2) > td:eq(1)').html($('table.thinline:eq(1) > tbody > tr:eq(2) > td:eq(1)').text() + ' &rarr; ($' + commafy(tmp) + ')');
  2360. setTimeout(function () {
  2361. setV('interest', tmp);
  2362. }, 0);
  2363.  
  2364. // Interest reminder
  2365. var seconds = parseInt($('table.thinline:eq(1) tbody span').attr('data-timeleft'), 10);
  2366. setTimeout(function () {
  2367. setV('banktleft', (time() + seconds));
  2368. }, 0);
  2369. }
  2370. // Calculators
  2371. if ($('td[width="33%"]:eq(2)').length) {
  2372. $('td[width="33%"]:eq(2)').append(
  2373. $('<br />'),
  2374. $('<table>').addClass('thinline').attr({
  2375. width: '100%',
  2376. align: 'center',
  2377. rules: 'none'
  2378. }).append(
  2379. $('<tr>').append(
  2380. $('<td>').addClass('tableheader').attr('colspan', '4').text('Calculators')
  2381. ), $('<tr>').append(
  2382. $('<td>').attr({
  2383. align: 'left',
  2384. width: '20%'
  2385. }).text('You send:'),
  2386. $('<td>').attr({
  2387. align: 'left',
  2388. width: '25%'
  2389. }).append(
  2390. $('<input>').attr({
  2391. name: 'amount',
  2392. type: 'text',
  2393. value: '',
  2394. maxlength: '11',
  2395. size: '13'
  2396. }).keyup(function () {
  2397. var amt = $(this).val().replace(/\D+/g, '');
  2398. $('#get').text('$' + commafy(Math.round(amt * 0.9)));
  2399. })
  2400. ),
  2401. $('<td>').attr({
  2402. align: 'left',
  2403. width: '23%'
  2404. }).text('User gets:'),
  2405. $('<td>').attr({
  2406. align: 'left',
  2407. id: 'get'
  2408. }).text('$0')
  2409. ), $('<tr>').append(
  2410. $('<td>').attr({
  2411. align: 'left',
  2412. width: '20%'
  2413. }).text('You want:'),
  2414. $('<td>').attr({
  2415. align: 'left',
  2416. width: '25%'
  2417. }).append(
  2418. $('<input>').attr({
  2419. name: 'amount',
  2420. type: 'text',
  2421. value: '',
  2422. maxlength: '11',
  2423. size: '13'
  2424. }).keyup(function () {
  2425. var amt = $(this).val().replace(/\D+/g, '');
  2426. $('#give').text('$' + commafy(Math.round(amt / 0.9)));
  2427. })
  2428. ),
  2429. $('<td>').attr({
  2430. align: 'left',
  2431. width: '23%'
  2432. }).text('User sends:'),
  2433. $('<td>').attr({
  2434. align: 'left',
  2435. id: 'give'
  2436. }).text('$0')
  2437. ), $('<tr>').append(
  2438. $('<td>').attr({
  2439. align: 'left',
  2440. width: '20%'
  2441. }).text('Deposit:'),
  2442. $('<td>').attr({
  2443. align: 'left',
  2444. width: '25%'
  2445. }).append(
  2446. $('<input>').attr({
  2447. name: 'amount',
  2448. type: 'text',
  2449. value: '',
  2450. maxlength: '11',
  2451. size: '13'
  2452. }).keyup(function () {
  2453. var amt = $(this).val().replace(/\D+/g, '');
  2454. $('#int').text('$' + commafy(Math.round(amt * (amt >= 1000000 ? (amt >= 3000000 ? (amt >= 6000000 ? (amt >= 10000000 ? (amt >= 15000000 ? (amt >= 21000000 ? (amt >= 27000000 ? (amt >= 35000000 ? 1.01 : 1.015) : 1.02) : 1.025) : 1.03) : 1.035) : 1.04) : 1.045) : 1.05))));
  2455. })
  2456. ),
  2457. $('<td>').attr({
  2458. align: 'left',
  2459. width: '23%'
  2460. }).text('Receive:'),
  2461. $('<td>').attr({
  2462. align: 'left',
  2463. id: 'int'
  2464. }).text('$0')
  2465. )
  2466. )
  2467. );
  2468. }
  2469. // m/k usage
  2470. var inputs = $('input[name="amount"], input#amount');
  2471. inputs.each(function () {
  2472. $(this).keydown(function (event) {
  2473. var symcode = event.which;
  2474. if (symcode == 75) {
  2475. $(this).val($(this).val() + '000');
  2476. }
  2477. if (symcode == 77) {
  2478. $(this).val($(this).val() + '000000');
  2479. }
  2480. return (symcode == 75 || symcode == 77) ? false : true;
  2481. });
  2482. });
  2483. }
  2484. // ---------------- All users ----------------
  2485. if (on_page('/allusers.php') && nn == 'div') {
  2486. // add page number
  2487. var start = parseInt(GetParam('start'), 10);
  2488. var page = (start / 15) + 1;
  2489. $('h4').before($('<h4>').text('Page: ' + page));
  2490.  
  2491. // edit show/hide dead link
  2492. var dead = GetParam('dead');
  2493. if (dead !== null) {
  2494. var url = wlh.replace('#', '');
  2495. var hs = (dead == 'HIDE') ? 'SHOW' : 'HIDE';
  2496. $('a[href*="/allusers.php?dead="]').attr('href', url.replace(dead, hs));
  2497. }
  2498. }
  2499. // ---------------- TOP 3 ----------------
  2500. // Control Panel
  2501. if (on_page('module=Family') && nn == 'div') {
  2502. if (GetParam('who')) {
  2503. $('input[name="invite"]').val(GetParam('who'));
  2504. }
  2505. // linkify CP log
  2506. if (nid == 'jsprogbar_fam_rank_progress') {
  2507. $('table.color2:eq(0) > tbody > tr > td').not(':first').not(':last').each(function () {
  2508. if ($(this).text() !== '') {
  2509. var len = $(this).html().trim().split(' ').length - 1;
  2510. var who = $(this).html().trim().split(' ');
  2511. if (who[0].match(/[A-Z]/g)) {
  2512. if (who[0] != 'Your') {
  2513. who[0] = '<a href="/user.php?nick=' + who[0] + '"><b>' + who[0] + '</b></a>';
  2514. }
  2515. }
  2516. if (who[len].match(/[A-Z]/g)) {
  2517. if (who[len] != 'Capo(s)') {
  2518. if (who[len] != 'Object(s)') {
  2519. if (who[len] != 'Unlocked') {
  2520. if (who[len] != 'Boss.') {
  2521. who[len] = '<a href="/user.php?nick=' + who[len].match(/\D+/g)[0].replace('.', '') + '"><b>' + who[len] + '</b></a>';
  2522. }
  2523. }
  2524. }
  2525. }
  2526. }
  2527. $(this).html(who.join(' '));
  2528. }
  2529. });
  2530. // Add promo calculation for GF/FL.
  2531. var cdP = parseInt($('table.color2:eq(1) > tbody > tr:eq(16) > td > table > tbody > tr:eq(6) > td:eq(3)').text().replace(/\D/g, ''), 10);
  2532. var perc = (cdP != '0') ? $('input[name="ppercentage"]').val() : 0;
  2533. var gfP = parseInt((((cdP / 100) * perc) + parseInt(cdP, 10)), 10);
  2534. $('table.color2:eq(1) > tbody > tr:eq(16) > td > table > tbody').append(
  2535. $('<tr>').append(
  2536. $('<td>').text('GF / FL'),
  2537. $('<td>').text('$ ' + commafy(gfP))
  2538. )
  2539. );
  2540. }
  2541. }
  2542. // linkify opened CP log
  2543. if (on_page('/familylog.php') && nn == 'table') {
  2544. $('table.color2 > tbody > tr > td').not(':first').each(function () {
  2545. if ($(this).text() !== '') {
  2546. var len = $(this).html().trim().split(' ').length - 1;
  2547. var who = $(this).html().trim().split(' ');
  2548. if (who[0].match(/[A-Z]/g)) {
  2549. if (who[0] != 'Your') {
  2550. who[0] = '<a href="/user.php?nick=' + who[0] + '"><b>' + who[0] + '</b></a>';
  2551. }
  2552. }
  2553. if (who[len].match(/[A-Z]/g)) {
  2554. if (who[len] != 'Capo(s)') {
  2555. if (who[len] != 'Object(s)') {
  2556. if (who[len] != 'Unlocked') {
  2557. if (who[len] != 'Boss.') {
  2558. who[len] = '<a href="/user.php?nick=' + who[len].match(/\D+/g)[0].replace('.', '') + '"><b>' + who[len] + '</b></a>';
  2559. }
  2560. }
  2561. }
  2562. }
  2563. }
  2564. $(this).html(who.join(' '));
  2565. }
  2566. });
  2567. }
  2568. // Family bank
  2569. if (on_page('/cpbank.php') && nn == 'center') {
  2570. $('table.thinline:eq(0)').after($('<br />'), $('<table>').addClass('thinline').attr({
  2571. width: '600',
  2572. align: 'center',
  2573. rules: 'none'
  2574. }).append(
  2575. $('<tr>').append(
  2576. $('<td>').addClass('tableheader').attr('colspan', '4').text('Calculators')
  2577. ), $('<tr>').append(
  2578. $('<td>').attr({
  2579. align: 'right',
  2580. width: '25%'
  2581. }).text('You send:'),
  2582. $('<td>').attr({
  2583. align: 'center',
  2584. width: '25%'
  2585. }).append(
  2586. $('<input>').attr({
  2587. name: 'amount',
  2588. type: 'text',
  2589. value: '',
  2590. maxlength: '11',
  2591. size: '15'
  2592. }).keyup(function () {
  2593. var amt = $(this).val().replace(/\D+/g, '');
  2594. $('#get').text('$' + commafy(Math.round(amt * 0.85)));
  2595. })
  2596. ),
  2597. $('<td>').attr({
  2598. align: 'right',
  2599. width: '25%'
  2600. }).text('User gets:'),
  2601. $('<td>').attr({
  2602. align: 'center',
  2603. width: '25%',
  2604. id: 'get'
  2605. }).text('$0')
  2606. ), $('<tr>').append(
  2607. $('<td>').attr({
  2608. align: 'right',
  2609. width: '25%'
  2610. }).text('You want:'),
  2611. $('<td>').attr({
  2612. align: 'center',
  2613. width: '25%'
  2614. }).append(
  2615. $('<input>').attr({
  2616. name: 'amount',
  2617. type: 'text',
  2618. value: '',
  2619. maxlength: '11',
  2620. size: '15'
  2621. }).keyup(function () {
  2622. var amt = $(this).val().replace(/\D+/g, '');
  2623. $('#give').text('$' + commafy(Math.round(amt / 0.85)));
  2624. })
  2625. ),
  2626. $('<td>').attr({
  2627. align: 'right',
  2628. width: '25%'
  2629. }).text('User sends:'),
  2630. $('<td>').attr({
  2631. align: 'center',
  2632. width: '25%',
  2633. id: 'give'
  2634. }).text('$0')
  2635. )
  2636. ));
  2637.  
  2638. // m/k usage
  2639. var inputs = $('input[name="amount"]');
  2640. inputs.each(function () {
  2641. $(this).keydown(function (event) {
  2642. var symcode = event.which;
  2643. if (symcode == 75) {
  2644. $(this).val($(this).val() + '000');
  2645. }
  2646. if (symcode == 77) {
  2647. $(this).val($(this).val() + '000000');
  2648. }
  2649. $(this).val($(this).val().replace(/k|m/g, ''));
  2650. return (symcode == 75 || symcode == 77) ? false : true;
  2651. });
  2652. });
  2653. }
  2654. // ---------------- SlotsTracker ----------------
  2655. if ((on_page('/gambling/slotmachine.php') || on_page('module=Casino.SlotMachine')) && nn == 'center') {
  2656. var slotjp = parseInt(getV('slotjp', 0), 10);
  2657. var slotbar = parseInt(getV('slotbar', 0), 10);
  2658. var slotgames = parseInt(getV('slotgames', 0), 10);
  2659. var slotgwon = parseInt(getV('slotgwon', 0), 10);
  2660. var slotmwon = parseInt(getV('slotmwon', 0), 10);
  2661. var slotspent = parseInt(getV('slotspent', 0), 10);
  2662. var slotbet = parseInt(getV('slotbet', 0), 10);
  2663. var jpmwon = parseInt(getV('jpmwon', 0), 10);
  2664. var str = $('#game_container > center > table > tbody > tr:eq(2) > td').text().replace(/,/g, '').replace(/\n/g, '').replace(/\t/g, '');
  2665. var betinput = $('input[name="bet"]');
  2666. betinput.focus();
  2667. betinput.keyup(function () {
  2668. setV('slotbet', parseInt($(this).val(), 10));
  2669. });
  2670.  
  2671. if ($('#game_container:contains("Congratulations!")').length > 0 || $('#game_container:contains("YOU WON THE JACKPOT")').length > 0) {
  2672. var S1 = $('img[src*="slotmachine"]:eq(0)').attr('src').replace(/">/g, '').split('/');
  2673. var S2 = $('img[src*="slotmachine"]:eq(1)').attr('src').replace(/">/g, '').split('/');
  2674. var S3 = $('img[src*="slotmachine"]:eq(2)').attr('src').replace(/">/g, '').split('/');
  2675. if (S1[6] == 'a.gif' && S2[6] == 'a.gif' && S3[6] == 'a.gif') { // Jackpot
  2676. var rexjp = new RegExp('You Win \\$(\\d+)');
  2677. var jpm = str.match(rexjp); // get money
  2678. jpmwon += parseInt(jpm[1], 10); // jp money won;
  2679. setV('jpmwon', jpmwon);
  2680. slotmwon += parseInt(jpm[1], 10); // money won;
  2681. setV('slotmwon', slotmwon);
  2682. slotjp += 1; // jackpot +1;
  2683. setV('slotjp', slotjp);
  2684. }
  2685. if (S1[6] == 'b.gif' && S2[6] == 'b.gif' && S3[6] == 'b.gif') { // Triple Bar
  2686. slotbar += 1; // triple bar +1;
  2687. setV('slotbar', slotbar);
  2688. }
  2689. var rex = new RegExp('Congratulations! You won \\$ (\\d+)');
  2690. var smw = str.match(rex); // get money
  2691. slotgames += 1; // games played +1;
  2692. setV('slotgames', slotgames);
  2693. slotgwon += 1; // games won +1;
  2694. setV('slotgwon', slotgwon);
  2695. slotmwon += parseInt(smw[1], 10); // money won;
  2696. slotmwon += parseInt(slotbet, 10); // bet back;
  2697. setV('slotmwon', slotmwon);
  2698. slotspent += parseInt(slotbet, 10); // money spent
  2699. setV('slotspent', slotspent);
  2700. }
  2701. if ($('#game_container:contains("Bummer")').length > 0) { // lost
  2702. slotgames += 1; // games played +1;
  2703. setV('slotgames', slotgames);
  2704. slotspent += parseInt(slotbet, 10); // money spent
  2705. setV('slotspent', slotspent);
  2706. }
  2707.  
  2708. var slotprofit = slotmwon - slotspent;
  2709. if (slotspent >= 0) {
  2710. if (slotprofit >= 0) {
  2711. slotprofit = '$' + commafy(slotprofit);
  2712. } else {
  2713. slotprofit = '-$' + commafy(slotspent - slotmwon);
  2714. }
  2715. }
  2716. var sgamesWon = Math.round((slotgwon / slotgames) * 100);
  2717. var sgamesWon2 = isNaN(sgamesWon) ? 0 : sgamesWon;
  2718.  
  2719. var SlTtop = parseInt(getV('SlTtop', '225'), 10);
  2720. var SlTleft = parseInt(getV('SlTleft', '300'), 10);
  2721. if ($('#SlTracker').length === 0) {
  2722. $('#game_container').append(
  2723. $('<div>').addClass('tracker').attr({
  2724. id: 'SlTracker',
  2725. 'data-beyond-fired': true
  2726. }).css({
  2727. top: SlTtop,
  2728. left: SlTleft
  2729. }).append(
  2730. $('<div>').attr({
  2731. id: 'slthead'
  2732. }).append(
  2733. $('<center>').text('SlotsTracker').css({
  2734. fontWeight: 'bold'
  2735. })
  2736. ).click(function () {
  2737. $('#SlTracker').draggable();
  2738. }),
  2739. $('<hr>').css({
  2740. color: 'gray'
  2741. }),
  2742. $('<div>').attr({
  2743. id: 'sltbody'
  2744. }).html('Games played:<font style="float:right;"><b>' + commafy(slotgames) + '</b></font><br />Games won:<font style="float:right;"><b>' + commafy(slotgwon) + ' (' + sgamesWon2 + '%)</b></font><br />Jackpot:<font style="float:right;"><b>' + slotjp + ' ($' + commafy(jpmwon) + ')</b></font><br />Triple BAR:<font style="float:right;"><b>' + slotbar + '</b></font><br />Money spent:<font style="float:right;"><b>$' + commafy(slotspent) + '</b></font><br />Money won:<font style="float:right;"><b>$' + commafy(slotmwon) + '</b></font><br />Profit:<font style="float:right;"><b>' + slotprofit + '</b></font>'),
  2745. $('<hr>').css({
  2746. color: 'gray'
  2747. }),
  2748. $('<div>').attr({
  2749. id: 'sltreset'
  2750. }).addClass('reset').text('Reset stats').click(function () {
  2751. $(this).text('Stats have been reset!');
  2752. $('#sltbody').html('Games played:<font style="float:right;"><b>0</b></font><br />Games won:<font style="float:right;"><b>0 (0%)</b></font><br />Jackpot:<font style="float:right;"><b>0 ($0)</b></font><br />Triple BAR:<font style="float:right;"><b>0</b></font><br />Money Spent:<font style="float:right;"><b>$0</b></font><br />Money won:<font style="float:right;"><b>$0</b></font><br />Profit:<font style="float:right;"><b>$0</b></font>');
  2753. setV('slotgames', 0);
  2754. setV('slotgwon', 0);
  2755. setV('slotmwon', 0);
  2756. setV('slotspent', 0);
  2757. setV('slotjp', 0);
  2758. setV('slotbar', 0);
  2759. setV('jpmwon', 0);
  2760. })
  2761. )
  2762. );
  2763. }
  2764. $('#SlTracker').mouseup(function () {
  2765. var divOffset = $('#SlTracker').offset();
  2766. var left = divOffset.left;
  2767. var top = divOffset.top;
  2768. setV('SlTleft', left);
  2769. setV('SlTtop', top);
  2770. });
  2771. // m/k usage
  2772. betinput.each(function () {
  2773. $(this).keydown(function (event) {
  2774. var symcode = event.which;
  2775. if (symcode == 75) {
  2776. $(this).val($(this).val() + '000');
  2777. }
  2778. if (symcode == 77) {
  2779. $(this).val($(this).val() + '000000');
  2780. }
  2781. $(this).val($(this).val().replace(/k|m/g, ''));
  2782. return (symcode == 75 || symcode == 77) ? false : true;
  2783. });
  2784. });
  2785. }
  2786. // ---------------- Scratch tracker ----------------
  2787. if (on_page('/scratch.php') && (nn == 'center' || nn == 'form')) {
  2788. var monin = parseInt(getV('monin', 0), 10);
  2789. var mils = parseInt(getV('mils', 0), 10);
  2790. var bullets = parseInt(getV('bullets', 0), 10);
  2791. var scratches = parseInt(getV('scratches', 0), 10);
  2792.  
  2793. if ($('#game_container:contains("Congratulations!"), #game_container:contains("Gefeliciteerd!")').length) { // grab winning event
  2794. if ($('#game_container:contains("They have been added to your account!"), #game_container:contains("Ze zijn toegevoegd aan jouw account!")').length) { // bullets
  2795. var rex = new RegExp('(\\d+) (bullets|Kogels)');
  2796. var r = $('#game_container').text().match(rex);
  2797. bullets += parseInt(r[1], 10);
  2798. setV('bullets', bullets);
  2799. }
  2800. if ($('#game_container:contains("It has been added to your account!"), #game_container:contains("Het is toegevoegd aan je account!")').length) { // money
  2801. var rex = new RegExp('\\$ (\\d+)');
  2802. var str = $('#game_container').text().replace(/,/g, '');
  2803. var r = str.match(rex);
  2804. monin += parseInt(r[1], 10);
  2805. setV('monin', monin);
  2806. if (parseInt(r[1], 10) == 1000000) {
  2807. mils += 1;
  2808. setV('mils', mils);
  2809. }
  2810. $('input[name="scratch"]').focus();
  2811. }
  2812. }
  2813. if ($('#game_container:contains("Start scratching"), #game_container:contains("Start met krassen")').length) { // grab scratching event
  2814. scratches += 1;
  2815. setV('scratches', scratches);
  2816. if ($('input[name="Check"]').length) {
  2817. $('input[name="Check"]').focus();
  2818. } else {
  2819. $('input[type="submit"]').focus();
  2820. }
  2821. } else {
  2822. if ($('input[name="codescratch"]').length) { // focus on unclaimed prices
  2823. $('input[type="submit"]:eq(1)').focus();
  2824. } else { // focus on scratch
  2825. $('input[name="scratch"]').focus();
  2826. }
  2827. }
  2828.  
  2829. var monout = (scratches * 5000);
  2830. var profit;
  2831. if ((monin - monout) < 0) {
  2832. profit = '-$' + commafy(monout - monin);
  2833. } else {
  2834. profit = '$' + commafy(monin - monout);
  2835. }
  2836. var ppk = Math.round((((monout - monin) / bullets) * 100000) / 100000);
  2837. if (isNaN(ppk) || bullets === 0) {
  2838. ppk = 0;
  2839. }
  2840.  
  2841. var STtop = parseInt(getV('STtop', '225'), 10);
  2842. var STleft = parseInt(getV('STleft', '300'), 10);
  2843. if ($('#STracker').length === 0) {
  2844. $('#game_container').append(
  2845. $('<div>').addClass('tracker').attr({
  2846. id: 'STracker',
  2847. 'data-beyond-fired': true
  2848. }).css({
  2849. top: STtop,
  2850. left: STleft
  2851. }).append(
  2852. $('<div>').attr({
  2853. id: 'sthead'
  2854. }).append(
  2855. $('<center>').text('ScratchTracker').css({
  2856. fontWeight: 'bold'
  2857. })
  2858. ).click(function () {
  2859. $('#STracker').draggable();
  2860. }),
  2861. $('<hr>').css({
  2862. color: 'gray'
  2863. }),
  2864. $('<div>').attr({
  2865. id: 'stbody'
  2866. }).html('Scratched:<font style="float:right;"><b>' + commafy(scratches) + '</b></font><br />Money spent:<font style="float:right;"><b>$' + commafy(monout) + '</b></font><br />Money won:<font style="float:right;"><b>$' + commafy(monin) + '</b></font><br />Profit:<font style="float:right;"><b>' + profit + '</b></font><br />Millions:<font style="float:right;"><b>' + commafy(mils) + '</b></font><br />Bullets won:<font style="float:right;"><b>' + commafy(bullets) + '</b></font><br />Price per bullet:<font style="float:right;"><b>$' + commafy(ppk) + '</b></font>'),
  2867. $('<hr>').css({
  2868. color: 'gray'
  2869. }),
  2870. $('<div>').attr({
  2871. id: 'streset'
  2872. }).addClass('reset').text('Reset stats').click(function () {
  2873. $(this).text('Stats have been reset!');
  2874. $('#stbody').html('Scratched:<font style="float:right;"><b>0</b></font><br />Money spent:<font style="float:right;"><b>$0</b></font><br />Money won: <font style="float:right;"><b>$0</b></font><br />Profit:<font style="float:right;"><b>$0</b></font><br />Millions:<font style="float:right;"><b>0</b></font><br />Bullets won:<font style="float:right;"><b>0</b></font><br />Price per bullet:<font style="float:right;"><b>$0</b></font>');
  2875. setV('monin', 0);
  2876. setV('mils', 0);
  2877. setV('bullets', 0);
  2878. setV('scratches', 0);
  2879. })
  2880. )
  2881. );
  2882. }
  2883. $('#STracker').mouseup(function () {
  2884. // alert('Set the x and y values using GM_getValue.');
  2885. var divOffset = $('#STracker').offset();
  2886. var left = divOffset.left;
  2887. var top = divOffset.top;
  2888. setV('STleft', left);
  2889. setV('STtop', top);
  2890. });
  2891. }
  2892.  
  2893. // ---------------- Bullet Tracker ----------------
  2894. if (on_page('/bullets2.php')) {
  2895. if (notificationsArray['Bullets'] !== undefined) {
  2896. notificationsArray['Bullets'].close();
  2897. delete notificationsArray['Bullets'];
  2898. }
  2899.  
  2900. var BTd = new Date();
  2901. var btdate = getV('btdate', 0);
  2902. if (BTd.getDate() > btdate) {
  2903. setV('bttoday', 0);
  2904. }
  2905. var obaybul = parseInt(getV('obaybul', 0), 10);
  2906. var btbullets = parseInt(getV('btbullets', 0), 10);
  2907. var bttoday = parseInt(getV('bttoday', 0), 10);
  2908. var btmoney = parseInt(getV('btmoney', 0), 10);
  2909. if (nn == 'br' && $('#game_container:contains("Success, you bought")').length) {
  2910. var rex = new RegExp('Success you bought (\\d+) bullets for \\$ (\\d+)');
  2911. var str = $('#game_container').text().split('Bulletfactory')[0].replace(/,/g, '');
  2912. var r = str.match(rex);
  2913. btbullets += parseInt(r[1], 10);
  2914. bttoday += parseInt(r[1], 10);
  2915. btmoney += parseInt(r[2], 10);
  2916. setV('btbullets', btbullets);
  2917. setV('bttoday', bttoday);
  2918. setV('btmoney', btmoney);
  2919. setV('btdate', BTd.getDate());
  2920. $('#BTracker').remove();
  2921. }
  2922. var btdolpbul;
  2923. if (btbullets === 0) {
  2924. btdolpbul = 0;
  2925. } else {
  2926. btdolpbul = Math.round((btmoney / btbullets) * 100) / 100;
  2927. }
  2928.  
  2929. var BTtop = parseInt(getV('BTtop', '300'), 10);
  2930. var BTleft = parseInt(getV('BTleft', '225'), 10);
  2931. if ($('#BTracker').length === 0) {
  2932. $('#game_container').append(
  2933. $('<div>').addClass('tracker').attr({
  2934. id: 'BTracker',
  2935. 'data-beyond-fired': true
  2936. }).css({
  2937. top: BTtop,
  2938. left: BTleft
  2939. }).append(
  2940. $('<div>').attr({
  2941. id: 'bthead'
  2942. }).append(
  2943. $('<center>').text('BulletTracker').css({
  2944. fontWeight: 'bold'
  2945. })
  2946. ).click(function () {
  2947. $('#BTracker').draggable();
  2948. }),
  2949. $('<hr>').css({
  2950. color: 'gray'
  2951. }),
  2952. $('<div>').attr({
  2953. id: 'btbody'
  2954. }).html('Bullets bought:<font style="float:right;"><b>' + commafy(btbullets) + '</b></font><br />Bought today:<font style="float:right;"><b>' + commafy(bttoday) + '</b></font><br />Money spent:<font style="float:right;">$<b>' + commafy(btmoney) + '</b></font><br />Price per bullet:<font style="float:right;">$<b>' + commafy(btdolpbul) + '</b></font><br />Bought on Obay:*<font style="float:right;"><b>' + commafy(obaybul) + '</b></font><br /><font size="1">*not included in total or price per bullet</font>'),
  2955. $('<hr>').css({
  2956. color: 'gray'
  2957. }),
  2958. $('<div>').attr({
  2959. id: 'btreset'
  2960. }).addClass('reset').text('Reset stats').click(function () {
  2961. $(this).text('Stats have been reset!');
  2962. $('#btbody > font:not(:last-child) > b').text('0');
  2963. setV('btbullets', 0);
  2964. setV('btmoney', 0);
  2965. setV('bttoday', 0);
  2966. setV('btdate', 0);
  2967. setV('obaybul', 0);
  2968. })
  2969. )
  2970. );
  2971. }
  2972. $('#BTracker').mouseup(function () {
  2973. var divOffset = $('#BTracker').offset();
  2974. var left = divOffset.left;
  2975. var top = divOffset.top;
  2976. setV('BTleft', left);
  2977. setV('BTtop', top);
  2978. });
  2979. }
  2980. // ---------------- User Profile ----------------
  2981. if (on_page('user.php') && nn == 'center') {
  2982. var status = $('span#status').text();
  2983. var inFam = ($('span#family > a').length ? $('span#family > a').text() : $('span#family').text());
  2984. var alive = status.search(/Dead|Dood/);
  2985. var unick = $('span#username').first().text();
  2986. // DEAD or AKILLED ?
  2987. if (!alive) {
  2988. var rankings = '<a href="/BeO/webroot/index.php?module=Rankings&nick=' + unick + '">View Rankings</a>';
  2989. if ($('img[src*="/userbadges/rip.gif"]').parent().get(0).tagName != 'A') {
  2990. var akill = '<span style="color:red; font-weight:bold;"> (Akill) </span>';
  2991. status += akill;
  2992. }
  2993. $.getJSON(OB_API_WEBSITE + '/?p=stats&w=deaths&v=' + v + '&ing=' + unick, function (data) {
  2994. if (data['DiedAt'] === null) {
  2995. $('span#status').html(status + ' | Death date is not known');
  2996. } else {
  2997. $('span#status').html(status + ' | ' + rankings + ' | Died at ' + data['Date'] + ' OT (' + data['Agod'] + 'd ' + data['Agoh'] + 'h ' + data['Agom'] + 'm ago)');
  2998. }
  2999. });
  3000. }
  3001. if (status === 'Alive' || status === 'Levend') {
  3002. $.getJSON(OB_API_WEBSITE + '/?p=stats&w=laston&v=' + v + '&ing=' + unick, function (data) {
  3003. if (data['LastOn'] === 0) { // 1970, thus not seen by logger
  3004. $('span#status').text(status + ' | This user has not been seen online by our logger yet');
  3005. } else {
  3006. $('span#status').html(status + ' | Last on: ' + data['Date'] + ' OT (' + data['Agod'] + 'd ' + data['Agoh'] + 'h ' + data['Agom'] + 'm ago)');
  3007. }
  3008. });
  3009. }
  3010.  
  3011. // Wealth
  3012. var tr, x, y, z;
  3013. tr = 10;
  3014. x = $('#game_container').html().search('Marital status:');
  3015. y = $('#game_container').html().search('SMS Status');
  3016. z = $('#game_container').html().search('Family Buster of');
  3017.  
  3018. if (x == -1) {
  3019. tr--;
  3020. }
  3021. if (y == -1) {
  3022. tr--;
  3023. }
  3024. if (z == -1) {
  3025. tr--;
  3026. }
  3027.  
  3028. var wlth = $('#wealth').attr('value');
  3029.  
  3030. var kind = [' ($0 - $50.000)', ' ($50.001 - $100.000)', ' ($100.001 - $500.000)', ' ($1.000.001 - $5.000.000)', ' ($5.000.001 - $15.000.000)', ' ( > $15.000.001)', ' ($500.001 - $1.000.000)'],
  3031. i = 1;
  3032. var wealth = (v == 'nl' ? ['Sloeber', 'Arm', 'Modaal', 'Erg rijk', 'Te rijk om waar te zijn', 'Rijker dan God', 'Rijk'] : ['Straydog', 'Poor', 'Nouveau Riche', 'Very rich', 'Too rich to be true', 'Richer than God', 'Rich']);
  3033. var a = wealth.indexOf(wlth);
  3034.  
  3035. $('#wealth').text(wlth + kind[a]);
  3036.  
  3037. // Race form
  3038. var rf = $('#raceform').attr('value');
  3039. var driver = (v == 'nl' ? ['Brokkenpiloot', 'Wegpiraat', 'Nieuwkomer', 'Waaghals', 'Beginner', 'Taxirijder', 'Talent', 'Professional', 'Coureur', 'Racemonster', 'Wereldkampioen'] : ['Rookie', 'Co-Driver', 'Driver', 'Advanced Driver', 'Master Driver', 'Chauffeur', 'Advanced Chauffeur', 'Master Chauffeur', 'Racing Driver', 'Race Supremo', 'Champion']);
  3040. var a = driver.indexOf(rf);
  3041. $('#raceform').text((a + 1) + ' - ' + rf);
  3042.  
  3043. // Bust ranks
  3044. var bustrank = $('#bustrank').attr('value');
  3045.  
  3046. var amount = [' (0-500)', ' (501-1.000)', ' (1.001-2.500)', ' (2.501-5.000)', ' (5.001-10.000)', ' (10.001-15.000)', ' (15.001-20.000)', ' (20.001-25.000)', ' (25.001-27.500)', ' (27.501+)'],
  3047. i = 1;
  3048. var brank = (v == 'nl' ? ['Beginner', 'In opleiding', 'Ray\'s Assistent', 'Gevorderde', 'Senior buster', 'Professioneel', 'Expert', 'Held van Alcatraz', 'Meesterbuster', 'Houdini'] : ['Rookie', 'Novice', 'Initiate', 'Decent', 'Apprentice', 'Intermediate', 'Professional', 'Expert', 'Ultimate', 'Extreme Expert']);
  3049.  
  3050. var a = brank.indexOf(bustrank);
  3051.  
  3052. $('#bustrank').text(bustrank + amount[a]);
  3053.  
  3054. // Actions
  3055. var self = ($('table.thinline > tbody > tr:eq(2) > td:eq(1) > a > span').text() == getV('nick', ''));
  3056. $('td.tableheader').parent().after(
  3057. $('<tr>').append(
  3058. $('<td>').addClass('profilerow').attr({
  3059. id: 'actions',
  3060. colspan: '2',
  3061. align: 'center'
  3062. }).css('display', 'none').html('<a href="BeO/webroot/index.php?module=Heist&action=&driver=' + unick + '">Heist</a> | <a href="' + document.location.protocol + '//' + document.location.hostname + '/BeO/webroot/index.php?module=Spots&driver=' + unick + '">Raid</a> | <a href="/BeO/webroot/index.php?module=Detectives&search=' + unick + '">Hire Detectives</a>')
  3063. )
  3064. );
  3065. var historyLink = null;
  3066. if (versionHasLogger) {
  3067. historyLink = $('<span>').text('View History').css('cursor', 'pointer').click(function () {
  3068. $.get(OB_API_WEBSITE + '/?p=history&v=' + v + '&name=' + unick, function (data) {
  3069. $('#game_container').empty();
  3070. $('#game_container').html(data);
  3071. });
  3072. });
  3073. }
  3074. if (!self && alive) {
  3075. $('td.tableheader').append(
  3076. $('<span>').text(' | '),
  3077. historyLink,
  3078. $('<span>').text(' | '),
  3079. $('<span>').text('Actions').css('cursor', 'pointer').click(function () {
  3080. $('#actions').toggle();
  3081. })
  3082. );
  3083. } else {
  3084. $('td.tableheader').append(
  3085. $('<span>').text(' | '),
  3086. historyLink
  3087. );
  3088. }
  3089. if (parseInt(getPow('bninfo', 4, -1), 10) === 3 && inFam === 'None') {
  3090. $('#actions').html($('#actions').html() + ' | <a href="/BeO/webroot/index.php?module=Family&who=' + unick + '">Invite to Family</a>');
  3091. }
  3092. }
  3093. // ---------------- Linkify ----------------
  3094. // Messages
  3095. if (on_page('action=showMsg') && nn == 'center') {
  3096. var msgType = $('.tableheader:eq(1) > b > strong').text();
  3097. var msgType2 = $('.tableheader:eq(1) > b').text();
  3098. var msgTxt = '.thinline:eq(1) > tbody > tr:eq(4) > td';
  3099. var arr = $(msgTxt).html().split(' ');
  3100. var linkify = ['Route 66 heist', 'Organised Crime', 'Mega Organized Crime', 'Target not found', 'Carrace invite', 'Target found', 'Kill success', 'Witness statement', 'Condolences', 'found', 'Ticket update', 'Crashed Message', 'Invitation', 'Raid Notification', 'Married', 'Wedding Gift', 'Wedding', 'Wedding Invitation', 'shot!'];
  3101.  
  3102. var setArr = function (num) {
  3103. if (arr[num].substr(-1) == '.') {
  3104. return (arr[num] = '<a href="/user.php?nick=' + arr[num].match(/\w+/g)[0] + '"><b>' + arr[num].match(/\w+/g)[0] + '</b></a>.');
  3105. }
  3106. return (arr[num] = '<a href="/user.php?nick=' + arr[num].match(/\w+/g)[0] + '"><b>' + arr[num].match(/\w+/g)[0] + '</b></a>');
  3107. };
  3108.  
  3109. var WitnessMsg = new RegExp(linkify[7]); // Witness statement
  3110. if (WitnessMsg.test(msgType)) {
  3111. setArr(3);
  3112. setArr(5);
  3113. $(msgTxt).html(arr.join(' '));
  3114. }
  3115. var TnFMsg = new RegExp(linkify[3]); // Target not found
  3116. if (TnFMsg.test(msgType)) {
  3117. setArr(5);
  3118. $(msgTxt).html(arr.join(' '));
  3119. }
  3120. var HeistMsg = new RegExp(linkify[0]); // Route 66 heist
  3121. if (HeistMsg.test(msgType)) {
  3122. if (arr[2] == 'inviting') {
  3123. setArr(0);
  3124. setArr(13);
  3125. $(msgTxt).html(arr.join(' '));
  3126. } else {
  3127. $(msgTxt).html($(msgTxt).html());
  3128. }
  3129. }
  3130. var RaceMsg = new RegExp(linkify[4]); // Car Race invite
  3131. if (RaceMsg.test(msgType)) {
  3132. setArr(9);
  3133. arr[arr.length - 15] = '<a href="/races.php"><strong>' + arr[arr.length - 15];
  3134. arr[arr.length - 14] = arr[arr.length - 14] + '</strong></a>';
  3135. $(msgTxt).html(arr.join(' '));
  3136. }
  3137. var RaidMsg = new RegExp(linkify[13]); // Raid Notification
  3138. if (RaidMsg.test(msgType)) {
  3139. setArr(9);
  3140. arr[arr.length - 8] = arr[arr.length - 8].split('<br>')[0] + '<br /><br /><a href="/BeO/webroot/index.php?module=Spots"><strong>' + arr[arr.length - 8].split('<br>')[2] + '</strong></a>';
  3141. $(msgTxt).html(arr.join(' '));
  3142. }
  3143. var OCMsg = new RegExp(linkify[1]); // Organized Crime
  3144. if (OCMsg.test(msgType)) {
  3145. if (arr[2] == 'inviting') {
  3146. setArr(0);
  3147. setArr(arr.length - 8);
  3148. $(msgTxt).html(arr.join(' '));
  3149. } else {
  3150. $(msgTxt).html($(msgTxt).html());
  3151. }
  3152. }
  3153. var MOCMsg = new RegExp(linkify[2]); // Mega Organized Crime
  3154. if (MOCMsg.test(msgType2)) {
  3155. if (arr[2] == 'invited') {
  3156. setArr(0);
  3157. arr[arr.length - 8] = '<a href="/BeO/webroot/index.php?module=MegaOC"><strong>' + arr[arr.length - 8];
  3158. arr[arr.length - 7] = arr[arr.length - 7] + '</strong></a>';
  3159. $(msgTxt).html(arr.join(' '));
  3160. } else {
  3161. $(msgTxt).html($(msgTxt).html());
  3162. }
  3163. }
  3164. var KillMsg = new RegExp(linkify[6]); // Kill success
  3165. if (KillMsg.test(msgType)) {
  3166. setArr(2);
  3167. $(msgTxt).html(arr.join(' '));
  3168. }
  3169. var CondMsg = new RegExp(linkify[8]); // Condolences
  3170. if (CondMsg.test(msgType)) {
  3171. setArr(2);
  3172. setArr(arr.length - 15);
  3173. $(msgTxt).html(arr.join(' '));
  3174. }
  3175. var InvMsg = new RegExp(linkify[12]); // Invite
  3176. if (InvMsg.test(msgType)) {
  3177. setArr(8);
  3178. $(msgTxt).html(arr.join(' '));
  3179. }
  3180. }
  3181. // ---------------- Lackeys ----------------
  3182. if (on_page('module=Lackeys') && nn == 'div') {
  3183. // General
  3184. var logpath = 'table[data-info="log"] > tbody > tr';
  3185. var itemspath = 'table[data-info="items"] > tbody > tr[data-id]';
  3186. var credits = $('td[data-info="credits"]').text();
  3187. var money = $('td[data-info="money"]').text().replace(/,/g, '');
  3188. // Noodles
  3189. if (on_page('type=2') && nn == 'div') {
  3190. var carSuccess = parseInt(getV('carSuccess', 0), 10);
  3191. var carMoney = parseInt(getV('carMoney', 0), 10);
  3192.  
  3193. // Loop cars to grab values
  3194. var x = 0;
  3195. var totalCarval = 0;
  3196. $(itemspath).each(function () {
  3197. // grab value
  3198. var carVal = parseInt($(itemspath + ':eq(' + x + ') > td:eq(4)').text().replace(',', '').replace('$', ''), 10);
  3199. totalCarval += carVal;
  3200. ++x;
  3201. });
  3202.  
  3203. // Show total value of nicked cars
  3204. $('div.oheader:eq(2)').text($(itemspath).length + $('div.oheader:eq(2)').text()).append(
  3205. $('<span>').text('total value: $' + commafy(totalCarval))
  3206. );
  3207.  
  3208. // Save cars and value
  3209. $('table[data-info="items"] > tbody > tr > td > input[type="submit"]').click(function() {
  3210. setV('carSuccess', (x + carSuccess));
  3211. setV('carMoney', (totalCarval + carMoney));
  3212. });
  3213. }
  3214. // Sluggs
  3215. if (on_page('type=6') && nn == 'div') {
  3216. var sluggsHideLaughing = sets['sluggsHideLaughing'] === undefined ? true : sets['sluggsHideLaughing'];
  3217. var price = $('input#setting_bullets_max_price_price_6').val();
  3218.  
  3219. // commafy and alert money
  3220. var needed = (credits / 5) * (price * 1000);
  3221. var short = money.substr(1) - needed;
  3222. var enough = (short < 0) ? '<p style="color:red;">' + commafy(money) + ' ($' + commafy(short) + ')</p>' : '<p style="color:green;">' + commafy(money) + '</p>';
  3223. $('td[data-info="money"]').html(enough);
  3224.  
  3225. // Price per bullet
  3226. var x = 0;
  3227. $(logpath).each(function () {
  3228. // show price per bullet when Sluggs bought
  3229. // Let's see if we can put the regexes in a variable, makes it easier to edit/match them
  3230.  
  3231. var sluggs_bought_match_nl = /Sluggs kocht (\d+) kogels voor \$(\d+)/;
  3232. var sluggs_bought_match_com = /Sluggs bought (\d+) bullets for \$(\d+)/;
  3233.  
  3234. if (v == 'nl') {
  3235. if ($(logpath + ':eq(' + x + ') > td:eq(1)').html().replace(/,/g, '').match(sluggs_bought_match_nl) && x != logpath.length) {
  3236. var r = $(logpath + ':eq(' + x + ') > td:eq(1)').html().replace(/,/g, '').match(sluggs_bought_match_nl);
  3237. var ppb = Math.round(r[2] / r[1]);
  3238. $(logpath + ':eq(' + x + ') > td:eq(1)').html($(logpath + ':eq(' + x + ') > td:eq(1)').html() + ' ($' + ppb + '/kogel)');
  3239. }
  3240. ++x;
  3241. } else {
  3242. if ($(logpath + ':eq(' + x + ') > td:eq(1)').html().replace(/,/g, '').match(sluggs_bought_match_com) && x != logpath.length) {
  3243. var r = $(logpath + ':eq(' + x + ') > td:eq(1)').html().replace(/,/g, '').match(sluggs_bought_match_com);
  3244. var ppb = Math.round(r[2] / r[1]);
  3245. $(logpath + ':eq(' + x + ') > td:eq(1)').html($(logpath + ':eq(' + x + ') > td:eq(1)').html() + ' ($' + ppb + '/bullet)');
  3246. }
  3247. ++x;
  3248. }
  3249. });
  3250.  
  3251. // Hide useless entries
  3252. var hideLaughing = function(hide) {
  3253. setA('sets', 'sluggsHideLaughing', hide);
  3254. sluggsHideLaughing = hide;
  3255. x = 0;
  3256. $(logpath).each(function () {
  3257.  
  3258. var sluggs_laughs_match_nl = /Sluggs lacht om je lage limiet/;
  3259. var sluggs_laughs_match_com = /Sluggs is laughing at your measly limit/;
  3260.  
  3261. if (v == 'nl') {
  3262. if ($(logpath + ':eq(' + x + ') > td:eq(1)').html().match(sluggs_laughs_match_nl) && x != logpath.length) {
  3263. if (hide) {
  3264. $(this).hide();
  3265. } else {
  3266. $(this).show();
  3267. }
  3268. }
  3269. ++x;
  3270. } else {
  3271. if ($(logpath + ':eq(' + x + ') > td:eq(1)').html().match(sluggs_laughs_match_com) && x != logpath.length) {
  3272. if (hide) {
  3273. $(this).hide();
  3274. } else {
  3275. $(this).show();
  3276. }
  3277. }
  3278. ++x;
  3279. }
  3280. });
  3281. };
  3282. var hide_text = (v == 'nl' ? 'Verberg "Sluggs lacht om" meldingen' : 'Hide "Sluggs is laughing" entries');
  3283. $('div.oheader:last').append(
  3284. $('<span>').append(
  3285. $('<input>').attr({
  3286. id: 'cb',
  3287. type: 'checkbox'
  3288. }).click(function () {
  3289. hideLaughing($('#cb').is(':checked'));
  3290. }),
  3291. $('<label />').attr('for', 'cb').text(hide_text)
  3292. )
  3293. );
  3294. if (sluggsHideLaughing === true) {
  3295. $('#cb').prop('checked', true);
  3296. hideLaughing(true);
  3297. }
  3298. }
  3299. // Freekowtski
  3300. if (on_page('type=4') && nn == 'div') {
  3301. var x = 0;
  3302. $(logpath).each(function () {
  3303. // show price per unit when Freekowtski bought
  3304.  
  3305. var free_bought_match_nl = /Freekowtski heeft zojuist (\d+) (\w+) gekocht voor \$(\d+)/;
  3306. var free_bought_match_com = /Freekowtski just bought (\d+) of (\w+) for \$(\d+)/;
  3307.  
  3308. if (v == 'nl') {
  3309. if ($(logpath + ':eq(' + x + ') > td:eq(1)').html().replace(/,/g, '').match(free_bought_match_nl) && x != logpath.length) {
  3310. var r = $(logpath + ':eq(' + x + ') > td:eq(1)').html().replace(/,/g, '').match(free_bought_match_nl);
  3311. var ppu = Math.round(r[3] / r[1]);
  3312. $(logpath + ':eq(' + x + ') > td:eq(1)').html($(logpath + ':eq(' + x + ') > td:eq(1)').html() + ' ($' + commafy(ppu) + ' / eenheid)');
  3313. }
  3314. ++x;
  3315. } else {
  3316. if ($(logpath + ':eq(' + x + ') > td:eq(1)').html().replace(/,/g, '').match(free_bought_match_com) && x != logpath.length) {
  3317. var r = $(logpath + ':eq(' + x + ') > td:eq(1)').html().replace(/,/g, '').match(free_bought_match_com);
  3318. var ppu = Math.round(r[3] / r[1]);
  3319. $(logpath + ':eq(' + x + ') > td:eq(1)').html($(logpath + ':eq(' + x + ') > td:eq(1)').html() + ' ($' + commafy(ppu) + ' / unit)');
  3320. }
  3321. ++x;
  3322. }
  3323. });
  3324. }
  3325. // O'Rourke
  3326. if (on_page('type=3') && nn == 'div') {
  3327. var x = 0;
  3328. $(logpath).each(function () {
  3329. // show price per unit when O'Rourke bought
  3330.  
  3331. var rourke_bought_match_nl = /O'Rourke heeft zojuist (\d+) (\w+) gekocht voor \$(\d+)/;
  3332. var rourke_bought_match_com = /O'Rourke just bought (\d+) of (\w+) for \$(\d+)/;
  3333.  
  3334. if (v == 'nl') {
  3335. if ($(logpath + ':eq(' + x + ') > td:eq(1)').html().replace(/,/g, '').match(rourke_bought_match_nl) && x != logpath.length) {
  3336. var r = $(logpath + ':eq(' + x + ') > td:eq(1)').html().replace(/,/g, '').match(rourke_bought_match_nl);
  3337. var ppu = Math.round(r[3] / r[1]);
  3338. $(logpath + ':eq(' + x + ') > td:eq(1)').html($(logpath + ':eq(' + x + ') > td:eq(1)').html() + ' ($' + commafy(ppu) + ' / eenheid)');
  3339. }
  3340. ++x;
  3341. } else {
  3342. if ($(logpath + ':eq(' + x + ') > td:eq(1)').html().replace(/,/g, '').match(rourke_bought_match_com) && x != logpath.length) {
  3343. var r = $(logpath + ':eq(' + x + ') > td:eq(1)').html().replace(/,/g, '').match(rourke_bought_match_com);
  3344. var ppu = Math.round(r[3] / r[1]);
  3345. $(logpath + ':eq(' + x + ') > td:eq(1)').html($(logpath + ':eq(' + x + ') > td:eq(1)').html() + ' ($' + commafy(ppu) + ' / unit)');
  3346. }
  3347. ++x;
  3348. }
  3349. });
  3350. }
  3351. // Fire all button
  3352. $('input[data-action="addCredits"]').closest('td').css('width', '99%').after(
  3353. $('<td>').attr('align', 'right').append(
  3354. $('<input id="ob_fire_all" type="button" value="Fire all lackeys">').click(function() {
  3355. if (confirm('Are you sure you want to fire ALL lackeys?')) {
  3356. $('#ob_fire_all').val('Firing lackeys ...').prop('disabled', true);
  3357. var jailWarn = false;
  3358. var fireLackey = function (lackeyIndex) {
  3359. $.post('//' + document.location.hostname + 'BeO/webroot/?module=Lackeys&action=fire', { lackey: lackeyIndex }).done(function(data) {
  3360. if (data.indexOf('jail') !== -1) {
  3361. jailWarn = true;
  3362. }
  3363. if (lackeyIndex < 6) {
  3364. fireLackey(lackeyIndex + 1);
  3365. } else {
  3366. if (jailWarn) {
  3367. alert('At least one of your lackeys is in jail and cannot be fired!');
  3368. $('#ob_fire_all').val('Fire all lackeys').prop('disabled', false);
  3369. } else {
  3370. $('#ob_fire_all').val('Lackeys fired!');
  3371. }
  3372. }
  3373. });
  3374. };
  3375. fireLackey(1);
  3376. }
  3377. })
  3378. )
  3379. );
  3380. }
  3381. // ---------------- BRC ----------------
  3382. if ((on_page('prices.php') && nn == 'center') || (on_page('smuggling.php') && nn == 'center')) {
  3383. var carry_n, carry_b;
  3384. var bninfo = getV('bninfo', -1);
  3385. if (bninfo !== '' && bninfo != -1) { // extra checker for undefined crap
  3386. if (bninfo.search(/[^0-9]/) != -1) {
  3387. setV('bninfo', -1);
  3388. }
  3389. }
  3390. // grab Lex
  3391. var lex, lexDay, lexHour;
  3392. if ($('span#lexhelpsyou').length) {
  3393. var lex = parseInt($('span#lexhelpsyou').html().replace(/[^0-9]/g, ''), 10);
  3394. setV('lex', lex);
  3395. var BRCd = new Date();
  3396. lexDay = BRCd.getDay();
  3397. lexHour = BRCd.getHours();
  3398. setV('lexHour', lexHour);
  3399. setV('lexDay', lexDay);
  3400. } else {
  3401. lex = getV('lex', 0);
  3402. lexDay = getV('lexDay', -1);
  3403. lexHour = getV('lexHour', -1);
  3404. }
  3405.  
  3406. var fillBRC = function(n, b, mode) { // actually filling the forms
  3407. var values = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; // set defaults
  3408. // booze - narcs == maximum user can buy
  3409. // carry_b - carry_n == total user is carrying
  3410. // b_amount - n_amount == amount per item user is carrying
  3411. // b - n == item we want
  3412. if (n > -1 && !lnarcs && mode != 3) { // do we want narcs?
  3413. if (carry_n === 0) { // nothing in pocket, fill it all
  3414. values[7 + n] = narcs;
  3415. $('input[name="typedrugs"]:eq(1)').prop('checked', true); // buy
  3416. } else { // something in pocket
  3417. if (carry_n < narcs) { // we got space for more
  3418. if (n_amount[n] < narcs) { // not full of wanted
  3419. if (n_amount[n] != carry_n) { // there is unwanted stuff
  3420. for (i = 0; i <= 6; i++) {
  3421. if (i != n || mode == 1) { // only sell what we don't want
  3422. values[i + 7] = n_amount[i];
  3423. }
  3424. }
  3425. $('input[name="typedrugs"]:eq(0)').prop('checked', true); // sell
  3426. } else { // only carrying wanted narcs
  3427. values[7 + n] = narcs - carry_n; // if any, fill missing amount
  3428. $('input[name="typedrugs"]:eq(1)').prop('checked', true); // buy
  3429. }
  3430. } else { // full of wanted
  3431. if (mode > 0) { // CD/RP mode, sell all
  3432. values[7 + n] = n_amount[n];
  3433. $('input[name="typedrugs"]:eq(0)').prop('checked', true); // sell
  3434. }
  3435. }
  3436. } else { // we go too much, guess it was a good heist
  3437. for (i = 0; i <= 6; i++) { // check what we carry
  3438. if (mode === 0 && i == n) {
  3439. values[i + 7] = 0;
  3440. } else {
  3441. values[i + 7] = n_amount[i];
  3442. $('input[name="typedrugs"]:eq(0)').prop('checked', true); // sell
  3443. }
  3444. }
  3445. }
  3446. }
  3447. }
  3448. if (n == -1 && mode == 4 && !lnarcs) {
  3449. for (i = 0; i <= 6; i++) {
  3450. values[i + 7] = n_amount[i];
  3451. $('input[name="typedrugs"]:eq(0)').prop('checked', true); // sell
  3452. }
  3453. }
  3454.  
  3455. // check for scenario: failed selling narcs in high
  3456. var selling_n = 0;
  3457. for (i = 0; i <= 6; i++) {
  3458. selling_n += values[i + 7];
  3459. }
  3460. var fail_n = (carry_b === 0 && carry_n == narcs && mode === 0 && selling_n > 0) ? 1 : 0;
  3461.  
  3462. if (b > -1 && !fail_n && !lbooze && mode != 3) { // do we want booze? Or are we still selling narcs in high?
  3463. if (carry_b === 0) {
  3464. values[b] = booze; // nothing in pocket, fill it all
  3465. $('input[name="typebooze"]:eq(1)').prop('checked', true); // buy
  3466. } else {
  3467. if (carry_b < booze) { // we got space for more
  3468. if (b_amount[b] < booze) { // not full of wanted
  3469. if (b_amount[b] != carry_b) { // there is unwanted stuff
  3470. for (i = 0; i <= 6; i++) {
  3471. values[i] = b_amount[i];
  3472. }
  3473. $('input[name="typebooze"]:eq(0)').prop('checked', true); // sell
  3474. } else { // only carrying wanted narcs
  3475. if (mode == 2) {
  3476. values[b] = carry_b; // if any, fill missing amount
  3477. $('input[name="typebooze"]:eq(0)').prop('checked', true); // sell
  3478. } else {
  3479. values[b] = booze - carry_b; // if any, fill missing amount
  3480. $('input[name="typebooze"]:eq(1)').prop('checked', true); // buy
  3481. }
  3482. }
  3483. } else { // full of wanted
  3484. if (mode > 0) { // CD/RP mode, sell all
  3485. values[b] = b_amount[b];
  3486. $('input[name="typebooze"]:eq(0)').prop('checked', true); // sell
  3487. }
  3488. }
  3489. } else { // we go too much, guess it was a good heist
  3490. for (i = 0; i <= 6; i++) { // check what we carry
  3491. if (mode === 0 && i == b) {
  3492. values[i] = 0;
  3493. } else {
  3494. values[i] = b_amount[i];
  3495. $('input[name="typebooze"]:eq(0)').prop('checked', true); // sell
  3496. }
  3497. }
  3498. }
  3499. }
  3500. }
  3501. if (b == -1 && mode == 4 && !lbooze) {
  3502. for (i = 0; i <= 6; i++) {
  3503. values[i] = b_amount[i];
  3504. $('input[name="typebooze"]:eq(0)').prop('checked', true); // sell
  3505. }
  3506. }
  3507.  
  3508. // fill in the fields with the calculated values
  3509. var sorts = ['wine', 'cognac', 'whiskey', 'amaretto', 'beer', 'port', 'rum', 'morphine', 'heroin', 'opium', 'cocaine', 'marihuana', 'tabacco', 'glue'];
  3510. var start = (lbooze) ? 7 : 0;
  3511. var end = (lnarcs) ? 6 : 13;
  3512. for (i = start; i <= end; i++) {
  3513. var box = $('input[name="' + sorts[i] + '"]');
  3514. box.val(values[i]);
  3515. }
  3516.  
  3517. // focus
  3518. $('input[type=submit]').focus();
  3519. };
  3520.  
  3521. var highlightRow = function () {
  3522. $(this).css('backgroundColor', '#888');
  3523. };
  3524.  
  3525. var removeHighlight = function () {
  3526. $(this).css('backgroundColor', 'transparent');
  3527. };
  3528.  
  3529. var fillBRCForCity = function () {
  3530. fillBRC(parseInt($(this).attr('n'), 10), parseInt($(this).attr('b'), 10), 0);
  3531. };
  3532.  
  3533. var appBRC = function(BN) {
  3534. if (!lboth) {
  3535. var getInfo = $('div#info:eq(0)').text();
  3536. getInfo = getInfo.split('*');
  3537. var narc = getInfo[0];
  3538. var booze = getInfo[1];
  3539. var city = getInfo[2];
  3540. var plane = getInfo[3];
  3541. var fam = getInfo[4];
  3542. var lex = parseInt(getInfo[6], 10);
  3543. var lexHour = parseInt(getInfo[7], 10);
  3544. var lexDay = parseInt(getInfo[8], 10);
  3545.  
  3546. // extra city checker
  3547. if (on_page('smuggling.php') && nn == 'center') {
  3548. var smugCity = unsafeWindow.omerta.character.game.city();
  3549. for (i = 0; i < 8; i++) {
  3550. if (smugCity.search(cities[i]) != -1) {
  3551. city = i + 4;
  3552. setPow('bninfo', 2, city);
  3553. }
  3554. }
  3555. }
  3556. // calc profits per item per city
  3557. var lex = 1 + 0.01 * lex;
  3558. var j;
  3559. for (var nCityprofit = [], bCityprofit = [], i = 0; i <= 7; i++) { // get profit per single unit of b/n
  3560. for (nCityprofit[i] = [], bCityprofit[i] = [], j = 0; j <= 6; j++) { // price there - price here
  3561. nCityprofit[i].push(Math.round(BN[0][j][(i + 2)] * lex) - Math.round(BN[0][j][(city - 4 + 2)])); // -4 correction for city ID,
  3562. bCityprofit[i].push(Math.round(BN[1][j][(i + 2)] * lex) - Math.round(BN[1][j][(city - 4 + 2)])); // +2 correction for min/max @ [0]+[1] in BN array
  3563. }
  3564. nCityprofit[i].unshift(Math.max.apply(null, nCityprofit[i])); // most profit per unit in this city
  3565. bCityprofit[i].unshift(Math.max.apply(null, bCityprofit[i]));
  3566. }
  3567. // create BRC table
  3568. var table = $('<table>').addClass('thinline').attr('id', 'brc').css('width', '500').append(
  3569. $('<tr>').append(
  3570. $('<td>').addClass('tableheader').attr('colspan', '5').text('Best Run Calculator')
  3571. ),
  3572. $('<tr>').append(
  3573. $('<td>').attr({
  3574. colspan: '5',
  3575. height: '1'
  3576. }).css('background-color', '#000')
  3577. ),
  3578. $('<tr>').css({
  3579. 'border-bottom': '1px solid #000'
  3580. }).append(
  3581. $('<td>').html('&nbsp; City'),
  3582. $('<td>').html('&nbsp; Booze'),
  3583. $('<td>').html('&nbsp; Narc'),
  3584. $('<td>').html('&nbsp; Profit'),
  3585. $('<td>').html('&nbsp;')
  3586. )
  3587. );
  3588.  
  3589. // add city rows with individual profits
  3590. for (var allProfits = [], bestBN = [], i = 0; i <= 7; i++) {
  3591. var tr = $('<tr>').attr('id', '2row' + (i + 2));
  3592. tr.hover(highlightRow, removeHighlight);
  3593.  
  3594. var td = $('<td>').attr('colspan', '5').css({
  3595. 'border-bottom': '1px solid #000',
  3596. height: '19px'
  3597. });
  3598.  
  3599. // --Calc profits
  3600. if (i == city - 4) { // This is the current city
  3601. td.css('text-align', 'center');
  3602. td.html('<i>You are in ' + cities[i] + '</i>');
  3603. tr.append(td);
  3604. allProfits.push(0);
  3605. bestBN.push([0, 0]);
  3606. } else if (plane === 0 && (((city == 6 || city == 11) && (i + 4) != 6 && (i + 4) != 11) || ((city != 6 && city != 11) && ((i + 4) == 6 || (i + 4) == 11)))) { // No plane to travel there
  3607. td.css('text-align', 'center');
  3608. td.html('<i>You can\'t fly to ' + cities[i] + '</i>');
  3609. tr.append(td);
  3610. allProfits.push(0);
  3611. bestBN.push([0, 0]);
  3612. } else { // Nothing wrong, clear to go
  3613. var bestNarc = nCityprofit[i][0] < 0 ? 0 : nCityprofit[i].lastIndexOf(nCityprofit[i][0]); // best, if any, narc?
  3614. var profitNarc = (bestNarc === 0) ? 0 : nCityprofit[i][bestNarc]; // profit per unit
  3615. profitNarc = profitNarc * narc;
  3616.  
  3617. var bestBooze = bCityprofit[i][0] < 0 ? 0 : bCityprofit[i].lastIndexOf(bCityprofit[i][0]); // best, if any, booze?
  3618. var profitBooze = (bestBooze === 0) ? 0 : bCityprofit[i][bestBooze]; // profit per unit
  3619. profitBooze = profitBooze * booze;
  3620.  
  3621. // calc travel cost
  3622. var travelPrices = [ // travel costs from A to B
  3623. [ 0, 600, 10350, 1575, 3600, 1350, 1050, 10800], // det
  3624. [ 600, 0, 11025, 2025, 3000, 1725, 1425, 11400], // chi
  3625. [10350, 11025, 0, 9075, 14025, 9450, 9750, 1875], // pal
  3626. [ 1575, 2025, 9075, 0, 5025, 375, 675, 9375], // ny
  3627. [ 3600, 3000, 14025, 5025, 0, 4650, 4350, 14400], // lv
  3628. [ 1350, 1725, 9450, 375, 4650, 0, 300, 9750], // phi
  3629. [ 1050, 1425, 9750, 675, 4350, 300, 0, 10050], // bal
  3630. [10800, 11400, 1875, 9375, 14400, 9750, 10050, 0] // cor
  3631. ]; // det chi pal ny lv phi bal cor
  3632. var travelCost = travelPrices[i][(city - 4)];
  3633. if (plane === 0) { // no plane => half travel cost
  3634. travelCost /= 2;
  3635. }
  3636.  
  3637. // Our total profit in this city
  3638. var totalProfit = (profitNarc + profitBooze) - Math.round(travelCost);
  3639.  
  3640. // save all profits in array for later
  3641. if (totalProfit < 0) {
  3642. bestBN.push([0, 0]); // push dummy to complete array
  3643. } else {
  3644. bestBN.push([bestNarc, bestBooze]);
  3645. }
  3646. var wnarc = (bestNarc === 0) ? 0 : bestNarc - 1;
  3647. var wbooze = (bestBooze === 0) ? 0 : bestBooze - 1;
  3648. var narcsell = (BN[0][wnarc][0] * narc) * lex;
  3649. var boozesell = (BN[1][wbooze][0] * booze) * lex;
  3650. var pay = (Math.round(narcsell * [0, 0.1, 0.1, 0, 0.1][fam]) + Math.round(boozesell * [0, 0.1, 0.1, 0, 0.1][fam])); // famless, member no capo, capo, top3, member with capo
  3651. totalProfit = totalProfit - pay;
  3652. allProfits.push(totalProfit);
  3653.  
  3654. // What's the result
  3655. if (totalProfit < 0) { // no profit :(
  3656. td.css('text-align', 'center');
  3657. td.html('<i>You won\'t make any profit in ' + cities[i] + '</i>');
  3658. tr.append(td);
  3659. } else { // profit \o/
  3660. td.html('&nbsp;' + cities[i]);
  3661. td.attr('colspan', '1');
  3662. tr.append(td);
  3663. tr.append(
  3664. $('<td>').css({
  3665. 'border-left': '1px solid #000',
  3666. 'border-bottom': '1px solid #000'
  3667. }).html('&nbsp; ' + boozenames[bestBooze]),
  3668. $('<td>').css({
  3669. 'border-left': '1px solid #000',
  3670. 'border-bottom': '1px solid #000'
  3671. }).html(parseInt(narc, 10) === 0 ? 'NO NARCS' : '&nbsp; ' + narcnames[bestNarc]),
  3672. $('<td>').css({
  3673. 'border-left': '1px solid #000',
  3674. 'border-bottom': '1px solid #000'
  3675. }).html('&nbsp; $' + commafy(totalProfit))
  3676. );
  3677.  
  3678. if (on_page('smuggling.php') && nn == 'center') { // we need JS links @ smuggling and don't want to waste clicks
  3679. var key = [0, 4, 6, 1, 2, 3, 5]; // convert b/n - bot prices order to smuggling order
  3680. var n1 = key[bestNarc - 1];
  3681. var b1 = key[bestBooze - 1];
  3682.  
  3683. tr.append(
  3684. $('<td>').css({
  3685. 'border-left': '1px solid #000',
  3686. 'border-bottom': '1px solid #000'
  3687. }).html('&nbsp;').append(
  3688. $('<span>').attr({
  3689. id: 'go' + i,
  3690. n: n1,
  3691. b: b1
  3692. }).css({
  3693. 'font-weight': 'inherit',
  3694. 'text-align': 'center',
  3695. cursor: 'pointer'
  3696. }).text('Go!').click(fillBRCForCity)
  3697. )
  3698. );
  3699. } else { // we need to GET to smuggling too
  3700. tr.append(
  3701. $('<td>').css({
  3702. 'border-left': '1px solid #000',
  3703. 'border-bottom': '1px solid #000'
  3704. }).html('&nbsp;').append(
  3705. $('<a>').attr({
  3706. id: 'go' + i,
  3707. href: '/smuggling.php?action=go&n=' + (bestNarc - 1) + '&b=' + (bestBooze - 1)
  3708. }).css({
  3709. 'font-weight': 'inherit',
  3710. 'text-align': 'center',
  3711. cursor: 'pointer'
  3712. }).text('Go!')
  3713. )
  3714. );
  3715. }
  3716. }
  3717. }
  3718. table.append(tr);
  3719. }
  3720. // add lex row
  3721. if (lex > 1) {
  3722. var lexDate = new Date();
  3723. table.append(
  3724. $('<tr>').append(
  3725. $('<td>').attr('colspan', '5').css({
  3726. 'text-align': 'center',
  3727. 'font-size': '10px'
  3728. }).text('Lex Level: ' + parseInt((lex - 1) * 100, 10) + ' - Seen ' + ((lexDate.getDay() != lexDay) ? '1 Day ago' : lexDate.getHours() - lexHour + ' Hours ago'))
  3729. )
  3730. );
  3731. }
  3732. // add table to page
  3733. if (on_page('prices.php') && nn == 'center') {
  3734. if ($('#brc').length === 0) {
  3735. $('#game_container').append(
  3736. $('<br />'),
  3737. table
  3738. );
  3739. }
  3740. } else {
  3741. if ($('#brc').length === 0) {
  3742. $('#game_container').append(
  3743. $('<br />'),
  3744. table
  3745. );
  3746. }
  3747. }
  3748. // bold-ify Best Run
  3749. var bestRun = allProfits.lastIndexOf(Math.max.apply(null, allProfits));
  3750. $('#brc > tbody > tr:eq(' + (3 + bestRun) + ')').css('font-weight', 'bold');
  3751.  
  3752. if (on_page('smuggling.php') && nn == 'center') {
  3753. var AF = function (sel, Xn, Xb) {
  3754. sel = parseInt(sel, 10);
  3755. var n = -1;
  3756. var b = -1;
  3757. // assemble info for AF
  3758. inputs = $('input');
  3759. var bn_xp = '.smuggling-header';
  3760. var bn_text = $(bn_xp).html().split('|');
  3761.  
  3762. cash = parseInt(bn_text[0].replace(/[^0-9.]/g, ''), 10);
  3763. booze = parseInt(bn_text[1].replace(/[^0-9.]/g, ''), 10); // max amount user can carry
  3764. narcs = parseInt(bn_text[2].replace(/[^0-9.]/g, ''), 10);
  3765.  
  3766. var b_amount = [0, 0, 0, 0, 0, 0, 0];
  3767. var n_amount = [0, 0, 0, 0, 0, 0, 0]; // what is user carrying
  3768. var xpb = 'table.thinline > tbody > tr:eq(';
  3769. var xpn = 'table.thinline:eq(1) > tbody > tr:eq(';
  3770. for (i = 0; i <= 13; i++) { // define how much of this item is being carried
  3771. if (i < 7 && !lbooze) {
  3772. b_amount[i] = parseInt($(xpb + (i + 3) + ') > td:eq(2)').text(), 10);
  3773. }
  3774. if (i > 6 && !lnarcs) {
  3775. n_amount[(i - 7)] = parseInt($(xpn + (i - 4) + ') > td:eq(2)').text(), 10);
  3776. }
  3777. }
  3778. carry_n = array_sum(n_amount);
  3779. carry_b = array_sum(b_amount); // how much is the user carrying already
  3780. // which item do we want?
  3781. key = [0, 4, 6, 1, 2, 3, 5];
  3782. if (sel === 0) { // Calc for Best Run
  3783. n = key[(bestBN[bestRun][0] - 1)]; // this trick works, even I'm amazed
  3784. b = key[(bestBN[bestRun][1] - 1)];
  3785. if ((carry_n > 0 || carry_b > 0) && Math.max.apply(Math, allProfits) === 0) {
  3786. // HACK: in this scenario we're in a high where no other
  3787. // cities would generate any profit. Just pretend we're using
  3788. // RP mode so all units get sold.
  3789. sel = 2;
  3790. }
  3791. }
  3792. if (sel == 1) { // CD Run
  3793. for (i = 0; i <= 6; i++) {
  3794. var nItem = parseInt(BN[0][i][(city - 4 + 2)], 10);
  3795. var highNarc = ((i === 0) ? nItem : ((highNarc > nItem) ? highNarc : nItem));
  3796. if (highNarc == nItem) {
  3797. n = i;
  3798. }
  3799. var bItem = parseInt(BN[1][i][(city - 4 + 2)], 10);
  3800. var highBooze = ((i === 0) ? bItem : ((highBooze > bItem) ? highBooze : bItem));
  3801. if (highBooze == bItem) {
  3802. b = i;
  3803. }
  3804. }
  3805. n = key[n];
  3806. b = key[b];
  3807. }
  3808. if (sel == 2) { // RP Run
  3809. for (i = 0; i <= 6; i++) {
  3810. var nItem = parseInt(BN[0][i][(city - 4 + 2)], 10);
  3811. var lowNarc = ((i === 0) ? nItem : ((lowNarc < nItem) ? lowNarc : nItem));
  3812. if (lowNarc == nItem) {
  3813. n = i;
  3814. }
  3815. var bItem = parseInt(BN[1][i][(city - 4 + 2)], 10);
  3816. var lowBooze = ((i === 0) ? bItem : ((lowBooze < bItem) ? lowBooze : bItem));
  3817. if (lowBooze == bItem) {
  3818. b = i;
  3819. }
  3820. }
  3821.  
  3822. n = key[n];
  3823. b = key[b];
  3824.  
  3825. /*
  3826. * Don't fill in if we can't earn RP and AF would want to buy
  3827. * Omerta sometimes won't display "NOW" when rp can be earned for b/n actions.
  3828. * it just displays "The next time you can earn rank points from buying [booze|narcs] is<end>"
  3829. * we'll handle that case too.
  3830. */
  3831. if (!lbooze) {
  3832. if (!$('.smuggling-table-info:eq(0)').text().match(/NOW|NU|booze is(\s+)$|kopen over(\s+)$/m) && $('input[name="typebooze"]:eq(1)').prop('checked') === true) {
  3833. b = -1;
  3834. }
  3835. }
  3836. if (!lnarcs) {
  3837. if (!$('.smuggling-table-info:eq(' + (lbooze ? 0 : 1) + ')').text().match(/NOW|NU|narcotics is(\s+)$|kopen over(\s+)$/m) && $('input[name="typedrugs"]:eq(1)').prop('checked') === true) {
  3838. n = -1;
  3839. }
  3840. }
  3841. }
  3842. if (sel == 3) { // None
  3843. n = b = -1;
  3844. }
  3845. if (document.location.href.indexOf('action=go') !== -1) { // user manual override using external Go! link
  3846. n = key[(GetParam('n'))];
  3847. b = key[(GetParam('b'))];
  3848. }
  3849.  
  3850. // overrule with hotkeys [ ] =
  3851. if (Xn) {
  3852. n = -1;
  3853. }
  3854. if (Xb) {
  3855. b = -1;
  3856. }
  3857.  
  3858. // we know our n and b => fill it in!
  3859. fillBRC(n, b, sel);
  3860. };
  3861. AF(getInfo[5]);
  3862.  
  3863. var AFtop = parseInt(getV('AFtop', '225'), 10);
  3864. var AFleft = parseInt(getV('AFleft', '300'), 10);
  3865. if (!$('#AF').length) {
  3866. if ((sets['af_position'] || 'floating') == 'floating') {
  3867. $('#game_container').append(
  3868. $('<div>').addClass('BRCinfo').attr({
  3869. id: 'AF'
  3870. }).css({
  3871. top: AFtop,
  3872. left: AFleft
  3873. })
  3874. );
  3875. } else {
  3876. var AFNode = $('<div>').attr({
  3877. id: 'AF'
  3878. });
  3879. $('.smuggling-header').prepend(AFNode);
  3880.  
  3881. }
  3882.  
  3883. $('#AF').append(
  3884. $('<center>').text('Auto-Fill').css('font-weight', 'bold'),
  3885. $('<hr>').css({
  3886. color: 'gray'
  3887. }),
  3888. $('<span>').append(
  3889. $('<input>').attr({
  3890. id: 'brc0',
  3891. type: 'radio',
  3892. name: 'brc'
  3893. }).click(function () {
  3894. AF(0);
  3895. try {
  3896. setV('brcAF', 0);
  3897. } catch (e) {}
  3898. }),
  3899. $('<label>').attr({
  3900. id: 'a1',
  3901. for: 'brc0',
  3902. acceskey: '8',
  3903. title: 'Fill in the most profitable b/n (Hotkey: 8 )'
  3904. }).text('Best: (8)')
  3905. ),
  3906. $('<span>').append(
  3907. $('<br />'),
  3908. $('<input>').attr({
  3909. id: 'brc1',
  3910. type: 'radio',
  3911. name: 'brc'
  3912. }).click(function () {
  3913. AF(1);
  3914. try {
  3915. setV('brcAF', 1);
  3916. } catch (e) {}
  3917. }),
  3918. $('<label>').attr({
  3919. id: 'a2',
  3920. for: 'brc1',
  3921. acceskey: '9',
  3922. title: 'Fill in the most expensive b/n (Hotkey: 9 )'
  3923. }).text('CD: (9)')
  3924. ),
  3925. $('<span>').append(
  3926. $('<br />'),
  3927. $('<input>').attr({
  3928. id: 'brc2',
  3929. type: 'radio',
  3930. name: 'brc'
  3931. }).click(function () {
  3932. AF(2);
  3933. try {
  3934. setV('brcAF', 2);
  3935. } catch (e) {}
  3936. }),
  3937. $('<label>').attr({
  3938. id: 'a3',
  3939. for: 'brc2',
  3940. acceskey: '0',
  3941. title: 'Fill in the cheapest b/n (Hotkey: 0 )'
  3942. }).text('RP: (0)')
  3943. ),
  3944. $('<span>').append(
  3945. $('<br />'),
  3946. $('<input>').attr({
  3947. id: 'brc3',
  3948. type: 'radio',
  3949. name: 'brc'
  3950. }).click(function () {
  3951. AF(3);
  3952. try {
  3953. setV('brcAF', 3);
  3954. } catch (e) {}
  3955. }),
  3956. $('<label>').attr({
  3957. id: 'a4',
  3958. for: 'brc3',
  3959. acceskey: '-',
  3960. title: 'Don\'t fill anything (Hotkey: - )'
  3961. }).text('None: (-)')
  3962. )
  3963. );
  3964. }
  3965. if ((sets['af_position'] || 'floating') == 'floating') {
  3966. $(function () {
  3967. $('#AF').draggable();
  3968. });
  3969. $('#AF').mouseup(function () {
  3970. // alert('Set the x and y values using GM_getValue.');
  3971. var divOffset = $('#AF').offset();
  3972. var left = divOffset.left;
  3973. var top = divOffset.top;
  3974. setV('AFleft', left);
  3975. setV('AFtop', top);
  3976. });
  3977. } else {
  3978. // show static AF settings in one row
  3979. $('#AF hr, #AF br').remove();
  3980. }
  3981.  
  3982. var mode = getV('brcAF', 0);
  3983.  
  3984. if ($('#do_n').length === 0) {
  3985. $('.smuggling-header').append(
  3986. $('<br />'),
  3987. $('<span>').attr({
  3988. id: 'do_n',
  3989. title: 'AutoFill just narcs according to selected BRC mode (Hotkey: [ )',
  3990. acceskey: '['
  3991. }).css('cursor', 'pointer').text('Narcs'),
  3992. $('<span>').text(' | '),
  3993. $('<span>').attr({
  3994. id: 'do_b',
  3995. title: 'AutoFill just booze according to selected BRC mode (Hotkey: ] )',
  3996. acceskey: ']'
  3997. }).css('cursor', 'pointer').text('Booze'),
  3998. $('<span>').text(' | '),
  3999. $('<span>').attr({
  4000. id: 'do_sell',
  4001. title: 'Sell all you have (Hotkey: = )',
  4002. acceskey: '='
  4003. }).css('cursor', 'pointer').text('Sell All'),
  4004. $('<br />')
  4005. );
  4006. }
  4007. $('#do_n').click(function () {
  4008. AF(getV('brcAF', 0), 0, 1);
  4009. });
  4010. $('#do_b').click(function () {
  4011. AF(getV('brcAF', 0), 1, 0);
  4012. });
  4013. $('#do_sell').click(function () {
  4014. AF(4, 1, 1);
  4015. });
  4016.  
  4017. $('input#brc' + mode).prop('checked', true);
  4018. }
  4019. }
  4020. };
  4021. if (getV('bninfo', -1) > 0) { // do we have info data?
  4022. // create info div to transfer data to XHR function
  4023. var narc = getPow('bninfo', 0, -1);
  4024. var booze = getPow('bninfo', 1, -1);
  4025. var city = getPow('bninfo', 2, -1);
  4026. var plane = getPow('bninfo', 3, -1);
  4027. var fam = getPow('bninfo', 4, -1);
  4028.  
  4029. if ($('#info').length === 0) {
  4030. $('#game_container').append(
  4031. $('<div>').attr('id', 'info').css('display', 'none').text(narc + '*' + booze + '*' + city + '*' + plane + '*' + fam + '*' + getV('brcAF', 0) + '*' + lex + '*' + lexHour + '*' + lexDay)
  4032. );
  4033. }
  4034.  
  4035. // get all prices
  4036. var i;
  4037. if (on_page('prices.php') && nn == 'center') { // prices are on the page
  4038. var j, k;
  4039. for (var BN = [], i = 0; i <= 1; i++) { // B/N
  4040. for (BN[i] = [], j = 0; j <= 6; j++) { // type
  4041. for (BN[i][j] = [], k = 0; k <= 7; k++) { // city
  4042. BN[i][j].push(parseInt($('#game_container center:eq(' + i + ') > table > tbody > tr:eq(' + (3 + k) + ') > td:eq(' + (1 + j) + ')').text().replace(/[^0-9]/g, ''), 10));
  4043. }
  4044. BN[i][j].unshift(Math.min.apply(null, BN[i][j])); // get min
  4045. BN[i][j].unshift(Math.max.apply(null, BN[i][j])); // get max
  4046. }
  4047. }
  4048. appBRC(BN);
  4049. } else {
  4050. var parsePrices = function (dom) {
  4051. for (var BN = [], i = 0; i <= 1; i++) { // B/N
  4052. for (BN[i] = [], j = 0; j <= 6; j++) { // type
  4053. for (BN[i][j] = [], k = 0; k <= 7; k++) {
  4054. BN[i][j].push(parseInt(dom.getElementsByTagName((i === 0 ? (narcnames[(j + 1)]).replace('abacco', 'obacco') : boozenames[(j + 1)]).toLowerCase())[k].textContent, 10)); // city
  4055. }
  4056. BN[i][j].unshift(Math.min.apply(null, BN[i][j])); // get min
  4057. BN[i][j].unshift(Math.max.apply(null, BN[i][j])); // get max
  4058. }
  4059. }
  4060. appBRC(BN); // send prices to BRC function
  4061. };
  4062. $.get('//' + document.location.hostname + '/BeO/webroot/index.php?module=API&action=smuggling_prices', parsePrices);
  4063. }
  4064. }
  4065.  
  4066. if (on_page('prices.php') && nn == 'center') {
  4067. var i, j, k;
  4068. var BN;
  4069. if (typeof BN == 'undefined') { // see if prices are grabbed already
  4070. for (BN = [], i = 0; i <= 1; i++) { // B/N
  4071. for (BN[i] = [], j = 0; j <= 6; j++) { // type
  4072. for (BN[i][j] = [], k = 0; k <= 7; k++) { // city
  4073. BN[i][j].push(parseInt($('#game_container center:eq(' + i + ') > table > tbody > tr:eq(' + (3 + k) + ') > td:eq(' + (1 + j) + ')').text().replace(/[^0-9]/g, ''), 10));
  4074. }
  4075. BN[i][j].unshift(Math.min.apply(null, BN[i][j])); // get min
  4076. BN[i][j].unshift(Math.max.apply(null, BN[i][j])); // get max
  4077. }
  4078. }
  4079. }
  4080.  
  4081. var highlightPriceRow = function () {
  4082. $(this).css('backgroundColor', '#888');
  4083. $('#' + (i ? 0 : 1) + 'row' + k).css('backgroundColor', '#888');
  4084. };
  4085.  
  4086. var removeHighlightPriceRow = function () {
  4087. $(this).css('backgroundColor', 'transparent');
  4088. $('#' + (i ? 0 : 1) + 'row' + k).css('backgroundColor', 'transparent');
  4089. };
  4090.  
  4091. for (i = 0; i <= 1; i++) {
  4092. for (j = 0; j <= 6; j++) {
  4093. for (k = 2; k <= 9; k++) {
  4094. if (j === 0) { // add mouseover effects
  4095. var row = $('#game_container center:eq(' + i + ') > table > tbody > tr:eq(' + (k + 1) + ')');
  4096. row.attr('id', i + 'row' + k);
  4097. row.css('borderTop', '1px solid #000');
  4098. row.hover(highlightPriceRow, removeHighlightPriceRow);
  4099. }
  4100.  
  4101. var item = $('#game_container center:eq(' + i + ') > table > tbody > tr:eq(' + (k + 1) + ') > td:eq(' + (j + 1) + ')');
  4102. item.css({
  4103. 'border-top': '1px solid #000',
  4104. 'text-align': 'center',
  4105. width: '12%'
  4106. });
  4107. if (j % 2 === 0) { // add colors to rows
  4108. item.css('backgroundColor', '#B0B0B0');
  4109. }
  4110. if (BN[i][j][k] == BN[i][j][0]) { // HL max
  4111. item.css('fontWeight', 'bold');
  4112. item.css('color', '#FF0000');
  4113. }
  4114. if (BN[i][j][k] == BN[i][j][1]) { // HL min
  4115. item.css('fontWeight', 'bold');
  4116. item.css('color', '#16E54A');
  4117. }
  4118. if (j == 5 && i === 0) { // bold-ify cocaine
  4119. item.css('fontWeight', 'bold');
  4120. }
  4121. }
  4122. }
  4123. }
  4124. }
  4125. }
  4126. // ---------------- Smuggling ----------------
  4127. if (on_page('smuggling.php') && nn == 'center') {
  4128. var lbooze = 0,
  4129. lnarcs = 0,
  4130. lboth = 0,
  4131. lex = 0;
  4132.  
  4133. // check if lackeys on
  4134. if ($('#game_container').html().match('/orourke.jpg') !== null && $('#game_container').html().match('/freekowski.jpg') !== null) {
  4135. lboth = 1;
  4136. } else if ($('#game_container').html().match('/orourke.jpg') !== null) {
  4137. lbooze = 1;
  4138. } else if ($('#game_container').html().match('/freekowski.jpg') !== null) {
  4139. lnarcs = 1;
  4140. }
  4141.  
  4142. // get input fields
  4143. var inputs = $('input');
  4144. var bn_xp = '.smuggling-header';
  4145. var bn_text = $(bn_xp).html().split('<br>');
  4146.  
  4147. var cash = parseInt(bn_text[0].replace(/[^0-9.]/g, ''), 10);
  4148. var booze = parseInt(bn_text[1].match(/\d+/), 10); // max amount user can carry
  4149. var narcs = parseInt(bn_text[2].match(/\d+/), 10);
  4150. var lexD = new Date();
  4151. var lexDay = lexD.getDay();
  4152. var lexHour = lexD.getHours();
  4153. if (bn_text[6]) {
  4154. var lex = parseInt(bn_text[6].match(/\d+/), 10);
  4155. setV('lex', lex);
  4156. setV('lexHour', lexHour);
  4157. setV('lexDay', lexDay);
  4158. } else {
  4159. setV('lex', 0);
  4160. setV('lexHour', lexHour);
  4161. setV('lexDay', lexDay);
  4162. }
  4163.  
  4164. var b_amount = [0, 0, 0, 0, 0, 0]; // what is user carrying
  4165. var n_amount = [0, 0, 0, 0, 0, 0];
  4166.  
  4167. var xpb = 'table.thinline > tbody > tr:eq(';
  4168. var xpn = 'table.thinline:eq(1) > tbody > tr:eq(';
  4169.  
  4170. if (!lboth) {
  4171. for (var i = 0; i <= 13; i++) { // add click to fill stuff and hotkeys
  4172. if (i < 7 && !lbooze) { // booze
  4173. var x = i + 3;
  4174. var bname = $(xpb + x + ') > td:eq(0)').text();
  4175. b_amount[i] = parseInt($(xpb + x + ') > td:eq(2)').html(), 10); // define how much of this item is being carried
  4176. $(xpb + x + ') > td:eq(0)').empty();
  4177. $(xpb + x + ') > td:eq(0)').append(
  4178. $('<span>').attr({
  4179. id: 'bh' + i,
  4180. index: i,
  4181. acceskey: (i + 1),
  4182. title: 'Fill in this booze (Hotkey: ' + (i + 1) + ')'
  4183. }).css('cursor', 'pointer').text((i + 1) + ' ' + bname).click(function () {
  4184. var i = parseInt($(this).attr('index'), 10);
  4185. var inpt = $('input[type="text"]');
  4186. for (var j = 0; j <= 6; j++) { // reset form
  4187. if (j != i) {
  4188. inpt[j + 1].value = 0;
  4189. }
  4190. }
  4191. var total = array_sum(b_amount);
  4192. var missing = booze - b_amount[i];
  4193. var value = parseInt(inpt[(i + 1)].value, 10);
  4194. if (b_amount[i] === 0 && total < booze) {
  4195. if (value === 0) {
  4196. inpt[(i + 1)].value = booze;
  4197. $('input[type="radio"]:eq(1)').prop('checked', true);
  4198. } else {
  4199. inpt[(i + 1)].value = 0;
  4200. }
  4201. } else if (b_amount[i] == booze) {
  4202. if (value === 0) {
  4203. inpt[(i + 1)].value = booze;
  4204. $('input[type="radio"]:eq(0)').prop('checked', true);
  4205. } else {
  4206. inpt[(i + 1)].value = 0;
  4207. }
  4208. } else if (b_amount[i] < booze && total < booze) {
  4209. if (value === 0) {
  4210. inpt[(i + 1)].value = missing;
  4211. $('input[type="radio"]:eq(1)').prop('checked', true);
  4212. } else if (value == missing) {
  4213. inpt[(i + 1)].value = b_amount[i];
  4214. $('input[type="radio"]:eq(0)').prop('checked', true);
  4215. } else {
  4216. inpt[(i + 1)].value = 0;
  4217. }
  4218. } else if (n_amount[i - 9] > booze) {
  4219. if (value === 0) {
  4220. inpt[(i + 1)].value = b_amount[i];
  4221. $('input[type="radio"]:eq(0)').prop('checked', true);
  4222. } else {
  4223. inpt[(i + 1)].value = 0;
  4224. }
  4225. } else if (b_amount[i] < booze && total > booze) {
  4226. if (value === 0) {
  4227. inpt[(i + 1)].value = b_amount[i];
  4228. $('input[type="radio"]:eq(0)').prop('checked', true);
  4229. } else {
  4230. inpt[(i + 1)].value = 0;
  4231. }
  4232. }
  4233. $('input[type=submit]').focus();
  4234. })
  4235. );
  4236. }
  4237. if (i > 6 && !lnarcs) { // narcs
  4238. var x = i - 4;
  4239. var nname = $(xpn + x + ') > td:eq(0)').text();
  4240. n_amount[(i - 7)] = parseInt($(xpn + x + ') > td:eq(2)').html(), 10); // define how much of this item is being carried
  4241. $(xpn + x + ') > td:eq(0)').empty();
  4242. $(xpn + x + ') > td:eq(0)').append(
  4243. $('<span>').attr({
  4244. id: 'nh' + i,
  4245. index: i,
  4246. title: 'Fill in this narc'
  4247. }).css('cursor', 'pointer').text(nname).click(function () {
  4248. var i = parseInt($(this).attr('index'), 10);
  4249. var inpt = $('input[type="text"]');
  4250. for (var j = 0; j <= 6; j++) { // reset form
  4251. if (j != i - 7) {
  4252. if (lbooze) {
  4253. inpt[j + 1].value = 0;
  4254. } else {
  4255. inpt[j + 8].value = 0;
  4256. }
  4257. }
  4258. }
  4259. var total = array_sum(n_amount);
  4260. var missing = narcs - n_amount[i - 7];
  4261. var value;
  4262. if (lbooze) {
  4263. value = parseInt(inpt[i - 6].value, 10);
  4264. } else {
  4265. value = parseInt(inpt[(i + 1)].value, 10);
  4266. }
  4267. if (n_amount[i - 7] === 0 && total < narcs) {
  4268. if (value === 0) {
  4269. if (lbooze) {
  4270. inpt[i - 6].value = narcs;
  4271. $('input[type="radio"]:eq(1)').prop('checked', true);
  4272. } else {
  4273. inpt[(i + 1)].value = narcs;
  4274. $('input[type="radio"]:eq(3)').prop('checked', true);
  4275. }
  4276. } else {
  4277. inpt[(i + 1)].value = 0;
  4278. }
  4279. } else if (n_amount[i - 7] == narcs) {
  4280. if (value === 0) {
  4281. if (lbooze) {
  4282. inpt[i - 6].value = narcs;
  4283. $('input[type="radio"]:eq(0)').prop('checked', true);
  4284. } else {
  4285. inpt[(i + 1)].value = narcs;
  4286. $('input[type="radio"]:eq(2)').prop('checked', true);
  4287. }
  4288. } else {
  4289. inpt[(i + 1)].value = 0;
  4290. }
  4291. } else if (n_amount[i - 7] < narcs && total < narcs) {
  4292. if (value === 0) {
  4293. if (lbooze) {
  4294. inpt[i - 6].value = missing;
  4295. $('input[type="radio"]:eq(1)').prop('checked', true);
  4296. } else {
  4297. inpt[(i + 1)].value = missing;
  4298. $('input[type="radio"]:eq(3)').prop('checked', true);
  4299. }
  4300. } else if (value == missing) {
  4301. if (lbooze) {
  4302. inpt[i - 6].value = n_amount[i - 7];
  4303. $('input[type="radio"]:eq(0)').prop('checked', true);
  4304. } else {
  4305. inpt[(i + 1)].value = n_amount[i - 7];
  4306. $('input[type="radio"]:eq(3)').prop('checked', true);
  4307. }
  4308. } else {
  4309. inpt[(i + 1)].value = 0;
  4310. }
  4311. } else if (n_amount[i - 7] > narcs) {
  4312. if (value === 0) {
  4313. if (lbooze) {
  4314. inpt[i - 6].value = n_amount[i - 7];
  4315. $('input[type="radio"]:eq(0)').prop('checked', true);
  4316. } else {
  4317. inpt[(i + 1)].value = n_amount[i - 7];
  4318. $('input[type="radio"]:eq(3)').prop('checked', true);
  4319. }
  4320. } else {
  4321. inpt[(i + 1)].value = 0;
  4322. }
  4323. } else if (b_amount[i] < narcs && total > narcs) {
  4324. if (value === 0) {
  4325. if (lbooze) {
  4326. inpt[i - 6].value = n_amount[i - 7];
  4327. $('input[type="radio"]:eq(0)').prop('checked', true);
  4328. } else {
  4329. inpt[(i + 1)].value = n_amount[i - 7];
  4330. $('input[type="radio"]:eq(2)').prop('checked', true);
  4331. }
  4332. } else {
  4333. inpt[(i + 1)].value = 0;
  4334. }
  4335. }
  4336. $('input[type=submit]').focus();
  4337. })
  4338. );
  4339. }
  4340. }
  4341. }
  4342.  
  4343. var inp = $('input[name="typebooze"], input[name="typedrugs"]');
  4344. inp.each(function () {
  4345. $(this).click(function () {
  4346. if ($('input[type=submit]').length) {
  4347. $('input[type=submit]').focus();
  4348. }
  4349. });
  4350. });
  4351.  
  4352. // visual fix
  4353. if (lnarcs) {
  4354. $('form > table > tbody > tr:eq(1) > td:eq(1)').prepend(
  4355. $('<br />'),
  4356. $('<br />')
  4357. );
  4358. $('table.thinline:eq(1)').append(
  4359. $('<br />')
  4360. );
  4361. }
  4362. if (lbooze) {
  4363. $('form > table > tbody > tr:eq(1) > td:eq(0)').prepend(
  4364. $('<br />'),
  4365. $('<br />')
  4366. );
  4367. $('table.thinline:eq(0)').append(
  4368. $('<br />')
  4369. );
  4370. }
  4371.  
  4372. // create more efficient info text
  4373. var str = $('<span>').text('Pocket: $ ' + commafy(cash) + ' | Booze: ' + booze + ' | Narcs: ' + narcs + ' | Lex: ' + lex);
  4374. $(bn_xp).html(str).append(
  4375. $('<br />'),
  4376. $('<a>').attr({
  4377. href: 'prices.php',
  4378. target: 'main'
  4379. }).text('Current Booze/Narcotics Prices')
  4380. );
  4381. if (!lboth) {
  4382. $('input[type=submit]').focus(); // focus captcha field
  4383. }
  4384. }
  4385.  
  4386. if (on_page('module=travel')) {
  4387. if (notificationsArray['Travel'] !== undefined) {
  4388. notificationsArray['Travel'].close();
  4389. delete notificationsArray['Travel'];
  4390. }
  4391. }
  4392.  
  4393. // ---------------- Crime Page ----------------
  4394. if (on_page('module=Crimes') && nid == 'module_Crimes') {
  4395. if (notificationsArray['Crime'] !== undefined) {
  4396. notificationsArray['Crime'].close();
  4397. delete notificationsArray['Crime'];
  4398. }
  4399. // Grab money stolen
  4400. var moneyStolenText = $('#game_container').text().trim();
  4401. if (moneyStolenText.match(/\$ ([,\d]+)/) !== null) {
  4402. var oldValue = parseInt(getV('crimeMoney', 0), 10);
  4403. var sum = parseInt(moneyStolenText.match(/\$ ([,\d]+)/)[1].replace(',', ''), 10);
  4404. setV('crimeMoney', (sum + oldValue));
  4405.  
  4406. var totalSuccess = parseInt(getV('crimeSuccess', 0), 10);
  4407. ++totalSuccess;
  4408. setV('crimeSuccess', totalSuccess);
  4409. }
  4410. // focus and highlight last crime option
  4411. $('#crime-choices .popup-place-wrapper:last').addClass('active');
  4412. $('#crime-choices button:last').focus();
  4413. }
  4414.  
  4415. // ---------------- Cars Page ----------------
  4416. if (on_page('module=Cars') && nid == 'module_Cars') {
  4417. // Close notifications
  4418. if (notificationsArray['Car'] !== undefined) {
  4419. notificationsArray['Car'].close();
  4420. delete notificationsArray['Car'];
  4421. }
  4422. // Grab value of stolen car (does not include cars stolen by lackeys)
  4423. var carValText = $('#game_container').text().trim();
  4424. if (carValText.match(/\$ ([,\d]+)/) !== null) {
  4425. var oldValue = parseInt(getV('carMoney', 0), 10);
  4426. var sum = parseInt(carValText.match(/\$ ([,\d]+)/)[1].replace(',', ''), 10);
  4427. setV('carMoney', (sum + oldValue));
  4428. var totalSuccess = parseInt(getV('carSuccess', 0), 10);
  4429. ++totalSuccess;
  4430. setV('carSuccess', totalSuccess);
  4431. }
  4432. var maxValue = 0;
  4433. var maxIndex = 3;
  4434. $('#nick-car-choices .head h4').each(function (i) {
  4435. if (parseInt($(this).text().replace('%', ''), 10) > maxValue) {
  4436. maxValue = parseInt($(this).text().replace('%', ''), 10);
  4437. maxIndex = i;
  4438. }
  4439. });
  4440. $('#nick-car-choices .popup-place-wrapper:eq(' + maxIndex + ')').addClass('active');
  4441. $('#nick-car-choices button:eq(' + maxIndex + ')').focus();
  4442. }
  4443. // Lackeys are on, show lackey page enhancements
  4444. if (on_page('module=Cars') && nclass == 'otable widetable') {
  4445. var itemspath = 'table[data-info="items"] > tbody > tr[data-id]';
  4446. // Loop cars
  4447. var x = 0;
  4448. var totalCarval = 0;
  4449. $(itemspath).each(function () {
  4450. // grab value
  4451. var carVal = parseInt($(itemspath + ':eq(' + x + ') > td:eq(4)').text().replace(',', '').replace('$', ''), 10);
  4452. totalCarval += carVal;
  4453. ++x;
  4454. });
  4455. // Show total value
  4456. $('div.oheader:eq(2)').text($(itemspath).length + $('div.oheader:eq(2)').text()).append(
  4457. $('<span>').text('total value: $' + commafy(totalCarval))
  4458. );
  4459. }
  4460. // ---------------- Obay ----------------
  4461. if (on_page('obay.php') && !on_page('specific') && nn == 'center') {
  4462. $('table.thinline:eq(2) > tbody > tr').each(function () {
  4463. if (['one', 'two', 'three'].indexOf($(this).attr('class')) > -1) { // this row has an object
  4464. var sort_b = (on_page('type=11')) ? 1 : 0; // are we sorting on bullets?
  4465. // add price per bullets
  4466. if ($(this).text().indexOf('bullets') != -1) {
  4467. var bullets = parseInt($(this).find('td:eq(' + (2 - sort_b) + ')').text().replace(/[^0-9.]/g, ''), 10);
  4468. var money = parseInt($(this).find('td:eq(' + (3 - sort_b) + ')').text().replace(/[^0-9.]/g, ''), 10);
  4469. var ppb = parseInt(money / bullets, 10);
  4470. $(this).find('td:eq(' + (2 - sort_b) + ')').text($(this).find('td:eq(' + (2 - sort_b) + ')').text() + ' ($' + commafy(ppb) + ')');
  4471. }
  4472. }
  4473. });
  4474. }
  4475. if (on_page('obay.php?specific=') && nn == 'center') {
  4476. $('input[name="anon"][value="0"]').prop('checked', 'checked');
  4477. $('input[type="submit"]').focus();
  4478. }
  4479. // ---------------- Garage ----------------
  4480. if ((on_page('garage.php') || on_page('module=Cars')) && nn == 'h2') {
  4481. var totVal = 0;
  4482. var types = [
  4483. ['h', 8, 9, 13, 15, 16, 17, 18, 19, 21, 22, 27, 32, 34, 35, 40, 43],
  4484. ['oc', 23, 25, 26, 28, 29, 30, 31, 33, 39, 41, 42],
  4485. ['moc', 45, 47, 48],
  4486. ['tr', 23, 47, 54]
  4487. ];
  4488. $('tr.thinline').each(function () { // loop rows
  4489. var carid = $(this).find('td:eq(0)').text();
  4490. var carVal = parseInt($(this).find('td:eq(3)').html().replace(',', '').replace('$', ''), 10); // get value
  4491. totVal += carVal;
  4492. $(this).click(function (e) {
  4493. var check = $(this).find('input[value="' + carid + '"]');
  4494. if (e.target.tagName != 'INPUT') {
  4495. check.click();
  4496. }
  4497. });
  4498. });
  4499. // add amount of bullets
  4500. var head = $('h2');
  4501. var cars = head.text().match(/\d+/g)[2];
  4502. if (cars > 0) {
  4503. head.append(
  4504. $('<span>').text(' | Potential Bullets: ' + cars * 12)
  4505. );
  4506. }
  4507. // add amount of money
  4508. if (totVal > 0) {
  4509. head.append(
  4510. $('<span>').text(' | Total car value of this page: $' + commafy(totVal))
  4511. );
  4512. }
  4513. // scrolldown link
  4514. $('<div>').css({
  4515. float: 'right',
  4516. cursor: 'pointer'
  4517. }).append(
  4518. $('<span>').text('Scroll down').click(function () {
  4519. $('#game_container_wrapper').animate({
  4520. scrollTop: $('#game_container').height()
  4521. }, 1000);
  4522. })
  4523. ).insertBefore('table.thinline');
  4524. $(window).scroll(toggleFooterVisibility);
  4525. $('td:has(input[value="SH-cars"]), #footer').append(
  4526. $('<select>').attr({
  4527. name: 'selsort'
  4528. }).append(
  4529. $('<option>').attr('value', '0').text('-----'),
  4530. $('<option>').attr('value', '1').text('Above'),
  4531. $('<option>').attr('value', '2').text('Below'),
  4532. $('<option>').attr('value', '3').text('Between')
  4533. ).on('change', function() {
  4534. $(this).siblings('[name="selval2"]').toggle($(this).val() === '3');
  4535. }),
  4536. $('<input>').attr({
  4537. type: 'text',
  4538. name: 'selval',
  4539. size: '9'
  4540. }),
  4541. $('<input>').attr({
  4542. type: 'text',
  4543. name: 'selval2',
  4544. size: '9'
  4545. }).css('display', 'none'),
  4546. $('<input>').attr({
  4547. type: 'button',
  4548. name: 'selgo',
  4549. value: 'Select'
  4550. }).click(function () {
  4551. var sort = $(this).siblings('[name="selsort"]').val();
  4552. var val = $(this).siblings('[name="selval"]').val();
  4553. if (val !== '' && sort != '-----') {
  4554. var maxPrice = $(this).siblings('[name="selval2"]').val();
  4555. $('tr.thinline').each(function () { // loop rows
  4556. var carid = $(this).find('td:eq(0)').text();
  4557. var carVal = parseInt($(this).find('td:eq(3)').html().replace(',', '').replace('$', ''), 10); // get value
  4558. var check = $(this).find('input[value="' + carid + '"]');
  4559. var comment = $(this).find('td:eq(6)').text().trim();
  4560. if (check.prop('checked') === true) {
  4561. check.click();
  4562. }
  4563. var carWorthAbove = sort == 1 && carVal > val;
  4564. var carWorthBelow = sort == 2 && carVal < val;
  4565. var carWorthBetween = (sort == 3 && carVal >= val && (carVal <= maxPrice));
  4566. if (carWorthAbove || carWorthBelow || carWorthBetween) {
  4567. if (comment.indexOf('IN SAFEHOUSE') === -1) {
  4568. check.click();
  4569. }
  4570. }
  4571. });
  4572. }
  4573. })
  4574. );
  4575. }
  4576. // ---------------- Kill page ----------------
  4577. if (on_page('module=Detectives') && nn == 'div') {
  4578. if (nid == 'wrappertest') {
  4579. if (GetParam('search')) {
  4580. $('input[name="target"]').val(GetParam('search'));
  4581. }
  4582. }
  4583.  
  4584. // Fire all Detectives that have failed searching for person X
  4585. // Translation variables
  4586. var failedMessage = (v == 'nl' ? 'gefaald' : 'failed');
  4587. var fireDetectivesMessage = (v == 'nl' ? 'Verwijder gefaalde detectives' : 'Fire all failed detectives');
  4588.  
  4589. $('input[data-action="fireAll"]').closest('td').css('width', 'auto').after(
  4590. $('<td>').attr('align', 'right').append(
  4591. $('<input id="ob_fire_all" type="button" value="' + fireDetectivesMessage + '"">').click(function() {
  4592. $('#ob_fire_all').val('Firing..').prop('disabled', true);
  4593. var fireDetectives = function () {
  4594.  
  4595. // Loop over each row in the table, except the last row
  4596. $('.otable > table > tbody > tr:not(:last-child)').each(function() {
  4597. var detectiveText = $(this).find('td:first').text();
  4598. var ajaxID = $(this).find('td:nth-child(2) a').attr('data-id');
  4599. var elem = this;
  4600.  
  4601. // Check if the row contains 'failed', which means the detective hasn't found the person
  4602. // In case he hasn't, its safe to remove that detective
  4603.  
  4604. if (wordInString(detectiveText, failedMessage)) {
  4605. $.post('//' + document.location.hostname + '/BeO/webroot/?module=Detectives&action=fire', { id: ajaxID }).done(function() {
  4606. $('#ob_fire_all').val('Detectives fired!');
  4607. $(elem).closest('tr').hide();
  4608. });
  4609. }
  4610. });
  4611. };
  4612. fireDetectives();
  4613. })
  4614. )
  4615. );
  4616.  
  4617. // Disable the input box if there are no messages of failed detectives
  4618. if ($('#detectives-hired-div:contains("' + failedMessage + '")').length > 0) {
  4619. $('#ob_fire_all').prop('disabled', false);
  4620. } else {
  4621. $('#ob_fire_all').prop('disabled', true);
  4622. }
  4623.  
  4624. // If a user inserts '60k', automatically change it to '60.000'.
  4625. // This should work for every value in front of the 'k'
  4626.  
  4627. $('input[name="bullets"]').keydown(function (event) {
  4628. var symcode = event.which;
  4629. if (symcode == 75) {
  4630. $(this).val($(this).val() + '000');
  4631. }
  4632. $(this).val($(this).val().replace(/k/g, ''));
  4633. return (symcode == 75) ? false : true;
  4634. });
  4635.  
  4636. }
  4637. // ---------------- Misc ----------------
  4638. // look its me
  4639. if ((on_page('users_online') && nn == 'center') || (on_page('allusers.php') && nn == 'div') || (on_page('global_stats')) && nn == 'center') {
  4640. var nick = getV('nick', '');
  4641. if (nick !== '') {
  4642. $('a[class!="link"]').each(function () {
  4643. if ($(this).text() == nick || $(this).text() == nick + '+') {
  4644. $(this).html('<span style="color:green;font-weight:bold;">' + $(this).html() + '</span>');
  4645. }
  4646. });
  4647. }
  4648. }
  4649. // quick lookup
  4650. if (on_page('user.php') && nn == 'span') {
  4651. var input = GetParam('nick');
  4652. var str = (v == 'nl' ? 'Deze speler bestaat niet' : 'This user does not exist');
  4653. if ($('#game_container:contains("' + str + '")').length && input !== false) {
  4654. setTimeout(function () {
  4655. $.getJSON(OB_API_WEBSITE + '/?p=quicklookup&v=' + v + '&input=' + input, function (data) {
  4656. $('#game_container').html(str + ': ' + input);
  4657. var html = '';
  4658. var i = 0;
  4659. for (var results in data) {
  4660. if (data.hasOwnProperty(results)) {
  4661. if (i < 50) {
  4662. html += '<br /><a href="user.php?nick=' + results + '" id="' + i + '" class="sel">' + results + '</a>';
  4663. }
  4664. }
  4665. i++;
  4666. }
  4667. var total = i === 0 ? 0 : ++i;
  4668. if (input.length < 3) {
  4669. $('#game_container').html(str + ': ' + input + '<br />This will give too many results. Try to be more specific.');
  4670. } else if (total !== 0) {
  4671. $('#game_wrapper_container').css('height', '99%');
  4672. $('span.title-main').text('Quick lookup by Omerta Beyond');
  4673. $('#game_container').html((total <= 50) ? str + ': ' + input + '<br />Maybe this is what you were looking for:<br />' : str + ': ' + input + '<br />Maybe this is what you were looking for:<br />Total results: ' + total + ' Showing first 50 results<br />');
  4674. $('#game_container').html($('#game_container').html() + html);
  4675. $('#0').focus();
  4676. var j = 0;
  4677. $(window).keydown(function (event) {
  4678. if (event.keyCode == 40) {
  4679. if (j < num - 1) {
  4680. j++;
  4681. $('#' + j).focus();
  4682. }
  4683. }
  4684. });
  4685. $(window).keydown(function (event) {
  4686. if (event.keyCode == 38) {
  4687. if (j !== 0) {
  4688. j--;
  4689. $('#' + j).focus();
  4690. }
  4691. }
  4692. });
  4693. } else {
  4694. $('#game_container').html(str + ': ' + input + '<br />Sorry, we also couldn\'t find any alternatives.');
  4695. }
  4696. });
  4697. }, 100);
  4698. }
  4699. }
  4700. // ---------------- Blood AF ----------------
  4701. if (on_page('module=Bloodbank') && nn == 'table') {
  4702. var table, tr, A, B, m, type, types;
  4703. type = getV('bloodType');
  4704.  
  4705. var bloodAF = function (t) {
  4706. // setup costs row
  4707. table = $('table.thinline:eq(1)');
  4708. tr = $('<tr>').html('<td><font size="2"><b> &nbsp;Total Costs </b></font></td><td align="center"><font size="2" id="A"></font></td><td align="center"><font size="2" id="B"></font></td><td align="center"><font size="2" id="AB"></font></td><td align="center"><font size="2" id="O"></font></td>');
  4709. table.append(tr);
  4710.  
  4711. function getType(num) {
  4712. return parseInt($('table.thinline:eq(1) > tbody > tr:eq(2) > td:eq(' + num + ')').text().replace('$ ', ''), 10);
  4713. }
  4714.  
  4715. function setType(num) {
  4716. return ($('select').get(0).selectedIndex = num);
  4717. }
  4718.  
  4719. function calc(a, b, ab, o) { // see if user can buy bloodtype and then calc total price
  4720. $('font#A').text(a ? '$ ' + m * $('td[align="center"]:eq(9)').text().replace('$ ', '') : 'X');
  4721. $('font#B').text(b ? '$ ' + m * $('td[align="center"]:eq(10)').text().replace('$ ', '') : 'X');
  4722. $('font#AB').text(ab ? '$ ' + m * $('td[align="center"]:eq(11)').text().replace('$ ', '') : 'X');
  4723. $('font#O').text(o ? '$ ' + m * $('td[align="center"]:eq(12)').text().replace('$ ', '') : 'X');
  4724. }
  4725. if ($('input[name="UnitsToBuy"]').length) {
  4726. m = parseInt($('input[name="UnitsToBuy"]').val(), 10);
  4727. types = [getType('1'), getType('2'), getType('3'), getType('4')];
  4728. A = [types[0], types[3]];
  4729. B = [types[1], types[3]];
  4730.  
  4731. if (t == 'A') {
  4732. calc(1, 0, 0, 1);
  4733. setType(iMin(A));
  4734. }
  4735. if (t == 'B') {
  4736. calc(0, 1, 0, 1);
  4737. setType(iMin(B));
  4738. }
  4739. if (t == 'AB') {
  4740. calc(1, 1, 1, 1);
  4741. setType(iMin(types));
  4742. }
  4743. if (t == 'O') {
  4744. calc(0, 0, 0, 1);
  4745. setType(0);
  4746. }
  4747. $('input[name="Buy"]').focus();
  4748. } else {
  4749. calc(0, 0, 0, 0);
  4750. }
  4751. };
  4752. bloodAF(type);
  4753. }
  4754. // ---------------- Bodyguards ----------------
  4755. if (on_page('module=Bodyguards') && nn == 'div') {
  4756. // Hide bio
  4757. $('div[id$="BoughtBG"]').css('display', 'none');
  4758. // set timer for BG if it counts down
  4759. ScheduleNotification(
  4760. 'bg',
  4761. $('[data-timecb="bodyguard"]').attr('data-time-end'),
  4762. 'Train Bodyguard (' + v + ')',
  4763. (v == 'nl' ? 'Je kunt je bodyguard weer trainen' : 'You can train your bodyguard again'),
  4764. 'bodyguard',
  4765. '/?module=Bodyguards',
  4766. assetUrl('/images/red-star.png')
  4767. );
  4768. }
  4769. // ---------------- Raid Result @ Statistics and Spots ----------------
  4770. if (on_page('global_stats') || on_page('module=Spots')) {
  4771. var isSpots = on_page('module=Spots');
  4772. // add possible raid profit in a new column for all objects
  4773. $('td:contains("Profit"), td:contains("Winst"), td:contains("Kazanc")').closest('table').find('tr').each(function() {
  4774. var tableHeader;
  4775. if (isSpots) {
  4776. tableHeader = $(this).find('td[colspan="7"]');
  4777. } else {
  4778. tableHeader = $(this).find('td.tableheader, td[bgcolor="black"]');
  4779. }
  4780. if (tableHeader.length > 0) {
  4781. // increase colspan of table header
  4782. tableHeader.each(function() {
  4783. $(this).attr('colspan', parseInt($(this).attr('colspan'), 10) + 1);
  4784. });
  4785. return;
  4786. }
  4787. if (isSpots && $(this).find('td:first').hasClass('tableheader')) {
  4788. $(this).find('td.tableheader:eq(4)').after($('<td class="tableheader"><b class="raid_profit_tooltip" title="Best Possible Raid Result per Player">Result</b></td>'));
  4789. return;
  4790. }
  4791. var firstRowText = $(this).find('td:first').text();
  4792. if (firstRowText == 'City:' || firstRowText == 'Stad:') {
  4793. // add table header
  4794. $(this).append($('<td><b class="raid_profit_tooltip" title="Best Possible Raid Result per Player">Raid Result:</b></td>'));
  4795. return;
  4796. }
  4797. if (isSpots && $(this).find('td[colspan="3"]').length > 0) {
  4798. // make Bankrupt/OOB columns wider
  4799. $(this).find('td[colspan="3"]').attr('colspan', '4');
  4800. return;
  4801. }
  4802. if (!isSpots) {
  4803. // make city column a bit smaller
  4804. $(this).find('td:first').attr('width', '130');
  4805. }
  4806. var profit;
  4807. if (isSpots) {
  4808. profit = parseInt($(this).find('td.text-green').text().replace(/,|\$/g, ''), 10);
  4809. } else {
  4810. if ($(this).find('.profit').length > 0) {
  4811. profit = parseInt($(this).find('.profit').text().replace(/,|\$/g, ''), 10);
  4812. } else {
  4813. profit = 0;
  4814. }
  4815. }
  4816. if (profit > 0) {
  4817. // row with running + profitable object
  4818. var protection = parseInt($(this).find('.percent').text().replace('%', ''), 10);
  4819. var raidResult = calcRaidResult(profit, protection);
  4820. if (isSpots) {
  4821. $(this).find('td:eq(4)').after('<td>$ ' + commafy(Math.floor(raidResult)) + '</td>');
  4822. } else {
  4823. $(this).append('<td>$ ' + commafy(Math.floor(raidResult)) + '</td>');
  4824. }
  4825. } else if (isSpots || $(this).find('.loss').length > 0 || $(this).text().indexOf('None') !== -1 || $(this).text().indexOf('Geen') !== -1) {
  4826. // append empty column for spots with losses or no profit
  4827. // border will be gone otherwise
  4828. if (isSpots) {
  4829. $(this).find('td:eq(4)').after('<td></td>');
  4830. } else {
  4831. $(this).append('<td></td>');
  4832. }
  4833. }
  4834. });
  4835. }
  4836. // ---------------- Statistics ----------------
  4837. if (on_page('module=Statistics') || on_page('allusers.php')) {
  4838. $('a[data-href*="/allusers.php"]').attr('href', '/allusers.php?start=0&order=lastrank&sort=DESC&dead=HIDE');
  4839. }
  4840. // ---------------- END OF MAIN GAME CONTAINER ----------------
  4841.  
  4842. // prefs circle
  4843. var prefs_div = $('<div>').addClass('sm-circle-bg ob-prefs-bg').append(
  4844. $('<span>').addClass('sm-circle sm-health').append(
  4845. $('<img>').attr({
  4846. src: assetUrl('/images/favicon.png'),
  4847. title: 'Omerta Beyond Preferences'
  4848. }).addClass('ob-prefs-img')
  4849. ).hover(
  4850. function() {
  4851. $(this).css('background', '#000FF0');
  4852. },
  4853. function() {
  4854. $(this).css('background', '#FFF');
  4855. }
  4856. )
  4857. ).click(function () {
  4858. $('span.title-main').text('Omerta Beyond Preferences');
  4859. $('#game_container').empty();
  4860. $('#game_wrapper_container').css('height', '99%');
  4861. $('#game_container').append(GetPrefPage());
  4862. });
  4863. if (versionHasLogger) {
  4864. // live famstats circle (needs new icon!)
  4865. var lf_div = $('<div>').addClass('sm-circle-bg ob-lf-bg').append(
  4866. $('<span>').addClass('sm-circle sm-health').append(
  4867. $('<img>').attr({
  4868. src: assetUrl('/images/favicon.png'),
  4869. title: 'Omerta Beyond Live Famstats'
  4870. }).addClass('ob-prefs-img')
  4871. ).hover(
  4872. function() {
  4873. $(this).css('background', '#1EB418');
  4874. },
  4875. function() {
  4876. $(this).css('background', '#FFF');
  4877. }
  4878. )
  4879. ).click(function () {
  4880. window.open(OB_RIX_WEBSITE + '/stats.php?v=' + v + '&d=n');
  4881. });
  4882.  
  4883. if ($('.ob-lf-bg').length === 0) {
  4884. $('div.omerta-widget-avatar-body').append(lf_div);
  4885. }
  4886. }
  4887.  
  4888. if ($('.ob-prefs-bg').length === 0) {
  4889. $('div.omerta-widget-avatar-body').append(prefs_div);
  4890. }
  4891. };
  4892. }
  4893.  
  4894. /*
  4895. * Pages without only text nodes
  4896. */
  4897.  
  4898. $('#game_container').on('DOMNodeInserted', function() {
  4899. if (on_page('jail.php')) {
  4900. // Return when self bo
  4901. if ($('#game_container:contains("You busted yourself out of jail")').length) {
  4902. if (!$('#bo_fired').length) {
  4903. var bos = parseInt(getV('bustouts', 0), 10);
  4904. bos = (bos + 1);
  4905. setV('bustouts', bos);
  4906. $('#game_container').append($('<span>').attr('id', 'bo_fired'));
  4907. unsafeWindow.omerta.GUI.container.loadPage(window.location.hash.substr(1));
  4908. }
  4909. }
  4910. // Return when busted
  4911. if ($('#game_container:contains("You are not in jail!")').length) {
  4912. if (!$('#bo_fired').length) {
  4913. $('#game_container').append($('<span>').attr('id', 'bo_fired'));
  4914. unsafeWindow.omerta.GUI.container.loadPage(window.location.hash.substr(1));
  4915. }
  4916. }
  4917. }
  4918. });
  4919.  
  4920. /*
  4921. * Notifications trigger & marquee
  4922. */
  4923.  
  4924. var prevPrices = [];
  4925. var firstTimePrice = true;
  4926. $('#game_container').one('DOMNodeInserted', function () {
  4927. if (versionHasLogger) {
  4928. setTimeout(function () {
  4929. CheckBmsg();
  4930. }, 1000);
  4931. }
  4932. setTimeout(function() {
  4933. CheckServiceVariable();
  4934. }, 1000);
  4935.  
  4936. function buildMarquee() {
  4937. setTimeout(function () {
  4938. $.get('//' + document.location.hostname + '/BeO/webroot/index.php?module=API&action=smuggling_prices', function (dom) {
  4939. function getPrice(drug, city) {
  4940. return dom.getElementsByTagName(drug)[city].textContent;
  4941. }
  4942.  
  4943. function refreshMarquee(h, m) {
  4944. h = (m >= 31 ? h + 1 : h);
  4945. m = (m >= 31 ? 1 : 31);
  4946. var marQd = new Date();
  4947. marQd.setHours(h);
  4948. marQd.setMinutes(m);
  4949. marQd.setSeconds(0);
  4950. marQd.setMilliseconds(0);
  4951. return (marQd.getTime() - getOmertaTime());
  4952. }
  4953.  
  4954. var p = [];
  4955. var q = [];
  4956. var pricesChanged = false;
  4957.  
  4958. for (var i = 0; i <= 7; i++) {
  4959. p[i] = getPrice('cocaine', i);
  4960. q[i] = p[i];
  4961. if ((prevPrices === undefined || prevPrices[i] === undefined) || prevPrices[i] != p[i]) {
  4962. pricesChanged = true;
  4963. }
  4964. }
  4965.  
  4966. if (pricesChanged) {
  4967. prevPrices = JSON.parse(JSON.stringify(q));
  4968. } else {
  4969. setTimeout(buildMarquee, 30000);
  4970. return;
  4971. }
  4972.  
  4973. var max = p.sort(function (a, b) {
  4974. return b - a;
  4975. })[0];
  4976. var min = p[(p.length - 1)];
  4977.  
  4978. var highCity = '';
  4979. var highCityPrice = 0;
  4980. var lowCity = '';
  4981. var lowCityPrice = 0;
  4982. i = 0;
  4983. q.forEach(function ($n) {
  4984. if ($n == min) {
  4985. q[i] = '<span style="color:#00ff00;">' + $n + '</span>';
  4986. lowCity = cities[i];
  4987. lowCityPrice = $n;
  4988. }
  4989. if ($n == max) {
  4990. q[i] = '<span style="color:' + '#ff5353' + ';">' + $n + '</span>';
  4991. highCity = cities[i];
  4992. highCityPrice = $n;
  4993. }
  4994. i++;
  4995. });
  4996.  
  4997. if (!firstTimePrice && (prefs['notify_bn'] || prefs['notify_bn_sound'])) {
  4998. if (prefs['notify_bn']) {
  4999. SendNotification('B/N prices changed', 'High city: ' + highCity + ' (' + highCityPrice + ')\nLow city: ' + lowCity + ' (' + lowCityPrice + ')', 'Booze', './BeO/webroot/index.php?module=Travel', assetUrl('/images/red-star.png'));
  5000. }
  5001.  
  5002. if (prefs['notify_bn_sound']) {
  5003. playSound('bn');
  5004. }
  5005. }
  5006.  
  5007. firstTimePrice = false;
  5008.  
  5009. var time = dom.getElementsByTagName('humantime')[0].textContent;
  5010. time = time.split(' ')[0];
  5011. time = time.split(':');
  5012. time = (time[1] < 30) ? time[0] + ':00 OT' : time[0] + ':30 OT';
  5013.  
  5014. function hovermenu(city) {
  5015. var hoverStyle = {
  5016. display: 'block',
  5017. position: 'fixed',
  5018. left: $('#marquee').offset().left,
  5019. top: '42px',
  5020. zIndex: '102',
  5021. opacity: 0.8,
  5022. backgroundColor: 'black',
  5023. color: '#EEE',
  5024. border: 'none',
  5025. padding: '5px 15px 5px 15px'
  5026. };
  5027. $('#hiddenbox').css(hoverStyle).html('Morphine: ' + getPrice('morphine', city) + ' | ' + 'Heroin: ' + getPrice('heroin', city) + ' | ' + 'Opium: ' + getPrice('opium', city) + ' | ' + 'Whiskey: ' + getPrice('whiskey', city) + ' | ' + 'Amaretto: ' + getPrice('amaretto', city) + ' | ' + 'Rum: ' + getPrice('rum', city));
  5028. }
  5029.  
  5030. function flytolink(city, priceStr) {
  5031. var link = $('<a>').attr({
  5032. id: cities[city],
  5033. href: '#'
  5034. }).css({
  5035. color: '#FFF',
  5036. fontSize: '10px'
  5037. }).click(function () {
  5038. unsafeWindow.omerta.GUI.container.loadPage('./BeO/webroot/index.php?module=Travel&action=FetchInfo&CityId=' + ((city == 'nul') ? 0 : city));
  5039. });
  5040.  
  5041. if (city == 5 || city == 6 || city == 7) {
  5042. link.mouseover(function () {
  5043. hovermenu(city);
  5044. $(this).css('textDecoration', 'underline');
  5045. });
  5046. } else if (city === 0 || city == 1 || city == 2) {
  5047. link.mouseover(function () {
  5048. hovermenu(city);
  5049. $(this).css('textDecoration', 'underline');
  5050. });
  5051. } else {
  5052. link.mouseover(function () {
  5053. hovermenu(city);
  5054. $(this).css('textDecoration', 'underline');
  5055. });
  5056. }
  5057. link.mouseout(function () {
  5058. $('#hiddenbox').css('display', 'none');
  5059. $(this).css('textDecoration', 'none');
  5060. });
  5061. link.html(priceStr);
  5062.  
  5063. return link;
  5064. }
  5065.  
  5066. var span = $('<span>').append(
  5067. $('<span>').text(time + ': ').css('font-size', '10px')
  5068. );
  5069.  
  5070. i = 0;
  5071. p.forEach(function () {
  5072. span.css('color', '#FFF');
  5073. span.append(flytolink(i, cities[i] + ':' + q[i]), $('<span>').text(' | '));
  5074. i++;
  5075. });
  5076.  
  5077. span.append(
  5078. $('<a>').attr({
  5079. href: 'prices.php'
  5080. }).text('All Prices').css({
  5081. color: '#FFF',
  5082. fontSize: '10px'
  5083. }).hover(function () {
  5084. $(this).css('textDecoration', 'underline');
  5085. }, function () {
  5086. $(this).css('textDecoration', 'none');
  5087. })
  5088. );
  5089.  
  5090. $('#marquee').html(span);
  5091. setTimeout(buildMarquee, refreshMarquee(new Date().getHours(), new Date().getMinutes()));
  5092. });
  5093. });
  5094. }
  5095.  
  5096. $('.top-nav').append(
  5097. $('<li>').addClass('pull-left').css({
  5098. width: '40%',
  5099. padding: '0',
  5100. display: 'table',
  5101. lineHeight: '14px'
  5102. }).append(
  5103. $('<div>').attr('id', 'marquee').css({
  5104. display: 'table-cell',
  5105. verticalAlign: 'middle'
  5106. }),
  5107. $('<div>').attr('id', 'hiddenbox').addClass('marqueebox')
  5108. )
  5109. );
  5110.  
  5111. buildMarquee();
  5112.  
  5113. var city = getPow('bninfo', 2, -1);
  5114. if (city > 0) {
  5115. city = cities[city - 4];
  5116. $('#' + city).css('font-style', 'italic');
  5117. }
  5118. });
  5119.  
  5120. function GetPrefPage() {
  5121. // set location.hash so other code doesn't get triggered
  5122. // window.location.hash = 'OB_preferences';
  5123. // ^ gonna comment this out for a quick .dm patch for new layout
  5124.  
  5125. var setGroupPriority = function () {
  5126. setA('sets', $(this).attr('id'), $(this).val());
  5127. };
  5128.  
  5129. var jailHL = (prefs['jailHL'] ? true : false);
  5130. var jailHL_sel = sets['jailHL_sel'] || 'highest';
  5131. var jailHL_other = sets['jailHL_other'] || 9;
  5132. var jailHL_friends = sets['jailHL_friends'] || 5;
  5133. var jailHL_own_lackey = sets['jailHL_own_lackey'] || 7;
  5134. var jailHL_fr_lackey = sets['jailHL_fr_lackey'] || 8;
  5135. var jailHL_other_lackey = sets['jailHL_other_lackey'] || 11;
  5136. var autoCloseNotificationsSecs = sets['autoCloseNotificationsSecs'] || 0;
  5137. var bo_hotkey = sets['bo_hotkey'] || '/';
  5138. var custom_groups = getV('custom_groups', '').split('|');
  5139. custom_groups.pop();
  5140. var nobust = getV('nobust', '').split(',');
  5141. var af_position = sets['af_position'] || 'floating';
  5142. setA('prefs', 'NR', 1);
  5143.  
  5144. // Build custom groups priority settings
  5145. var c_group_div = null;
  5146. for (var i = 0; i < custom_groups.length; i++) {
  5147. var group_name = custom_groups[i].split(':')[0];
  5148. var group_prio = sets['jailHL_' + group_name] || (i + 12);
  5149. var group_lackey_prio = sets['jailHL_' + group_name + '_lackey'] || (i + 13);
  5150. var jailTr = [
  5151. $('<tr>').append(
  5152. $('<td>').text(group_name),
  5153. $('<td>').append(
  5154. $('<input>').attr({
  5155. id: 'jailHL_' + group_name,
  5156. type: 'text',
  5157. value: group_prio
  5158. }).blur(setGroupPriority)
  5159. )
  5160. ),
  5161. $('<tr>').append(
  5162. $('<td>').text(group_name + ' lackeys'),
  5163. $('<td>').append(
  5164. $('<input>').attr({
  5165. id: 'jailHL_' + group_name + '_lackey',
  5166. type: 'text',
  5167. value: group_lackey_prio
  5168. }).blur(setGroupPriority)
  5169. )
  5170. )
  5171. ];
  5172. if (c_group_div === null) {
  5173. c_group_div = jailTr;
  5174. } else {
  5175. c_group_div = c_group_div.concat(jailTr);
  5176. }
  5177. }
  5178.  
  5179. function deleteNoBustEntry() {
  5180. var entrySpan = $(this).prev();
  5181. var index = nobust.indexOf(entrySpan.attr('id'));
  5182. nobust.splice(index, 1);
  5183. entrySpan.hide();
  5184. $(this).hide();
  5185. setV('nobust', nobust);
  5186. }
  5187. // Build no bust list
  5188. var nobust_div = $('<div>').attr('id', 'nobust');
  5189. for (var i = 0; i < nobust.length; i++) {
  5190. if (nobust[i].length > 0) {
  5191. nobust_div.append(
  5192. $('<span>').attr({id: nobust[i]}).text(nobust[i]),
  5193. $('<img />').addClass('inboxImg').attr({
  5194. src: assetUrl('/images/delete.png'),
  5195. title: 'Delete'
  5196. }).click(deleteNoBustEntry),
  5197. $('<br>')
  5198. );
  5199. }
  5200. }
  5201. nobust_div.append(
  5202. $('<input>').attr({
  5203. id: 'new_nobust',
  5204. type: 'text'
  5205. }),
  5206. $('<button>').text('Add').click(function() {
  5207. // let's not add empty entries
  5208. var newVal = $('#new_nobust').val();
  5209. if (newVal.length > 0) {
  5210. $('<span>').attr({id: newVal}).text(newVal).insertBefore($('#new_nobust'));
  5211. $('<img />').addClass('inboxImg').attr({
  5212. src: assetUrl('/images/delete.png'),
  5213. title: 'Delete'
  5214. }).click(deleteNoBustEntry).insertBefore($('#new_nobust'));
  5215. $('<br>').insertBefore($('#new_nobust'));
  5216. nobust.push(newVal);
  5217. setV('nobust', nobust);
  5218. $('#new_nobust').val('');
  5219. }
  5220. })
  5221. );
  5222.  
  5223. var getNotificationItem = function(name, label) {
  5224. return $('<tr>').append(
  5225. $('<td>').text(label),
  5226. $('<td>').css('text-align', 'center').append(
  5227. $('<input>').attr({
  5228. type: 'checkbox',
  5229. checked: prefs[name] ? true : false
  5230. }).click(function () {
  5231. setA('prefs', name, $(this).prop('checked'));
  5232. })
  5233. ),
  5234. $('<td>').css('text-align', 'center').append(
  5235. $('<input>').attr({
  5236. type: 'checkbox',
  5237. checked: prefs[name + '_sound'] ? true : false
  5238. }).click(function () {
  5239. setA('prefs', name + '_sound', $(this).prop('checked'));
  5240. })
  5241. )
  5242. );
  5243. };
  5244.  
  5245. var notificationOptions = [
  5246. { name: 'bmsgDeaths', label: 'Deaths' },
  5247. { name: 'bmsgNews', label: 'News' },
  5248. { name: 'notify_bn', label: 'B/N prices changes'},
  5249. { name: 'notify_crime', label: 'Crime' },
  5250. { name: 'notify_gta', label: 'Nick a car' },
  5251. { name: 'notify_heist', label: 'Heist' },
  5252. { name: 'notify_oc', label: 'OC' },
  5253. { name: 'notify_moc', label: 'Mega OC' },
  5254. { name: 'notify_raid', label: 'Spot raid' },
  5255. { name: 'notify_race', label: 'Car race' },
  5256. { name: 'notify_travel', label: 'Travel' },
  5257. { name: 'notify_bullets', label: 'Buy bullets' },
  5258. { name: 'notify_health', label: 'When losing health' },
  5259. { name: 'notify_kill', label: 'When you can kill' },
  5260. { name: 'notify_blood', label: 'When you can buy blood' },
  5261. { name: 'notify_messages', label: 'Receive new message' },
  5262. { name: 'notify_alerts', label: 'New alerts' },
  5263. { name: 'notify_bg', label: 'Train BG' },
  5264. { name: 'notify_highlight', label: 'Name mentioned in chat' }
  5265. ];
  5266.  
  5267. var notificationMarkup = $('<table>').addClass('thinline').attr({ cellspacing: 0, cellpading: 2, width: '100%' }).append(
  5268. $('<tr>').append(
  5269. $('<td>').addClass('tableitem').attr('align', 'center').append(
  5270. $('<b>').text('Event')
  5271. ),
  5272. $('<td>').addClass('tableitem').attr('align', 'center').append(
  5273. $('<b>').text('Notification')
  5274. ),
  5275. $('<td>').addClass('tableitem').attr('align', 'center').append(
  5276. $('<b>').text('Sound')
  5277. )
  5278. ),
  5279. notificationOptions.map(function(element) {
  5280. return getNotificationItem(element.name, element.label);
  5281. })
  5282. );
  5283.  
  5284. var prefs_page = $('<center>').attr({
  5285. id: 'prefsContainer'
  5286. }).append(
  5287. $('<table>').addClass('thinline').attr({ cellspacing: 0, cellpading: 2, width: '90%' }).append(
  5288. $('<tr>').append(
  5289. $('<td>').addClass('tableheader').attr('align', 'center').css('text-align', 'center').append(
  5290. $('<span>').css('font-weight', 'bold').text('OmertaBeyond Preferences')
  5291. )
  5292. ),
  5293. $('<tr>').append(
  5294. $('<td>').attr({ height: '1', bgcolor: 'black' })
  5295. ),
  5296. $('<tr>').append(
  5297. $('<td>').addClass('tableitem').attr('align', 'center').css('text-align', 'center').css('font-weight', 'normal').text('Version ' + OB_VERSION)
  5298. ),
  5299. $('<tr>').append(
  5300. $('<td>').attr({ height: '1', bgcolor: 'black' })
  5301. ),
  5302. $('<tr>').append(
  5303. $('<td>').addClass('tableitem').attr('align', 'center').css('text-align', 'center').text('Notifications')
  5304. ),
  5305. $('<tr>').append(
  5306. $('<td>').attr({ height: '1', bgcolor: 'black' })
  5307. ),
  5308. $('<tr>').append(
  5309. $('<td>').attr('align', 'center').css('text-align', 'center').text('OmertaBeyond can send you desktop notifications or play a sound for events like deaths or news posts.').append(
  5310. $('<br>'),
  5311. $('<div>').attr('id', 'Authmsg'),
  5312. $('<button id="btnNotification">').text('Authorize for notifications').click(function () {
  5313. if ('Notification' in window) {
  5314. Notification.requestPermission(function (perm) {
  5315. $('#Authmsg').text('Authorization for notification is: ' + perm);
  5316. });
  5317. }
  5318. }),
  5319. $('<br>'),
  5320. $('<label>').attr('for', 'autoCloseNotificationsSecs').text('Show notifications for X seconds (0 = always show)'),
  5321. $('<input>').attr({
  5322. id: 'autoCloseNotificationsSecs',
  5323. type: 'text',
  5324. value: autoCloseNotificationsSecs
  5325. }).blur(function() {
  5326. setA('sets', 'autoCloseNotificationsSecs', $('#autoCloseNotificationsSecs').val());
  5327. }),
  5328. $('<br>'),
  5329. $('<input>').attr({
  5330. id: 'use_tts',
  5331. type: 'checkbox',
  5332. checked: prefs['use_tts'] ? true : false
  5333. }).click(function () {
  5334. setA('prefs', 'use_tts', $(this).prop('checked'));
  5335. }),
  5336. $('<label>').attr('for', 'use_tts').text('Enable Text-to-Speech'),
  5337. $('<br>'),
  5338. $('<div>').addClass('notify').append(
  5339. notificationMarkup
  5340. )
  5341. )
  5342. ),
  5343. $('<tr>').append(
  5344. $('<td>').attr({ height: '1', bgcolor: 'black' })
  5345. ),
  5346. $('<tr>').append(
  5347. $('<td>').addClass('tableitem').attr('align', 'center').css('text-align', 'center').text('Bust Priorities')
  5348. ),
  5349. $('<tr>').append(
  5350. $('<td>').attr({ height: '1', bgcolor: 'black' })
  5351. ),
  5352. $('<tr>').append(
  5353. $('<td>').attr('align', 'center').css('text-align', 'center').text(
  5354. 'Here you can choose which groups you want to bust before others.'
  5355. ).append(
  5356. $('<br>'),
  5357. $('<input>').attr({
  5358. id: 'jailHL',
  5359. type: 'checkbox',
  5360. checked: jailHL
  5361. }).click(function () {
  5362. setA('prefs', 'jailHL', $('#jailHL:checked').length);
  5363. }),
  5364. $('<label>').attr('for', 'jailHL').text('Enable Bust Priorities'),
  5365. $('<br>'),
  5366. $('<span>').css('font-style', 'italic').text('Lower value means higher priority'),
  5367. $('<table>').css('text-align', 'left').css('margin-left', '30%').append(
  5368. $('<tr>').append(
  5369. $('<td>').text('Other'),
  5370. $('<td>').append(
  5371. $('<input>').attr({
  5372. id: 'jailHL_other',
  5373. type: 'text',
  5374. value: jailHL_other
  5375. }).blur(function () {
  5376. setA('sets', 'jailHL_other', $('#jailHL_other').val());
  5377. })
  5378. )
  5379. ),
  5380. $('<tr>').append(
  5381. $('<td>').text('Friends and Family'),
  5382. $('<td>').append(
  5383. $('<input>').attr({
  5384. id: 'jailHL_friends',
  5385. type: 'text',
  5386. value: jailHL_friends
  5387. }).blur(function () {
  5388. setA('sets', 'jailHL_friends', $('#jailHL_friends').val());
  5389. })
  5390. )
  5391. ),
  5392. $('<tr>').append(
  5393. $('<td>').text('Own lackeys'),
  5394. $('<td>').append(
  5395. $('<input>').attr({
  5396. id: 'jailHL_own_lackey',
  5397. type: 'text',
  5398. value: jailHL_own_lackey
  5399. }).blur(function () {
  5400. setA('sets', 'jailHL_own_lackey', $('#jailHL_own_lackey').val());
  5401. })
  5402. )
  5403. ),
  5404. $('<tr>').append(
  5405. $('<td>').text('Friend/Family lackeys'),
  5406. $('<td>').append(
  5407. $('<input>').attr({
  5408. id: 'jailHL_fr_lackey',
  5409. type: 'text',
  5410. value: jailHL_fr_lackey
  5411. }).blur(function () {
  5412. setA('sets', 'jailHL_fr_lackey', $('#jailHL_fr_lackey').val());
  5413. })
  5414. )
  5415. ),
  5416. $('<tr>').append(
  5417. $('<td>').text('Other lackeys'),
  5418. $('<td>').append(
  5419. $('<input>').attr({
  5420. id: 'jailHL_other_lackey',
  5421. type: 'text',
  5422. value: jailHL_other_lackey
  5423. }).blur(function () {
  5424. setA('sets', 'jailHL_other_lackey', $('#jailHL_other_lackey').val());
  5425. })
  5426. )
  5427. ),
  5428. c_group_div,
  5429. $('<tr>').append(
  5430. $('<td>')
  5431. ),
  5432. $('<tr>').append(
  5433. $('<td>').text('Buyout hotkey'),
  5434. $('<td>').append(
  5435. $('<input>').attr({
  5436. id: 'bo_hotkey',
  5437. type: 'text',
  5438. value: bo_hotkey
  5439. }).blur(function () {
  5440. setA('sets', 'bo_hotkey', $('#bo_hotkey').val());
  5441. $('.ob_hotkey_pref').text($('#bo_hotkey').val());
  5442. })
  5443. )
  5444. )
  5445. ),
  5446. $('<p>').html('Depending on browser and operating system, you can use either Alt + Shift + <span class="ob_hotkey_pref">' + bo_hotkey + '</span>, Alt + <span class="ob_hotkey_pref">' + bo_hotkey + '</span> or Ctrl + Alt + <span class="ob_hotkey_pref">' + bo_hotkey + '</span> to buy yourself out.'),
  5447. $('<span>').text('Do you want to choose players with highest/lowest remaining jailtime first, or pick one randomly?'),
  5448. $('<br>'),
  5449. $('<div>').addClass('notify').append(
  5450. $('<input>').attr({
  5451. name: 'jailHL_sel',
  5452. id: 'jailHL_high',
  5453. type: 'radio',
  5454. checked: (jailHL_sel == 'highest' ? true : false)
  5455. }).click(function () {
  5456. setA('sets', 'jailHL_sel', 'highest');
  5457. }),
  5458. $('<span>').append(
  5459. $('<label>').attr('for', 'jailHL_high').text('highest')
  5460. ),
  5461. $('<br>'),
  5462. $('<input>').attr({
  5463. name: 'jailHL_sel',
  5464. id: 'jailHL_low',
  5465. type: 'radio',
  5466. checked: (jailHL_sel == 'lowest' ? true : false)
  5467. }).click(function () {
  5468. setA('sets', 'jailHL_sel', 'lowest');
  5469. }),
  5470. $('<span>').append(
  5471. $('<label>').attr('for', 'jailHL_low').text('lowest')
  5472. ),
  5473. $('<br>'),
  5474. $('<input>').attr({
  5475. name: 'jailHL_sel',
  5476. id: 'jailHL_rand',
  5477. type: 'radio',
  5478. checked: (jailHL_sel == 'random' ? true : false)
  5479. }).click(function () {
  5480. setA('sets', 'jailHL_sel', 'random');
  5481. }),
  5482. $('<span>').append(
  5483. $('<label>').attr('for', 'jailHL_rand').text('random')
  5484. )
  5485. )
  5486. )
  5487. ),
  5488. $('<tr>').append(
  5489. $('<td>').attr({ height: '1', bgcolor: 'black' })
  5490. ),
  5491. $('<tr>').append(
  5492. $('<td>').addClass('tableitem').attr('align', 'center').css('text-align', 'center').text('Scumbag List')
  5493. ),
  5494. $('<tr>').append(
  5495. $('<td>').attr({ height: '1', bgcolor: 'black' })
  5496. ),
  5497. $('<tr>').append(
  5498. $('<td>').attr('align', 'center').css('text-align', 'center').text(
  5499. 'There is this one scumbag you wouldn\'t want to bust even if their life depended on it? Just add them here!'
  5500. ).append(
  5501. $('<br>'),
  5502. nobust_div,
  5503. $('<span>').text('You can add family names too, by the way.')
  5504. )
  5505. ),
  5506. $('<tr>').append(
  5507. $('<td>').attr({ height: '1', bgcolor: 'black' })
  5508. ),
  5509. $('<tr>').append(
  5510. $('<td>').addClass('tableitem').attr('align', 'center').css('text-align', 'center').text('Best Run Calculator - Autofiller')
  5511. ),
  5512. $('<tr>').append(
  5513. $('<td>').attr({ height: '1', bgcolor: 'black' })
  5514. ),
  5515. $('<tr>').append(
  5516. $('<td>').attr('align', 'center').css('text-align', 'center').text(
  5517. 'Settings for the Best Run Calculator are visible on the Smuggling page'
  5518. ).append(
  5519. $('<br>'),
  5520. $('<br>'),
  5521. $('<span>').text('You can choose between a movable window or showing the options on top of the page.'),
  5522. $('<br>'),
  5523. $('<div>').addClass('notify').append(
  5524. $('<input>').attr({
  5525. type: 'radio',
  5526. id: 'AF_Floating',
  5527. name: 'AF_Position',
  5528. checked: af_position == 'floating'
  5529. }).click(function() {
  5530. setA('sets', 'af_position', 'floating');
  5531. }),
  5532. $('<label>').attr({ for: 'AF_Floating' }).text('Show settings in movable window'),
  5533. $('<br>'),
  5534. $('<input>').attr({
  5535. type: 'radio',
  5536. id: 'AF_Static',
  5537. name: 'AF_Position',
  5538. checked: af_position == 'static'
  5539. }).click(function() {
  5540. setA('sets', 'af_position', 'static');
  5541. }),
  5542. $('<label>').attr({ for: 'AF_Static' }).text('Show settings on top of the page')
  5543. ),
  5544. $('<br>'),
  5545. $('<br>'),
  5546. $('<span>').text('If the movable window is gone, click here to reset its position.'),
  5547. $('<br>'),
  5548. $('<button>').text('Clear').click(function () {
  5549. if (confirm('Are you sure?')) {
  5550. setV('AFtop', '225');
  5551. setV('AFleft', '300');
  5552. }
  5553. })
  5554.  
  5555. )
  5556. ),
  5557. $('<tr>').append(
  5558. $('<td>').attr({ height: '1', bgcolor: 'black' })
  5559. ),
  5560. $('<tr>').append(
  5561. $('<td>').addClass('tableitem').attr('align', 'center').css('text-align', 'center').text('Reset data')
  5562. ),
  5563. $('<tr>').append(
  5564. $('<td>').attr({ height: '1', bgcolor: 'black' })
  5565. ),
  5566. $('<tr>').append(
  5567. $('<td>').attr('align', 'center').css('text-align', 'center').text(
  5568. 'Manually reset all saved OB data.'
  5569. ).append(
  5570. $('<br>'),
  5571. $('<span>').text('Click the button to clear all settings, WARNING this resets all OB data'),
  5572. $('<br>'),
  5573. $('<button>').text('Clear').click(function () {
  5574. if (confirm('Are you sure you want to clear ALL OB data?')) {
  5575. clearUserData();
  5576. alert('Please reload Omerta for the changes to take effect.');
  5577. }
  5578. })
  5579. )
  5580. ),
  5581. $('<tr>').append(
  5582. $('<td>').attr({ height: '1', bgcolor: 'black' })
  5583. ),
  5584. $('<tr>').append(
  5585. $('<td>').addClass('tableitem').attr('align', 'center').css('text-align', 'center').text('Report a Bug')
  5586. ),
  5587. $('<tr>').append(
  5588. $('<td>').attr({ height: '1', bgcolor: 'black' })
  5589. ),
  5590. $('<tr>').append(
  5591. $('<td>').attr('align', 'center').css('text-align', 'center').text(
  5592. 'Please report any bugs you might encounter on IRC in #beyond or post a comment '
  5593. ).append(
  5594. $('<a>').text('here.').css('text-decoration', 'underline').click(function() {
  5595. window.open('https://omertabeyond.net/');
  5596. }),
  5597. $('<br>'),
  5598. $('<span>').html('To help us track down the issue, please include the following code:'),
  5599. $('<br>'),
  5600. $('<strong>').text(localStorage.getItem('ob_uid'))
  5601. )
  5602. )
  5603. )
  5604. ); // here we can build prefs page
  5605.  
  5606. if (!('Notification' in window)) {
  5607. $('#Authmsg', prefs_page).text('Your browser doesn\'t support notifications');
  5608. $('#btnNotification', prefs_page).remove();
  5609. } else if (Notification.permission == 'granted') {
  5610. $('#Authmsg', prefs_page).text('Authorization for notification is: ').append(
  5611. $('<span>').text('granted').css({
  5612. 'font-weight': 'bold'
  5613. })
  5614. );
  5615. $('#btnNotification', prefs_page).remove();
  5616. }
  5617.  
  5618. return prefs_page;
  5619. }
  5620.  
  5621. /*
  5622. * Info grabber
  5623. */
  5624.  
  5625. var infoD = new Date(); // check once every hour for new info
  5626. if (typeof unsafeWindow.omerta !== 'undefined' && (getV('bninfo', -1) == -1 || getV('brcDate', -1) != infoD.getHours())) {
  5627. // Update shizzle
  5628. bnUpdate();
  5629. var nick = unsafeWindow.omerta.character.info.name();
  5630. $.get('//' + document.location.hostname + '/user.php?nick=' + nick, function (data) {
  5631. var a = data.split('<script');
  5632. $('#game_wrapper').append(
  5633. $('<div>').css('display', 'none').attr('id', 'xhr').html(a[0])
  5634. );
  5635. if ($('#xhr').length) {
  5636. var role = 1; // default is in a family
  5637. var pos = $('span#position').attr('value');
  5638. var fam = ($('span#family > a').length ? $('span#family > a').text() : $('span#family').text());
  5639. var hascapo = ($('span#capo').length) ? 1 : 0;
  5640. if (/None|Geen/.test(fam)) {
  5641. role = 0;
  5642. } else {
  5643. if (/Capo (of|van):/.test(pos)) {
  5644. role = 2;
  5645. }
  5646. if (/(Sottocapo|Consiglieri|Don) (of|van):/.test(pos)) {
  5647. role = 3;
  5648. }
  5649. if (hascapo) {
  5650. role = 4;
  5651. }
  5652. }
  5653. setV('family', fam);
  5654. setPow('bninfo', 4, role); // save
  5655. }
  5656. setV('brcDate', infoD.getHours());
  5657. $('#xhr').remove();
  5658. $('#str2dom').remove();
  5659. });
  5660. }
  5661.  
  5662. // Reset on death
  5663. if (window.location.search.indexOf('action=omertician') != -1 || (window.location.search.indexOf('module=Account') != -1 && $('#table_accounts button[onclick*="module=Account&action=open"]').length === 0 && $('#loginbox').length === 0 && $('input:first').attr('disabled') !== 'disabled')) {
  5664. if (confirm('Do you want to reset all OB data?')) {
  5665. clearUserData();
  5666. }
  5667. }
  5668.  
  5669. // Add focus on front page
  5670. $('input[name="email"]').focus();
  5671.  
  5672. // Replace Omerta's favicon
  5673. $('<link rel="shortcut icon" type="image/x-icon"/>').appendTo('head').attr('href', assetUrl('/images/favicon.png'));
  5674.  
  5675. /*
  5676. * Logos replacing
  5677. */
  5678.  
  5679. // Main logo in the game
  5680. $('#game_header_left').children('img').attr('src', assetUrl('/images/logo.png'));
  5681. if (v === 'dm') {
  5682. $('#omerta_header #logo').css({
  5683. 'background-image': 'url(' + assetUrl('/images/logo.png') + ')',
  5684. top: '2px',
  5685. left: '0px',
  5686. width: '549px',
  5687. height: '104px'
  5688. });
  5689. }
  5690. // Logo on homepage
  5691. $('img[src*="omerta-game-logo.gif"]').attr('src', assetUrl('/images/logo-old.png'));
  5692. $('img[src*="pic_bg-logo.png"]').attr('src', assetUrl('/images/logo-old.png'));
  5693. // Logo on /servers.php
  5694. $('img[src*="logo0.gif"]').attr('src', assetUrl('/images/logo-old.png'));
  5695.  
  5696. $.get(assetUrl('/scripts/beyond.css'), function(data) {
  5697. $('head').append('<style type="text/css">' + data + '</style>');
  5698. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement