Advertisement
Guest User

Untitled

a guest
Jun 7th, 2018
419
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 197.80 KB | None | 0 0
  1. /*
  2. * Copyright (c) 2007-2018 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.4
  23. // @date 24-05-2018
  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 GPL-3.0
  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.7/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.4';
  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. $('<p>').html('By using OmertaBeyond you agree to our <a target="_blank" href="https://news.omertabeyond.net/terms">Terms of Service</a> and <a target="_blank" href="https://news.omertabeyond.net/privacy">Privacy Policy</a>.')
  1140. )
  1141. );
  1142.  
  1143. $('#ob_updated_dialog').dialog({
  1144. resizable: false,
  1145. height: 'auto',
  1146. width: 480,
  1147. modal: true,
  1148. buttons: {
  1149. Close: function() {
  1150. $(this).dialog('close');
  1151. }
  1152. }
  1153. });
  1154. localStorage.setItem('ob_last_version', OB_VERSION);
  1155. });
  1156. }
  1157.  
  1158. /*
  1159. * for maximum forwards-compatibility, trigger the beacon code on either the
  1160. * main container being present, or the "omerta" variable being set
  1161. */
  1162. if (document.getElementById('game_container') !== null || typeof unsafeWindow.omerta !== 'undefined') {
  1163. sendBeacon();
  1164. showReleaseNotes();
  1165. }
  1166.  
  1167. /*
  1168. * Main game listener
  1169. */
  1170.  
  1171. if (document.getElementById('game_container') !== null) {
  1172. var mutationObserver = window.MutationObserver || window.WebKitMutationObserver || window.MozMutationObserver;
  1173.  
  1174. if (mutationObserver) {
  1175. var observer = new MutationObserver(function(mutations) {
  1176. mutations.forEach(function(mutation) {
  1177. for (var i = 0; i < mutation.addedNodes.length; i++) {
  1178. var node = mutation.addedNodes[i];
  1179. if (node.nodeType == 1 && !node.hasAttribute('data-beyond-fired')) {
  1180. node.setAttribute('data-beyond-fired', true);
  1181. gameContainerChanged(node);
  1182. }
  1183. }
  1184. });
  1185. });
  1186.  
  1187. observer.observe(document.getElementById('game_container'), {
  1188. attributes: false,
  1189. childList: true,
  1190. characterData: false
  1191. });
  1192. } else {
  1193. // jeez, get a new browser ;(
  1194. // falling back to DOMNodeInserted event
  1195. document.getElementById('game_container').addEventListener('DOMNodeInserted', function(event) {
  1196. if (event.target.nodeType != 1) {
  1197. return false;
  1198. }
  1199.  
  1200. if ($(event.target).attr('data-beyond-fired') !== undefined) {
  1201. return false;
  1202. }
  1203.  
  1204. if ($(event.target).attr('id') == 'recaptcha-popup') {
  1205. return false;
  1206. }
  1207.  
  1208. $(event.target).attr('data-beyond-fired', 'true');
  1209. gameContainerChanged(event.target);
  1210. }, true);
  1211. }
  1212.  
  1213. var gameContainerChanged = function(node) {
  1214. var nn = node.tagName.toLowerCase();
  1215. var nid = node.getAttribute('id');
  1216. var nclass = node.className;
  1217. var wlh = window.location.hash;
  1218.  
  1219. $(node).find('img').each(function() {
  1220. proxyImage(this);
  1221. });
  1222.  
  1223. // unbind events
  1224. if (!on_page('garage.php') && !on_page('module=Cars')) {
  1225. $(window).unbind('scroll');
  1226. $('#game_wrapper_container div#footer').remove();
  1227. }
  1228. if (!on_page('action=showMsg')) {
  1229. $(window).unbind('keydown');
  1230. }
  1231. // Disable nickreader when going to other page
  1232. if ($('#shft').length > 0) {
  1233. $('#shft').remove();
  1234. }
  1235. if ($('#proc').length > 0) {
  1236. $('#proc').remove();
  1237. }
  1238. if ($('.NRinfo').length > 0) {
  1239. $('.NRinfo').remove();
  1240. }
  1241. if ($('#NRstatus').length > 0) {
  1242. $('#NRstatus').remove();
  1243. }
  1244.  
  1245. // hitting the click limit means the page won't contain what we expect. ignore it.
  1246. if ($(node).filter(':contains("You reached your click limit."), :contains("Je hebt jouw kliklimiet bereikt.")').length > 0) {
  1247. return;
  1248. }
  1249.  
  1250. // autofocus on long pages with button at the bottom causes annoying scroll
  1251. var isAutofocusBlacklist = on_page('module=Mail') || on_page('forums');
  1252. if (!isAutofocusBlacklist && $('input[type=submit]').length == 1) {
  1253. $('input[type=submit]').focus();
  1254. }
  1255.  
  1256. if (on_page('jail.php')) {
  1257. if ($('#game_container form').length == 2) {
  1258. // self-bust page - focus on bustout button
  1259. $('input[type=submit]:eq(1)').focus();
  1260. } else {
  1261. // regular jail page, focus on top bustout button
  1262. $('input[type=submit]:first').focus();
  1263. }
  1264. }
  1265.  
  1266. /*
  1267. * add end time tooltip to every countdown
  1268. * causes issues with Greasemonkey 2+, disabling till issue is fixed
  1269. * addEndTimeTooltip(node);
  1270. */
  1271.  
  1272. // ---------------- FAMILY PAGE ----------------
  1273. if (on_page('family.php') && nn == 'center') {
  1274. nickReader();
  1275. // add HR, Deaths and Worth
  1276. var famid = wlh.split('=')[1];
  1277. var famIdFromImg = $('img[src*="family_image.php"]:last').attr('src').match(/\d+/g)[0];
  1278. var famname = $('td.profilerow').text().trim().split(' ')[0].trim().toLowerCase();
  1279. var url = (famid === famIdFromImg) ? 'id=' + famid : 'ing=' + famname;
  1280. var ownfam = getV('family', '');
  1281.  
  1282. // Count rows
  1283. var tr = $('table.thinline:eq(0) tr').length;
  1284.  
  1285. // add HQ space to members
  1286. var hq = $('table.thinline:eq(0) tr:eq(' + (tr - 3) + ') td:last').text();
  1287. var members = $('table.thinline:eq(0) tr:eq(' + (tr - 5) + ') td:last').text();
  1288. $('table.thinline:eq(0) tr:eq(' + (tr - 5) + ') td:last').text(members + '/' + hq);
  1289.  
  1290. // add color to HQ space
  1291. var hqperc = ((members / hq) * 100);
  1292. $('table.thinline:eq(0) tr:eq(' + (tr - 5) + ') td:last').css({
  1293. background: 'linear-gradient(to right, rgba(46, 188, 0, 1) ' + hqperc + '%, rgba(46, 188, 0, 0) ' + hqperc + '%)'
  1294. });
  1295.  
  1296. // add color to donating %
  1297. var doperc = $('table.thinline:eq(0) tr:eq(' + (tr - 4) + ') td:last').text().split(' (')[0].trim();
  1298. $('table.thinline:eq(0) tr:eq(' + (tr - 4) + ') td:last').css({
  1299. background: 'linear-gradient(to right, rgba(46, 188, 0, 1) ' + doperc + ', rgba(46, 188, 0, 0) ' + doperc + ')'
  1300. });
  1301.  
  1302. // add color to rank progress
  1303. if (famname == ownfam.toLowerCase()) {
  1304. var rankperc = $('table.thinline:eq(0) tr:last td:last').text().split(' (')[1].replace(')', '').trim();
  1305. $('table.thinline:eq(0) tr:last td:last').css({
  1306. background: 'linear-gradient(to right, rgba(46, 188, 0, 1) ' + rankperc + ', rgba(46, 188, 0, 0) ' + rankperc + ')'
  1307. });
  1308. }
  1309.  
  1310. // get tops
  1311. var tops = [];
  1312. $('table.thinline:eq(0) > tbody > tr > td:has(a)').each(function () {
  1313. tops.push($(this).text().trim());
  1314. });
  1315.  
  1316. var nTop = tops.length; // # tops
  1317. var SorC = (nTop == 3) ? 2 : /Consi/.test($('table.thinline:eq(0) tr:eq(7) td:first').text()); // Sotto or Consi
  1318. var don = tops[0];
  1319. var sotto = (nTop > 1 && (nTop == 3 || SorC === false)) ? tops.pop() : null;
  1320. var cons = (nTop > 1 && (nTop == 3 || SorC === true)) ? tops.pop() : null;
  1321.  
  1322. // get capos
  1323. var capos = [];
  1324. $('table.thinline:last > tbody > tr > td > a.tableheader').each(function () {
  1325. capos.push($(this).text());
  1326. });
  1327.  
  1328. // get object owners
  1329. var objects = [];
  1330. $('table.thinline:eq(2) > tbody > tr > td:has(a)').each(function () {
  1331. objects.push($(this).text());
  1332. });
  1333.  
  1334. $('#game_container a[href*="user.php"]').each(function () {
  1335. var n = $(this).text(); // nick
  1336. var vip = '';
  1337. if (n == don) {
  1338. $(this).html(n + '<small><sup>[D]</sup></small>');
  1339. vip = '[D]';
  1340. }
  1341. if (n == sotto) {
  1342. $(this).html(n + '<small><sup>[S]</sup></small>');
  1343. vip = '[S]';
  1344. }
  1345. if (n == cons) {
  1346. $(this).html(n + '<small><sup>[C]</sup></small>');
  1347. vip = '[C]';
  1348. }
  1349. if ($.inArray(n, capos) != -1) {
  1350. if (n != don) {
  1351. $(this).html(n + '<small><sup>' + vip + '(c)</sup></small>');
  1352. vip = vip + '(c)';
  1353. }
  1354. }
  1355. if ($.inArray(n, objects) != -1) {
  1356. if (n != don) {
  1357. $(this).html(n + '<small><sup>' + vip + '(o)</sup></small>');
  1358. vip = vip + '(o)';
  1359. }
  1360. }
  1361. });
  1362.  
  1363. if (versionHasLogger) {
  1364. $.getJSON(OB_API_WEBSITE + '/?p=stats&w=fampage&v=' + v + '&' + url, function (data) {
  1365. // Family position and worth
  1366. $('td.subtableheader').first().closest('tr').after(
  1367. $('<tr>').append(
  1368. $('<td>').addClass('subtableheader').text('Position:'),
  1369. $('<td>').addClass('profilerow').text('#' + data['pos'] + ' - Worth: ' + data['worth'] + '')
  1370. )
  1371. );
  1372.  
  1373. // add HR
  1374. $('table.thinline').first().find('tbody').append(
  1375. $('<tr>').append(
  1376. $('<td>').addClass('subtableheader').text('Ranks:'),
  1377. $('<td>').addClass('profilerow').append(
  1378. $('<table>').attr('width', '100%').append(
  1379. $('<tr>').append($('<td>').text('Godfather/First Lady:'), $('<td>').addClass('bold').text(data['hr']['gf'])),
  1380. $('<tr>').append($('<td>').text('Capodecina:'), $('<td>').addClass('bold').text(data['hr']['cd'])),
  1381. $('<tr>').append($('<td>').text('Bruglione:'), $('<td>').addClass('bold').text(data['hr']['brug'])),
  1382. $('<tr>').append($('<td>').text('Chief:'), $('<td>').addClass('bold').text(data['hr']['chief'])),
  1383. $('<tr>').append($('<td>').text('Local Chief:'), $('<td>').addClass('bold').text(data['hr']['lc'])),
  1384. $('<tr>').append($('<td>').text('Assassin:'), $('<td>').addClass('bold').text(data['hr']['assa'])),
  1385. $('<tr>').append($('<td>').text('Swindler:'), $('<td>').addClass('bold').text(data['hr']['swin'])),
  1386. $('<tr>').append($('<td>').attr('colspan', '2').append($('<hr />'))),
  1387. $('<tr>').append($('<td>').text('Total points:'), $('<td>').addClass('bold').text(data['hr']['pts']))
  1388. )
  1389. )
  1390. )
  1391. );
  1392.  
  1393. setTimeout(function () {
  1394. // Family deaths
  1395. $('table.thinline:eq(1)').closest('td').append(
  1396. $('<br />'),
  1397. $('<table>').addClass('thinline').css('width', '100%').attr('cellspacing', '0').attr('cellpadding', '2').attr('rules', 'none').append(
  1398. $('<tr>').append(
  1399. $('<td>').addClass('tableheader').attr('colspan', '100%').text('Last family deaths')
  1400. ),
  1401. $('<tr>').append(
  1402. $('<td>').attr('colspan', '100%').attr('bgcolor', 'black').attr('height', '1')
  1403. ),
  1404. $('<tr>').append(
  1405. $('<td>').addClass('bold').css('width', '28%').attr('align', 'left').text('Name'),
  1406. $('<td>').addClass('bold').attr('align', 'center').text('Rank'),
  1407. $('<td>').addClass('bold').attr('align', 'center').text('Date'),
  1408. $('<td>').addClass('bold').css('text-align', 'right').text('Ago')
  1409. )
  1410. )
  1411. );
  1412. if (v === 'com') {
  1413. $('<div>').addClass('dlContainer').append(
  1414. $('<a>').attr({
  1415. href: OB_NEWS_WEBSITE + '/deathslog/latest/' + famid,
  1416. target: '_blank'
  1417. }).append(
  1418. $('<img>').addClass('brcImg').attr({
  1419. src: assetUrl('/images/changelog.png'),
  1420. title: 'View full deathslog'
  1421. })
  1422. )
  1423. ).appendTo($('table.thinline:eq(2)>tbody>tr:eq(0)>td'));
  1424. }
  1425.  
  1426. var deaths_body = $('table.thinline:eq(2)').find('tbody');
  1427. if (data['deaths']) {
  1428. $.each(data['deaths'], function (k, v) {
  1429. var extra = (v['Akill'] == 1) ? '(<b>A</b>) ' : (v['BF'] == 1) ? '(<b>BF</b>) ' : '';
  1430. deaths_body.append(
  1431. $('<tr>').append(
  1432. $('<td>').html(extra).append(
  1433. $('<a>').attr('href', 'user.php?name=' + v['Name']).text(v['Name'])
  1434. ),
  1435. $('<td>').attr('align', 'center').append(
  1436. $('<a>').attr('href', OB_API_WEBSITE + '/?p=history&v=' + v + '&name=' + v['Name']).text(v['Rank'])
  1437. ),
  1438. $('<td>').attr('align', 'center').text(v['Date']),
  1439. $('<td>').css('text-align', 'right').text(v['Agod'] + 'd ' + v['Agoh'] + 'h ' + v['Agom'] + 'm')
  1440. )
  1441. );
  1442. });
  1443. } else {
  1444. deaths_body.append(
  1445. $('<tr>').append(
  1446. $('<td>').addClass('red').css('text-align', 'center').attr('colspan', '4').text('There are no deaths yet!')
  1447. )
  1448. );
  1449. }
  1450.  
  1451. // add Famlog
  1452. $('table.thinline:eq(1)').closest('td').append(
  1453. $('<br />'),
  1454. $('<table>').addClass('thinline').css('width', '100%').attr('cellspacing', '0').attr('cellpadding', '2').attr('rules', 'none').append(
  1455. $('<tr>').append(
  1456. $('<td>').addClass('tableheader').attr('colspan', '100%').text('Last family changes')
  1457. ),
  1458. $('<tr>').append(
  1459. $('<td>').attr('colspan', '100%').attr('bgcolor', 'black').attr('height', '1')
  1460. ),
  1461. $('<tr>').append(
  1462. $('<td>').addClass('bold').css('width', '28%').attr('align', 'left').text('Date'),
  1463. $('<td>').addClass('bold').attr('align', 'left').text('Change')
  1464. )
  1465. )
  1466. );
  1467. if (v === 'com') {
  1468. $('<div>').addClass('dlContainer').append(
  1469. $('<a>').attr({
  1470. href: OB_NEWS_WEBSITE + '/famlog/latest/' + famid,
  1471. target: '_blank'
  1472. }).append(
  1473. $('<img>').addClass('brcImg').attr({
  1474. src: assetUrl('/images/changelog.png'),
  1475. title: 'View full changelog'
  1476. })
  1477. )
  1478. ).appendTo($('table.thinline:eq(3)>tbody>tr:eq(0)>td'));
  1479. }
  1480.  
  1481. var changes_body = $('table.thinline:eq(3)').find('tbody');
  1482. if (data['changes']) {
  1483. $.each(data['changes'], function (k, v) {
  1484. changes_body.append(
  1485. $('<tr>').append(
  1486. $('<td>').css('width', '28%').attr('align', 'left').attr('valign', 'top').text(v['date']),
  1487. $('<td>').attr('align', 'left').text(v['text'])
  1488. )
  1489. );
  1490. });
  1491. } else {
  1492. changes_body.append(
  1493. $('<tr>').append(
  1494. $('<td>').addClass('red').css('text-align', 'center').attr('colspan', '2').text('There are no changes yet!')
  1495. )
  1496. );
  1497. }
  1498. }, 0);
  1499. });
  1500. }
  1501. }
  1502. // ---------------- My account ----------------
  1503. if (on_page('/information.php') && nn == 'table') {
  1504. var interest = parseInt(getV('interest', 0), 10);
  1505. var banktleft = parseInt(getV('banktleft', 0), 10);
  1506. // Update info
  1507. bnUpdate();
  1508. // Grab busts for Jail page
  1509. var bos;
  1510. // Save Will
  1511. var timestamp = getV('willTimestamp');
  1512. var checkTimestamp = $.now() - (1000 * 30 * 60);
  1513. var willTR = $('.thinline:eq(0)>tbody>tr>td a[href^="/user.php?nick="]:eq(1)');
  1514. var willName = unsafeWindow.omerta.character.info.testament();
  1515. willName = willTR.text().replace(/,/g, '').trim();
  1516.  
  1517. var appendDead = function() {
  1518. willTR.append('<span class="red"> | Dead!</span>');
  1519. };
  1520.  
  1521. // Let's skip doing this if the will has not been set.
  1522. if (getV('willTimestamp', 0) <= checkTimestamp && willName != '') {
  1523. checkUserAlive(willName, function(isAlive) {
  1524. setV('willTimestamp', $.now());
  1525. if (!isAlive) {
  1526. setV('deadWillName', willName);
  1527. appendDead();
  1528. }
  1529. });
  1530. } else {
  1531. var deadWillName = getV('deadWillName');
  1532.  
  1533. // If the person in the will has been changed it shouldn't be shown anymore
  1534. if (willName != '' && deadWillName == willName) {
  1535. appendDead();
  1536. }
  1537. }
  1538.  
  1539. bos = $('.thinline:eq(5)>tbody>tr:eq(1)>td:last').text().replace(/,/g, '');
  1540. setV('bustouts', bos);
  1541.  
  1542. // Interest reminder
  1543. if (!$('#interestRow').length) {
  1544. var inbank = $('.thinline:eq(4)>tbody>tr:eq(2)>td:last>a').html().replace(/\D/g, '');
  1545. if (inbank > 0 && interest > 0) {
  1546. var timestamp = Math.round(parseInt(new Date().getTime(), 10) / 1000);
  1547. var left = (banktleft - timestamp);
  1548. var bankTr = $('<tr>').attr({id: 'interestRow'}).append(
  1549. $('<td>').html('<b>Interest</b>'),
  1550. $('<td>').html('<a href="/bank.php">$ ' + commafy(interest) + '</a> (<span data-timeleft="' + left + '">Now!</span>)')
  1551. );
  1552. $('.thinline:eq(4)').append(bankTr);
  1553. }
  1554. }
  1555.  
  1556. // Tell how old the account is
  1557. var startElem;
  1558. $('table.thinline:eq(0)>tbody>tr>td:nth-child(2)').each(function() {
  1559. if (/^(\d{2})-(\d{2})-(\d{4}) (\d{2}):(\d{2}):(\d{2})$/.test($(this).text())) {
  1560. startElem = $(this);
  1561. }
  1562. });
  1563. if (startElem !== null) {
  1564. var startDate = datestringParse(startElem.text());
  1565. var diff = Math.abs(Date.now() - startDate.getTime());
  1566. var diffDays = Math.ceil(diff / (1000 * 3600 * 24));
  1567. var startDay = startDate.getDate() >= 10 ? startDate.getDate() : '0' + startDate.getDate();
  1568. var startMonth = startDate.getMonth() + 1 >= 10 ? (startDate.getMonth() + 1) : '0' + (startDate.getMonth() + 1);
  1569. var previousText = startElem.text();
  1570. startElem.html(startDay + '-' + startMonth + '-' + startDate.getFullYear() + ' (' + (diffDays - 1) + ' days old)').click(function() {
  1571. var currentText = $(this).text();
  1572. $(this).text(previousText);
  1573. previousText = currentText;
  1574. });
  1575. }
  1576.  
  1577. // car
  1578. var carAttempts = parseInt($('table.thinline:eq(5)>tbody>tr:eq(3)>td:last').text().replace(',', ''), 10);
  1579. var successCars = parseInt(getV('carSuccess', 0), 10);
  1580. if (successCars >= 1) {
  1581. var successRate = (successCars / carAttempts) * 100;
  1582. var earned = getV('carMoney', 0);
  1583. var newText = '<tr><td><b>Car nicking success</b></td><td>' + successCars + ' (' + successRate.toFixed(2) + '%, $' + commafy(earned) + ')</td></tr>';
  1584. $('table.thinline:eq(5)>tbody>tr:eq(3)').after(newText);
  1585. }
  1586.  
  1587. // crime stats
  1588. var crimeAttempts = parseInt($('table.thinline:eq(5)>tbody>tr:eq(2)>td:last').text().replace(',', ''), 10);
  1589. var successCrimes = parseInt(getV('crimeSuccess', 0), 10);
  1590. if (successCrimes >= 1) {
  1591. var successRate = (successCrimes / crimeAttempts) * 100;
  1592. var earned = getV('crimeMoney', 0);
  1593. var newText = '<tr><td><b>Crime success</b></td><td>' + successCrimes + ' (' + successRate.toFixed(2) + '%, $' + commafy(earned) + ')</td></tr>';
  1594. $('table.thinline:eq(5)>tbody>tr:eq(2)').after(newText);
  1595. }
  1596.  
  1597. // Visual improvement
  1598.  
  1599. $('.thinline:eq(4)>tbody>tr:eq(2)>td:first').html('<a href="/bank.php"><b>In bank account</b></a>');
  1600.  
  1601. ScheduleNotification(
  1602. 'heist',
  1603. $('.thinline:eq(1)>tbody>tr:eq(3) [data-time-end]').attr('data-time-end'),
  1604. 'Heist (' + v + ')',
  1605. (v == 'nl' ? 'Je kunt weer heisten' : 'You can do a heist again'),
  1606. 'heist',
  1607. '/?module=Heist',
  1608. assetUrl('/images/red-star.png')
  1609. );
  1610.  
  1611. ScheduleNotification(
  1612. 'oc',
  1613. $('.thinline:eq(1)>tbody>tr:eq(4) [data-time-end]').attr('data-time-end'),
  1614. 'Organised Crime (' + v + ')',
  1615. (v == 'nl' ? 'Je kunt weer een georganiseerde misdaad doen' : 'You can do an organised crime again'),
  1616. 'oc',
  1617. '/?module=OC',
  1618. assetUrl('/images/red-star.png')
  1619. );
  1620.  
  1621. ScheduleNotification(
  1622. 'moc',
  1623. $('.thinline:eq(1)>tbody>tr:eq(5) [data-time-end]').attr('data-time-end'),
  1624. 'Mega Organised Crime (' + v + ')',
  1625. (v == 'nl' ? 'Je kunt weer een mega georganiseerde misdaad doen' : 'You can do a mega organised crime again'),
  1626. 'moc',
  1627. '/?module=MegaOC',
  1628. assetUrl('/images/red-star.png')
  1629. );
  1630.  
  1631. ScheduleNotification(
  1632. 'kill',
  1633. $('.thinline:eq(1)>tbody>tr:eq(8) [data-time-end]').attr('data-time-end'),
  1634. 'Next Kill (' + v + ')',
  1635. (v == 'nl' ? 'Je kunt weer een moordpoging doen' : 'You can make a kill attempt again'),
  1636. 'kill',
  1637. '/?module=Detectives',
  1638. assetUrl('/images/red-star.png')
  1639. );
  1640.  
  1641. ScheduleNotification(
  1642. 'race',
  1643. $('a[href="/races.php"] [data-time-end]').attr('data-time-end'),
  1644. 'Car Race (' + v + ')',
  1645. (v == 'nl' ? 'Je kunt weer racen' : 'You can race again'),
  1646. 'race',
  1647. '/races.php',
  1648. assetUrl('/images/red-star.png')
  1649. );
  1650.  
  1651. ScheduleNotification(
  1652. 'blood',
  1653. $('.thinline:eq(1)>tbody>tr:eq(10) [data-time-end]').attr('data-time-end'),
  1654. 'Blood Buy (' + v + ')',
  1655. (v == 'nl' ? 'Je kunt weer bloed kopen' : 'You can buy blood again'),
  1656. 'blood',
  1657. '/?module=Bloodbank',
  1658. assetUrl('/images/red-star.png')
  1659. );
  1660.  
  1661. ScheduleNotification(
  1662. 'raid',
  1663. $('.thinline:eq(1)>tbody>tr:eq(11) [data-time-end]').attr('data-time-end'),
  1664. 'Spot Raid (' + v + ')',
  1665. (v == 'nl' ? 'Je kunt weer een spot overvallen' : 'You can raid a spot again'),
  1666. 'raid',
  1667. '/?module=Spots',
  1668. assetUrl('/images/red-star.png')
  1669. );
  1670. }
  1671. // ---------------- NEW My account ----------------
  1672. if (on_page('module=UserInformation')) {
  1673. // Check for dead player in testament
  1674. var willTs = getV('willTimestamp', 0);
  1675. var checkWillTs = $.now() - (1000 * 10 * 60);
  1676. var willName = unsafeWindow.omerta.character.info.testament();
  1677. var willTr = $('div.gangster-info-body li:eq(2) a span');
  1678.  
  1679. if (willName !== '') {
  1680. if (willTs <= checkWillTs) {
  1681. checkUserAlive(willName, function(isAlive) {
  1682. setV('willTimestamp', $.now());
  1683. if (!isAlive) {
  1684. setV('deadWillName', willName);
  1685. willTr.append($('<span>').addClass('red').text(' | Dead!'));
  1686. }
  1687. });
  1688. } else {
  1689. var deadWillName = getV('deadWillName');
  1690. if (deadWillName == willName) {
  1691. willTr.append($('<span>').addClass('red').text(' | Dead!'));
  1692. }
  1693. }
  1694. }
  1695.  
  1696. // Tell how old the account is
  1697. var startElem = $('div.gangster-info-body li:eq(5) a span');
  1698. var startDate = unsafeWindow.omerta.character.info.startdate();
  1699. var diff = Math.abs(Date.now() - startDate.getTime());
  1700. var diffDays = Math.ceil(diff / (1000 * 3600 * 24));
  1701. var startDay = startDate.getDate() >= 10 ? startDate.getDate() : '0' + startDate.getDate();
  1702. var startMonth = startDate.getMonth() + 1 >= 10 ? (startDate.getMonth() + 1) : '0' + (startDate.getMonth() + 1);
  1703. var previousText = startElem.html();
  1704. startElem.html(startDay + '-' + startMonth + '-' + startDate.getFullYear() + ' (' + (diffDays - 1) + ' days old)').click(function() {
  1705. var currentText = $(this).html();
  1706. $(this).html(previousText);
  1707. previousText = currentText;
  1708. });
  1709. // Update info
  1710. setTimeout(function () {
  1711. bnUpdate();
  1712. }, 2000);
  1713. }
  1714. // -------------------- Jail --------------------
  1715. if (on_page('/jail.php') && nn == 'form' && prefs['jailHL']) {
  1716. if (getV('fam_colour', '') === '' || getV('friends_colour', '') === '') {
  1717. unsafeWindow.omerta.GUI.container.loadPage('/jail_settings.php');
  1718. }
  1719. var bos;
  1720. if (!unsafeWindow.omerta.modules.UserInformation.data.hasOwnProperty('actions_stats')) {
  1721. bos = parseInt(getV('bustouts', 0), 10);
  1722. } else {
  1723. bos = Math.max(parseInt(getV('bustouts', 0), 10), unsafeWindow.omerta.modules.UserInformation.data.actions_stats[0].value);
  1724. }
  1725. var jailHL_sel = sets['jailHL_sel'] || 'highest';
  1726. var jailHL_other = parseInt(sets['jailHL_other'] || 9, 10);
  1727. var jailHL_friends = parseInt(sets['jailHL_friends'] || 5, 10);
  1728. var jailHL_own_lackey = parseInt(sets['jailHL_own_lackey'] || 7, 10);
  1729. var jailHL_fr_lackey = parseInt(sets['jailHL_fr_lackey'] || 8, 10);
  1730. var jailHL_other_lackey = parseInt(sets['jailHL_other_lackey'] || 11, 10);
  1731.  
  1732. var rows = $('tr[bgcolor]').length;
  1733. var prior = null;
  1734. // list for inmates with lowest priority
  1735. var bustlist = [];
  1736. var priority;
  1737. // Build new row on top
  1738. $('#game_container > form > center > table.thinline > tbody').prepend($('<tr>').attr('id', 'HLrow').css('border-bottom', '1px solid #000'));
  1739. // Loop inmates
  1740. $('tr[bgcolor]').each(function () {
  1741. // Skip nobust
  1742. if (getV('nobust', 0)) {
  1743. var nobust = getV('nobust').toLowerCase().split(',');
  1744. var fam = $(this).find('td:eq(1) > font').text().toLowerCase();
  1745. var name = $(this).find('td:eq(0) > font > a > font').text().toLowerCase();
  1746. if ((fam.length > 0 && $.inArray(fam, nobust) != -1) || $.inArray(name, nobust) != -1) {
  1747. $(this).find('td').css('text-decoration', 'line-through');
  1748. $(this).attr('nobust', true);
  1749. return;
  1750. }
  1751. }
  1752. if ($(this).find('td:eq(0)>font>span').text() === '') {
  1753. // normal player
  1754. if ($(this).attr('bgcolor') !== '') {
  1755. // friends, family or custom group
  1756. if (getV('custom_groups', '').indexOf($(this).attr('bgcolor')) > 0) {
  1757. // custom group
  1758. var cg = getV('custom_groups', '').split('|');
  1759. cg.pop();
  1760. for (var i = 0; i < cg.length; i++) {
  1761. var g = cg[i].split(':');
  1762. if (g[1] == $(this).attr('bgcolor')) {
  1763. var cg_prio = parseInt(sets['jailHL_' + g[0]], 10);
  1764. priority = cg_prio;
  1765. if (!prior || priority <= prior) {
  1766. if (!prior || priority < prior) {
  1767. prior = priority;
  1768. bustlist = [];
  1769. }
  1770. bustlist.push($(this));
  1771. }
  1772. }
  1773. }
  1774. } else if ($(this).attr('bgcolor') == getV('fam_colour') || $(this).attr('bgcolor') == getV('friends_colour')) {
  1775. // friends or family
  1776. priority = jailHL_friends;
  1777. if (!prior || priority <= prior) {
  1778. if (!prior || priority < prior) {
  1779. prior = priority;
  1780. bustlist = [];
  1781. }
  1782. bustlist.push($(this));
  1783. }
  1784. }
  1785. } else {
  1786. // other
  1787. priority = jailHL_other;
  1788. if (!prior || priority <= prior) {
  1789. if (!prior || priority < prior) {
  1790. prior = priority;
  1791. bustlist = [];
  1792. }
  1793. bustlist.push($(this));
  1794. }
  1795. }
  1796. } else {
  1797. // lackey
  1798. if ($(this).attr('bgcolor') !== '') {
  1799. // friend, family or custom group
  1800. if (getV('custom_groups', '').indexOf($(this).attr('bgcolor')) > 0) {
  1801. // custom group
  1802. var cg = getV('custom_groups', '').split('|');
  1803. cg.pop();
  1804. for (var i = 0; i < cg.length; i++) {
  1805. var g = cg[i].split(':');
  1806. if (g[1] == $(this).attr('bgcolor')) {
  1807. var cg_prio = parseInt(sets['jailHL_' + g[0] + '_lackey'], 10);
  1808. priority = cg_prio;
  1809. if (!prior || priority <= prior) {
  1810. if (!prior || priority < prior) {
  1811. prior = priority;
  1812. bustlist = [];
  1813. }
  1814. bustlist.push($(this));
  1815. }
  1816. }
  1817. }
  1818. } else if ($(this).attr('bgcolor') == getV('fam_colour') || $(this).attr('bgcolor') == getV('friends_colour')) {
  1819. // friends or family
  1820. priority = jailHL_fr_lackey;
  1821. if (!prior || priority <= prior) {
  1822. if (!prior || priority < prior) {
  1823. prior = priority;
  1824. bustlist = [];
  1825. }
  1826. bustlist.push($(this));
  1827. }
  1828. }
  1829. } else {
  1830. // other
  1831. if ($(this).find('td:eq(0) > font > a').text() == getV('nick', '')) {
  1832. // own
  1833. priority = jailHL_own_lackey;
  1834. if (!prior || priority <= prior) {
  1835. if (!prior || priority < prior) {
  1836. prior = priority;
  1837. bustlist = [];
  1838. }
  1839. bustlist.push($(this));
  1840. }
  1841. } else {
  1842. // other
  1843. priority = jailHL_other_lackey;
  1844. if (!prior || priority <= prior) {
  1845. if (!prior || priority < prior) {
  1846. prior = priority;
  1847. bustlist = [];
  1848. }
  1849. bustlist.push($(this));
  1850. }
  1851. }
  1852. }
  1853. }
  1854. }).click(function () {
  1855. // Add selected on top
  1856. $('#HLrow').html($(this).html());
  1857. $('#HLrow').css('background-color', $(this).attr('bgcolor'));
  1858. $(this).find('input[name="bust"]').attr('checked', true);
  1859. });
  1860. if (bustlist.length > 0) {
  1861. var bustthis;
  1862. if (jailHL_sel === 'lowest') {
  1863. bustthis = bustlist[bustlist.length - 1];
  1864. } else if (jailHL_sel === 'random') {
  1865. bustthis = bustlist[rand(0, (bustlist.length - 1))];
  1866. } else {
  1867. bustthis = bustlist[0];
  1868. }
  1869.  
  1870. // select inmate
  1871. $('#HLrow').html(bustthis.html());
  1872. $('#HLrow').css('background-color', bustthis.attr('bgcolor'));
  1873. bustthis.find('input[name="bust"]').attr('checked', true);
  1874. }
  1875.  
  1876. $('tr[bgcolor][nobust]').find('input[name="bust"]').attr('checked', false);
  1877. // Add successful BO to total
  1878. var bustMsg = (v == 'nl' ? 'Je hebt deze gangster' : 'You busted this person');
  1879. var bustFriendMsg = (v == 'nl' ? 'celmaat uit de gevangenis' : 'cellmate out of jail');
  1880. if ($('#game_container:contains("' + bustMsg + '")').length) {
  1881. if ($('#game_container:contains("' + bustFriendMsg + '")').length) {
  1882. bos = (bos + 1);
  1883. }
  1884. bos = (bos + 1);
  1885. setV('bustouts', bos);
  1886. }
  1887. // Add amount of inmates and bustouts
  1888. $('#game_container tr:first').prepend(
  1889. $('<td>').css('width', '46%').append(
  1890. $('<span>').text('In jail: ' + rows),
  1891. $('<br />'),
  1892. $('<span>').text('Bustouts: ' + bos)
  1893. )
  1894. );
  1895. $('#game_container tr:first table').css('margin-left', '0');
  1896. }
  1897.  
  1898. // Shit we're busted!
  1899. if (on_page('/jail.php') && nn == 'table') {
  1900. var bo_hotkey = sets['bo_hotkey'] || '/';
  1901. // Add buyout hotkey
  1902. if ($('input[name="buymeout"]').length) {
  1903. $('input[name="buymeout"]').attr('accesskey', bo_hotkey);
  1904. }
  1905. // Go back to jail when time is over
  1906. if ($('#game_container span').attr('data-timeleft')) {
  1907. $('#game_container span').on('DOMSubtreeModified', function() {
  1908. if ($('#game_container span').attr('data-timeleft') == -1) {
  1909. unsafeWindow.omerta.GUI.container.loadPage(window.location.hash.substr(1));
  1910. }
  1911. });
  1912. }
  1913. }
  1914. // Save omerta jail settings
  1915. if (on_page('/jail_settings.php') && nn == 'form') {
  1916. // check if already saved
  1917. if ($('form[name="jailcolours"]').attr('saving') != 'done') {
  1918. // save omerta defaults
  1919. setV('friends_colour', $('select[name="friends_colour_select"]').val());
  1920. setV('fam_colour', $('select[name="fam_colour_select"]').val());
  1921. // cycle custom groups
  1922. var i = 1;
  1923. var custom_groups = '';
  1924. $('#game_container form center div').not('#creategroup').each(function() {
  1925. var group_name = $(this).attr('id');
  1926. var group_colour = $(this).find('select[name="editgroup_colour_select' + i + '"]').find('option:eq(0)').val();
  1927. custom_groups = custom_groups + group_name + ':' + group_colour + '|';
  1928. i++;
  1929. });
  1930. // save custom groups
  1931. setV('custom_groups', custom_groups);
  1932.  
  1933. $('form[name="jailcolours"]').attr('saving', 'done');
  1934. }
  1935. }
  1936. // ---------------- 1-click voter ----------------
  1937. if (on_page('/vfo.php') && nn == 'center') {
  1938. $('a[href*="votelot.php"]').attr('name', 'forticket');
  1939.  
  1940. $('td.tableheader:first').html(
  1941. $('<span>').addClass('orange').css({
  1942. cursor: 'pointer'
  1943. }).attr({
  1944. id: 'votelink',
  1945. title: ''
  1946. }).text($('td.tableheader:first').text())
  1947. ).click(function () {
  1948. voteNow(false);
  1949. });
  1950. var lastVote = getV('lastvote', 0); // get last voting time
  1951. if (lastVote === 0) {
  1952. if (confirm('You haven\'t used the 1-click voter yet!\nDo you want to use it now?')) {
  1953. voteNow(true);
  1954. }
  1955. } else { // not first run
  1956. var till = (parseInt(lastVote, 10) + 86400) - time(); // time till next vote
  1957. var msg = '';
  1958. if (till <= 0) { // user can vote again so ask
  1959. var ago = time() - lastVote; // time since last vote
  1960. msg += 'You haven\'t used the 1-click voter today!' + '\n' + 'Since you last used the 1-click voter, it\'s been:\n';
  1961. msg += Math.floor(ago / 86400) + ' days, '; // days
  1962. msg += Math.floor((ago % 86400) / 3600) + ' hours, '; // hours
  1963. msg += Math.floor((ago % 3600) / 60) + ' minutes and '; // minutes
  1964. msg += Math.floor(ago % 60) + ' seconds.'; // seconds
  1965. msg += '\n' + 'Do you want to use the 1-click voter now?';
  1966. } else { // can't vote yet
  1967. msg += 'You can\'t vote again yet!\nPlease wait another:\n';
  1968. msg += Math.floor(till / 3600) + ' hours, '; // hours
  1969. msg += Math.floor((till % 3600) / 60) + ' minutes and '; // minutes
  1970. msg += Math.floor(till % 60) + ' seconds.'; // seconds
  1971. msg += '\n' + 'Do you still want to vote?';
  1972. }
  1973. if (confirm(msg)) {
  1974. voteNow(true);
  1975. }
  1976. }
  1977. }
  1978. // ---------------- Group Crimes ----------------
  1979. // GroupCrime general accept focus
  1980. if (on_page('module=GroupCrimes') && nn == 'center') {
  1981. // focus on accept
  1982. $('a').filter(function () {
  1983. return (/Accept/i).test($(this).text());
  1984. }).focus();
  1985. // focus on transfer
  1986. $('a').filter(function () {
  1987. return (/Make Transfer/i).test($(this).text());
  1988. }).focus();
  1989. }
  1990. // Heist LE autoform
  1991. if (on_page('module=Heist') && nn == 'center') {
  1992. $('input[name="bullets"]').val('50');
  1993. $('select[name="gun"]').val('real');
  1994. if (GetParam('driver')) {
  1995. var dr = GetParam('driver');
  1996. $('input[name="driver"]').val(dr);
  1997. $('input[type="submit"]').focus();
  1998. } else {
  1999. $('input[name="driver"]').focus();
  2000. }
  2001. }
  2002. // OC accept focus
  2003. if (on_page('/orgcrime2.php') && nn == 'br') {
  2004. // focus on accept
  2005. $('a').filter(function () {
  2006. return (/Yes/i).test($(this).text());
  2007. }).focus();
  2008. }
  2009. // OC Participants autoform
  2010. if (on_page('?takepart=yes') && nn == 'form') {
  2011. // WE
  2012. $('input[name="bulletz"]').val('100');
  2013. $('select[name="guns"]').val('2');
  2014. // EE
  2015. $('input:radio[name="exploz"]').prop('checked', true);
  2016. // ALL
  2017. $('input[type="submit"]').focus();
  2018. }
  2019. // MOC Participants autoform
  2020. if (on_page('module=MegaOC') && nn == 'form') {
  2021. // WE
  2022. $('input[type="text"]').val('500');
  2023. // EE
  2024. $('input:radio:eq(2)').prop('checked', true);
  2025. // ALL
  2026. $('input[type="submit"]').focus();
  2027. }
  2028. // Raid LE autoform
  2029. if (on_page('module=Spots') && nn == 'form') {
  2030. var kind_text = (v == 'nl' ? 'Soort' : 'Kind');
  2031. var text_real = 'Real';
  2032. var text_fake = 'Fake';
  2033. var raid_setting = getV('raid_setting', 'real_raid');
  2034.  
  2035. $('table.thinline tr').eq(4).after($('<tr>').append(
  2036. $('<td>').html('<b>' + kind_text + '</b>'),
  2037. $('<td>').text(text_real).append(
  2038. $('<input>').attr({
  2039. type: 'radio',
  2040. class: 'real_raid',
  2041. checked: (raid_setting == 'real_raid') ? true : false
  2042. })
  2043. ).append(
  2044. text_fake
  2045. ).append(
  2046. $('<input>').attr({
  2047. type: 'radio',
  2048. class: 'fake_raid',
  2049. checked: (raid_setting == 'fake_raid') ? true : false
  2050. })
  2051. )
  2052. ));
  2053.  
  2054. if (raid_setting == 'fake_raid') {
  2055. $('input[name="bullets"]').val('0');
  2056. } else {
  2057. $('input[name="bullets"]').val('200');
  2058. }
  2059.  
  2060. $('input[type=radio]').change(function() {
  2061. setV('raid_setting', $(this).attr('class'));
  2062. raid_setting = getV('raid_setting');
  2063.  
  2064. if (raid_setting == 'fake_raid') {
  2065. $('input[name="bullets"]').val('0');
  2066. } else {
  2067. $('input[name="bullets"]').val('200');
  2068. }
  2069.  
  2070. $('input[type=radio]:checked').not(this).prop('checked', false);
  2071. });
  2072.  
  2073. if (GetParam('driver')) {
  2074. var dr = GetParam('driver');
  2075. $('input[name="driver"]').val(dr);
  2076. } else {
  2077. $('input[name="driver"]').focus();
  2078. }
  2079. }
  2080. // ---------------- Mail ----------------
  2081. // Inbox
  2082. if ((on_page('action=inbox') || on_page('action=delMsg') || (on_page('module=Mail') && !on_page('action='))) && nn == 'center') {
  2083. // save unread msg and msg ids
  2084. var msg = $('td[style="cursor:pointer;cursor:hand"]').length;
  2085. var unreadmsg = $('tr.color2').length;
  2086. var id = [];
  2087. for (var i = 0; i < msg; i++) { // find first open spot
  2088. id[i] = $('a[href*="showMsg"]:eq(' + i + ')').attr('href').split('?')[1].match(/\d+/g);
  2089. setV('msgids', id.join(',')); // join and save values
  2090. }
  2091. var unreadid = [];
  2092. for (var a = 0; a < unreadmsg; a++) { // find first open spot
  2093. unreadid[a] = $('tr.color2 > td:eq(1) > a').attr('href').split('?')[1].match(/\d+/g);
  2094. setV('unread', unreadid.join(',')); // join and save values
  2095. }
  2096. // delete and reply icons
  2097. var num = 1;
  2098. setTimeout(function () {
  2099. $('tr[class*="color"]').each(function () {
  2100. var id = $(this).children('td:eq(1)').children('a').attr('href').split('?')[1].match(/\d+/g)[0];
  2101. if ($(this).attr('class') == 'color2') {
  2102. $(this).children('td:eq(0)').append(
  2103. $('<img />').addClass('inboxImg unread').attr({
  2104. src: assetUrl('/images/delete.png'),
  2105. title: 'Delete'
  2106. }).click(function () {
  2107. delMsg('id', id);
  2108. })
  2109. );
  2110. } else {
  2111. $(this).children('td:eq(0)').append(
  2112. $('<img />').addClass('inboxImg').attr({
  2113. src: assetUrl('/images/delete.png'),
  2114. title: 'Delete'
  2115. }).click(function () {
  2116. delMsg('id', id);
  2117. })
  2118. );
  2119. }
  2120. if ($(this).children('td:eq(2)').children('a').length) { // add reply icon
  2121. $(this).children('td:eq(0)').append(
  2122. $('<a>').attr('href', 'BeO/webroot/index.php?module=Mail&action=sendMsg&iReply=' + id).html(
  2123. $('<img />').addClass('inboxImg').attr({
  2124. src: assetUrl('/images/reply.png'),
  2125. title: 'Reply'
  2126. })
  2127. )
  2128. );
  2129. }
  2130. if (num < 11) { // add msg hotkeys
  2131. var mailTitle = $(this).children('td:eq(1)').children();
  2132. mailTitle.html('[' + (num == 10 ? 0 : num) + '] ' + mailTitle.html());
  2133. mailTitle.attr('accesskey', (num == 10 ? 0 : num));
  2134. num++;
  2135. }
  2136. });
  2137. }, 0);
  2138. // hotkeys for system delete
  2139. var keys = ['-', '=', '[', ']', ';', '\''];
  2140. var selectors = $('td[align="right"][colspan="100%"] > a');
  2141. for (i = -1; ++i < selectors.length;) {
  2142. $('td[align="right"][colspan="100%"] > a:eq(' + i + ')').attr({
  2143. accesskey: keys[i],
  2144. title: 'Hotkey: ' + keys[i]
  2145. });
  2146. }
  2147. // select all button
  2148. $('td[align="right"][colspan="100%"]').prepend(
  2149. $('<span>').css('float', 'left').append(
  2150. $('<input />').attr({
  2151. type: 'button',
  2152. value: '(Un)Select All'
  2153. }).click(function () {
  2154. $('[name="selective[]"]').each(function () {
  2155. $(this).prop('checked', !$(this).prop('checked'));
  2156. });
  2157. })
  2158. )
  2159. );
  2160. // add custom system delete
  2161. // Declare translation variables
  2162.  
  2163. var lottery_text = (v == 'nl' ? 'Super Loterij' : 'Super Lottery');
  2164. var target_not_found_text = (v == 'nl' ? 'Doelwit niet gevonden' : 'Target not found');
  2165. var target_found_text = (v == 'nl' ? 'Doelwit gevonden' : 'Target found');
  2166. var promoted_text = (v == 'nl' ? 'Gepromoveerd' : 'Promoted');
  2167. var obay_higherbid_text = (v == 'nl' ? 'Obay hoger bod informatie' : 'Obay higher bid information');
  2168.  
  2169.  
  2170. $('td[align="right"][colspan="100%"] > a:eq(0)').before($('<br />'));
  2171. $('td[align="right"][colspan="100%"]').append(
  2172. $('<br />'),
  2173. $('<span>').text('Delete System: '),
  2174. $('<span>').css('cursor', 'pointer').text(lottery_text).click(function () {
  2175. delMsg('name', lottery_text);
  2176. }),
  2177. $('<span>').text(' | '),
  2178. $('<span>').css('cursor', 'pointer').text(target_not_found_text).click(function () {
  2179. delMsg('name', target_not_found_text);
  2180. }),
  2181. $('<span>').text(' | '),
  2182. $('<span>').css('cursor', 'pointer').text(target_found_text).click(function () {
  2183. delMsg('name', target_found_text);
  2184. }),
  2185. $('<span>').text(' | '),
  2186. $('<span>').css('cursor', 'pointer').text(promoted_text).click(function () {
  2187. delMsg('name', promoted_text);
  2188. }),
  2189. $('<span>').text(' | '),
  2190. $('<span>').css('cursor', 'pointer').text(obay_higherbid_text).click(function () {
  2191. delMsg('name', obay_higherbid_text);
  2192. })
  2193. );
  2194. }
  2195.  
  2196. // Outbox
  2197. if (on_page('action=outbox') && nn == 'center') {
  2198. setTimeout(function () {
  2199. $('a[href*="showSentMsg"]').each(function () {
  2200. var id = $(this).attr('href').split('?')[1].match(/\d+/g)[0];
  2201. $(this).parent().prepend(
  2202. $('<img />').addClass('inboxImg').attr({
  2203. src: assetUrl('/images/delete.png'),
  2204. title: 'Delete'
  2205. }).click(function () {
  2206. $.get('//' + document.location.hostname + '/BeO/webroot/index.php?module=Mail&action=delMsg&iId=' + id + '&iParty=1', function () {
  2207. $('font[color="red"]').text('Message deleted.');
  2208. });
  2209.  
  2210. $(this).closest('tr').hide();
  2211. $(this).closest('tr').next().hide();
  2212. })
  2213. );
  2214. });
  2215. }, 0);
  2216. }
  2217.  
  2218. // Show message
  2219. if (on_page('action=showMsg') && nn == 'center') {
  2220. var id = wlh.split('iMsgId=')[1].match(/\d+/g)[0];
  2221. var ids = getV('msgids', '').split(',');
  2222. for (var i = 0; i < ids.length; i++) {
  2223. if (ids[i] == id) {
  2224. var next = ids[i - 1];
  2225. var prev = ids[i + 1];
  2226. }
  2227. }
  2228. // check unread msg and grab obay bullets
  2229. var unread = getV('unread', '').split(',');
  2230. for (var x = 0; x < unread.length; ++x) {
  2231. if (unread[x] !== '' && unread[x] == id) { // msg is unread
  2232. var msgTyp = $('tr.tableitem').text().split(/Type:|Soort:/);
  2233. if (msgTyp.length > 1) {
  2234. var msgTyp = msgTyp[1].split(/Sent:|Verzonden:/)[0];
  2235. }
  2236. var arr = $('table.thinline > tbody > tr:eq(7) > td').html().split(' ');
  2237. var bulletmsg = new RegExp('Obay bid succesful');
  2238. if (bulletmsg.test(msgTyp)) { // grab obay bullets from message
  2239. setV('obaybul', (getV('obaybul', 0) + parseInt(arr[2], 10)));
  2240. }
  2241. // resave unread msg's, without our msg
  2242. var str = '';
  2243. for (var y = 0; y < unread.length; ++y) {
  2244. if (unread[y] !== '' && unread[y] != id) {
  2245. str += ',' + unread[y];
  2246. }
  2247. }
  2248. setV('unread', str.substr(1));
  2249. x = unread.length; // not needed to continue because we found our id
  2250. }
  2251. }
  2252. // add previous and next arrows
  2253. setTimeout(function () {
  2254. $('table.thinline > tbody > tr > td.tableheader:eq(1)').append(
  2255. $('<span>').css({
  2256. float: 'right',
  2257. 'padding-top': '2px'
  2258. }).append(
  2259. $('<a>').attr({
  2260. id: 'prev',
  2261. href: '/BeO/webroot/index.php?module=Mail&action=showMsg&iMsgId=' + prev
  2262. }).append(
  2263. $('<img>').addClass('inboxImg').attr({
  2264. title: 'Previous',
  2265. src: assetUrl('/images/prev.png')
  2266. })
  2267. )
  2268. ).append(
  2269. $('<a>').attr({
  2270. id: 'next',
  2271. href: '/BeO/webroot/index.php?module=Mail&action=showMsg&iMsgId=' + next
  2272. }).append(
  2273. $('<img>').addClass('inboxImg').attr({
  2274. title: 'Next',
  2275. src: assetUrl('/images/next.png')
  2276. })
  2277. )
  2278. )
  2279. );
  2280. for (var j = 0; j < ids.length; j++) {
  2281. if (ids[j] == id) {
  2282. if (j === 0) {
  2283. $('a#next').css('visibility', 'hidden');
  2284. }
  2285. if (j == ids.length - 1) {
  2286. $('a#prev').css('visibility', 'hidden');
  2287. }
  2288. }
  2289. }
  2290. }, 0);
  2291. // replace reply and delete links
  2292. var linkz = $('table.thinline > tbody > tr:eq(9) > td > a');
  2293. if (linkz.length == 1) {
  2294. setTimeout(function () {
  2295. $('table.thinline > tbody > tr:eq(9) > td > a').html(
  2296. $('<img />').addClass('inboxImg').attr({
  2297. src: assetUrl('/images/delete.png'),
  2298. title: 'Delete ([)'
  2299. })
  2300. ).attr('accesskey', '[');
  2301. }, 0);
  2302. } else {
  2303. setTimeout(function () {
  2304. $('table.thinline > tbody > tr:eq(9) > td > a:first').html(
  2305. $('<img />').addClass('inboxImg').attr({
  2306. src: assetUrl('/images/delete.png'),
  2307. title: 'Delete ([)'
  2308. })
  2309. ).attr('accesskey', '[');
  2310. $('table.thinline > tbody > tr:eq(9) > td > a:last').html(
  2311. $('<img />').addClass('inboxImg').attr({
  2312. src: assetUrl('/images/reply.png'),
  2313. title: 'Reply (])'
  2314. })
  2315. ).attr('accesskey', ']');
  2316. }, 0);
  2317. }
  2318. // Add arrow hotkeys
  2319. $(window).keydown(function (event) {
  2320. var key = event.which;
  2321. if (key == 39) { // right, reply
  2322. unsafeWindow.omerta.GUI.container.loadPage('./BeO/webroot/index.php?module=Mail&action=sendMsg&iReply=' + id);
  2323. }
  2324. if (key == 38 && id != ids[0]) { // up, select previous
  2325. unsafeWindow.omerta.GUI.container.loadPage('./BeO/webroot/index.php?module=Mail&action=showMsg&iMsgId=' + next);
  2326. }
  2327. if (key == 40 && id != ids[ids.length - 1]) { // down, select next
  2328. unsafeWindow.omerta.GUI.container.loadPage('./BeO/webroot/index.php?module=Mail&action=showMsg&iMsgId=' + prev);
  2329. }
  2330. if (key == 37) { // left, delete
  2331. unsafeWindow.omerta.GUI.container.loadPage('./BeO/webroot/index.php?module=Mail&action=delMsg&iId=' + id + '&iParty=2');
  2332. }
  2333. });
  2334. }
  2335. // focus on text area
  2336. if (on_page('iReply=') && nn == 'center') {
  2337. $('textarea').focus();
  2338. }
  2339. // redirect on send message
  2340. if (on_page('action=sendMsg') && nn == 'b') { // needs testing
  2341. if ($('font:eq(0)').text().indexOf('Message sent to') != -1) {
  2342. setTimeout(function () {
  2343. $('a[href*="inbox"]')[0].click();
  2344. }, 1000);
  2345. }
  2346. }
  2347. // ---------------- Bank ----------------
  2348. if (on_page('/bank.php') && nn == 'center') {
  2349. // auto reload after transfer
  2350. if ($('#game_container center').html().search('<table') == -1) {
  2351. setTimeout(function () {
  2352. unsafeWindow.omerta.GUI.container.loadPage(window.location.hash.substr(1));
  2353. }, 1000);
  2354. }
  2355. // Add amount of interest next to %
  2356. if ($('table.thinline:eq(1) > tbody > tr:eq(1) > td:eq(1)').length) { // check for banked money
  2357. var money = $('table.thinline:eq(1) > tbody > tr:eq(1) > td:eq(1)').text();
  2358. var rx = $('table.thinline:eq(1) > tbody > tr:eq(3) > td:eq(1)').text(); // get received amount
  2359. var tmp = 1 * rx.replace(/\D/g, '') - 1 * money.replace(/\D/g, ''); // calculate interest
  2360. $('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) + ')');
  2361. setTimeout(function () {
  2362. setV('interest', tmp);
  2363. }, 0);
  2364.  
  2365. // Interest reminder
  2366. var seconds = parseInt($('table.thinline:eq(1) tbody span').attr('data-timeleft'), 10);
  2367. setTimeout(function () {
  2368. setV('banktleft', (time() + seconds));
  2369. }, 0);
  2370. }
  2371. // Calculators
  2372. if ($('td[width="33%"]:eq(2)').length) {
  2373. $('td[width="33%"]:eq(2)').append(
  2374. $('<br />'),
  2375. $('<table>').addClass('thinline').attr({
  2376. width: '100%',
  2377. align: 'center',
  2378. rules: 'none'
  2379. }).append(
  2380. $('<tr>').append(
  2381. $('<td>').addClass('tableheader').attr('colspan', '4').text('Calculators')
  2382. ), $('<tr>').append(
  2383. $('<td>').attr({
  2384. align: 'left',
  2385. width: '20%'
  2386. }).text('You send:'),
  2387. $('<td>').attr({
  2388. align: 'left',
  2389. width: '25%'
  2390. }).append(
  2391. $('<input>').attr({
  2392. name: 'amount',
  2393. type: 'text',
  2394. value: '',
  2395. maxlength: '11',
  2396. size: '13'
  2397. }).keyup(function () {
  2398. var amt = $(this).val().replace(/\D+/g, '');
  2399. $('#get').text('$' + commafy(Math.round(amt * 0.9)));
  2400. })
  2401. ),
  2402. $('<td>').attr({
  2403. align: 'left',
  2404. width: '23%'
  2405. }).text('User gets:'),
  2406. $('<td>').attr({
  2407. align: 'left',
  2408. id: 'get'
  2409. }).text('$0')
  2410. ), $('<tr>').append(
  2411. $('<td>').attr({
  2412. align: 'left',
  2413. width: '20%'
  2414. }).text('You want:'),
  2415. $('<td>').attr({
  2416. align: 'left',
  2417. width: '25%'
  2418. }).append(
  2419. $('<input>').attr({
  2420. name: 'amount',
  2421. type: 'text',
  2422. value: '',
  2423. maxlength: '11',
  2424. size: '13'
  2425. }).keyup(function () {
  2426. var amt = $(this).val().replace(/\D+/g, '');
  2427. $('#give').text('$' + commafy(Math.round(amt / 0.9)));
  2428. })
  2429. ),
  2430. $('<td>').attr({
  2431. align: 'left',
  2432. width: '23%'
  2433. }).text('User sends:'),
  2434. $('<td>').attr({
  2435. align: 'left',
  2436. id: 'give'
  2437. }).text('$0')
  2438. ), $('<tr>').append(
  2439. $('<td>').attr({
  2440. align: 'left',
  2441. width: '20%'
  2442. }).text('Deposit:'),
  2443. $('<td>').attr({
  2444. align: 'left',
  2445. width: '25%'
  2446. }).append(
  2447. $('<input>').attr({
  2448. name: 'amount',
  2449. type: 'text',
  2450. value: '',
  2451. maxlength: '11',
  2452. size: '13'
  2453. }).keyup(function () {
  2454. var amt = $(this).val().replace(/\D+/g, '');
  2455. $('#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))));
  2456. })
  2457. ),
  2458. $('<td>').attr({
  2459. align: 'left',
  2460. width: '23%'
  2461. }).text('Receive:'),
  2462. $('<td>').attr({
  2463. align: 'left',
  2464. id: 'int'
  2465. }).text('$0')
  2466. )
  2467. )
  2468. );
  2469. }
  2470. // m/k usage
  2471. var inputs = $('input[name="amount"], input#amount');
  2472. inputs.each(function () {
  2473. $(this).keydown(function (event) {
  2474. var symcode = event.which;
  2475. if (symcode == 75) {
  2476. $(this).val($(this).val() + '000');
  2477. }
  2478. if (symcode == 77) {
  2479. $(this).val($(this).val() + '000000');
  2480. }
  2481. return (symcode == 75 || symcode == 77) ? false : true;
  2482. });
  2483. });
  2484. }
  2485. // ---------------- All users ----------------
  2486. if (on_page('/allusers.php') && nn == 'div') {
  2487. // add page number
  2488. var start = parseInt(GetParam('start'), 10);
  2489. var page = (start / 15) + 1;
  2490. $('h4').before($('<h4>').text('Page: ' + page));
  2491.  
  2492. // edit show/hide dead link
  2493. var dead = GetParam('dead');
  2494. if (dead !== null) {
  2495. var url = wlh.replace('#', '');
  2496. var hs = (dead == 'HIDE') ? 'SHOW' : 'HIDE';
  2497. $('a[href*="/allusers.php?dead="]').attr('href', url.replace(dead, hs));
  2498. }
  2499. }
  2500. // ---------------- TOP 3 ----------------
  2501. // Control Panel
  2502. if (on_page('module=Family') && nn == 'div') {
  2503. if (GetParam('who')) {
  2504. $('input[name="invite"]').val(GetParam('who'));
  2505. }
  2506. // linkify CP log
  2507. if (nid == 'jsprogbar_fam_rank_progress') {
  2508. $('table.color2:eq(0) > tbody > tr > td').not(':first').not(':last').each(function () {
  2509. if ($(this).text() !== '') {
  2510. var len = $(this).html().trim().split(' ').length - 1;
  2511. var who = $(this).html().trim().split(' ');
  2512. if (who[0].match(/[A-Z]/g)) {
  2513. if (who[0] != 'Your') {
  2514. who[0] = '<a href="/user.php?nick=' + who[0] + '"><b>' + who[0] + '</b></a>';
  2515. }
  2516. }
  2517. if (who[len].match(/[A-Z]/g)) {
  2518. if (who[len] != 'Capo(s)') {
  2519. if (who[len] != 'Object(s)') {
  2520. if (who[len] != 'Unlocked') {
  2521. if (who[len] != 'Boss.') {
  2522. who[len] = '<a href="/user.php?nick=' + who[len].match(/\D+/g)[0].replace('.', '') + '"><b>' + who[len] + '</b></a>';
  2523. }
  2524. }
  2525. }
  2526. }
  2527. }
  2528. $(this).html(who.join(' '));
  2529. }
  2530. });
  2531. // Add promo calculation for GF/FL.
  2532. 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);
  2533. var perc = (cdP != '0') ? $('input[name="ppercentage"]').val() : 0;
  2534. var gfP = parseInt((((cdP / 100) * perc) + parseInt(cdP, 10)), 10);
  2535. $('table.color2:eq(1) > tbody > tr:eq(16) > td > table > tbody').append(
  2536. $('<tr>').append(
  2537. $('<td>').text('GF / FL'),
  2538. $('<td>').text('$ ' + commafy(gfP))
  2539. )
  2540. );
  2541. }
  2542. }
  2543. // linkify opened CP log
  2544. if (on_page('/familylog.php') && nn == 'table') {
  2545. $('table.color2 > tbody > tr > td').not(':first').each(function () {
  2546. if ($(this).text() !== '') {
  2547. var len = $(this).html().trim().split(' ').length - 1;
  2548. var who = $(this).html().trim().split(' ');
  2549. if (who[0].match(/[A-Z]/g)) {
  2550. if (who[0] != 'Your') {
  2551. who[0] = '<a href="/user.php?nick=' + who[0] + '"><b>' + who[0] + '</b></a>';
  2552. }
  2553. }
  2554. if (who[len].match(/[A-Z]/g)) {
  2555. if (who[len] != 'Capo(s)') {
  2556. if (who[len] != 'Object(s)') {
  2557. if (who[len] != 'Unlocked') {
  2558. if (who[len] != 'Boss.') {
  2559. who[len] = '<a href="/user.php?nick=' + who[len].match(/\D+/g)[0].replace('.', '') + '"><b>' + who[len] + '</b></a>';
  2560. }
  2561. }
  2562. }
  2563. }
  2564. }
  2565. $(this).html(who.join(' '));
  2566. }
  2567. });
  2568. }
  2569. // Family bank
  2570. if (on_page('/cpbank.php') && nn == 'center') {
  2571. $('table.thinline:eq(0)').after($('<br />'), $('<table>').addClass('thinline').attr({
  2572. width: '600',
  2573. align: 'center',
  2574. rules: 'none'
  2575. }).append(
  2576. $('<tr>').append(
  2577. $('<td>').addClass('tableheader').attr('colspan', '4').text('Calculators')
  2578. ), $('<tr>').append(
  2579. $('<td>').attr({
  2580. align: 'right',
  2581. width: '25%'
  2582. }).text('You send:'),
  2583. $('<td>').attr({
  2584. align: 'center',
  2585. width: '25%'
  2586. }).append(
  2587. $('<input>').attr({
  2588. name: 'amount',
  2589. type: 'text',
  2590. value: '',
  2591. maxlength: '11',
  2592. size: '15'
  2593. }).keyup(function () {
  2594. var amt = $(this).val().replace(/\D+/g, '');
  2595. $('#get').text('$' + commafy(Math.round(amt * 0.85)));
  2596. })
  2597. ),
  2598. $('<td>').attr({
  2599. align: 'right',
  2600. width: '25%'
  2601. }).text('User gets:'),
  2602. $('<td>').attr({
  2603. align: 'center',
  2604. width: '25%',
  2605. id: 'get'
  2606. }).text('$0')
  2607. ), $('<tr>').append(
  2608. $('<td>').attr({
  2609. align: 'right',
  2610. width: '25%'
  2611. }).text('You want:'),
  2612. $('<td>').attr({
  2613. align: 'center',
  2614. width: '25%'
  2615. }).append(
  2616. $('<input>').attr({
  2617. name: 'amount',
  2618. type: 'text',
  2619. value: '',
  2620. maxlength: '11',
  2621. size: '15'
  2622. }).keyup(function () {
  2623. var amt = $(this).val().replace(/\D+/g, '');
  2624. $('#give').text('$' + commafy(Math.round(amt / 0.85)));
  2625. })
  2626. ),
  2627. $('<td>').attr({
  2628. align: 'right',
  2629. width: '25%'
  2630. }).text('User sends:'),
  2631. $('<td>').attr({
  2632. align: 'center',
  2633. width: '25%',
  2634. id: 'give'
  2635. }).text('$0')
  2636. )
  2637. ));
  2638.  
  2639. // m/k usage
  2640. var inputs = $('input[name="amount"]');
  2641. inputs.each(function () {
  2642. $(this).keydown(function (event) {
  2643. var symcode = event.which;
  2644. if (symcode == 75) {
  2645. $(this).val($(this).val() + '000');
  2646. }
  2647. if (symcode == 77) {
  2648. $(this).val($(this).val() + '000000');
  2649. }
  2650. $(this).val($(this).val().replace(/k|m/g, ''));
  2651. return (symcode == 75 || symcode == 77) ? false : true;
  2652. });
  2653. });
  2654. }
  2655. // ---------------- SlotsTracker ----------------
  2656. if ((on_page('/gambling/slotmachine.php') || on_page('module=Casino.SlotMachine')) && nn == 'center') {
  2657. var slotjp = parseInt(getV('slotjp', 0), 10);
  2658. var slotbar = parseInt(getV('slotbar', 0), 10);
  2659. var slotgames = parseInt(getV('slotgames', 0), 10);
  2660. var slotgwon = parseInt(getV('slotgwon', 0), 10);
  2661. var slotmwon = parseInt(getV('slotmwon', 0), 10);
  2662. var slotspent = parseInt(getV('slotspent', 0), 10);
  2663. var slotbet = parseInt(getV('slotbet', 0), 10);
  2664. var jpmwon = parseInt(getV('jpmwon', 0), 10);
  2665. var str = $('#game_container > center > table > tbody > tr:eq(2) > td').text().replace(/,/g, '').replace(/\n/g, '').replace(/\t/g, '');
  2666. var betinput = $('input[name="bet"]');
  2667. betinput.focus();
  2668. betinput.keyup(function () {
  2669. setV('slotbet', parseInt($(this).val(), 10));
  2670. });
  2671.  
  2672. if ($('#game_container:contains("Congratulations!")').length > 0 || $('#game_container:contains("YOU WON THE JACKPOT")').length > 0) {
  2673. var S1 = $('img[src*="slotmachine"]:eq(0)').attr('src').replace(/">/g, '').split('/');
  2674. var S2 = $('img[src*="slotmachine"]:eq(1)').attr('src').replace(/">/g, '').split('/');
  2675. var S3 = $('img[src*="slotmachine"]:eq(2)').attr('src').replace(/">/g, '').split('/');
  2676. if (S1[6] == 'a.gif' && S2[6] == 'a.gif' && S3[6] == 'a.gif') { // Jackpot
  2677. var rexjp = new RegExp('You Win \\$(\\d+)');
  2678. var jpm = str.match(rexjp); // get money
  2679. jpmwon += parseInt(jpm[1], 10); // jp money won;
  2680. setV('jpmwon', jpmwon);
  2681. slotmwon += parseInt(jpm[1], 10); // money won;
  2682. setV('slotmwon', slotmwon);
  2683. slotjp += 1; // jackpot +1;
  2684. setV('slotjp', slotjp);
  2685. }
  2686. if (S1[6] == 'b.gif' && S2[6] == 'b.gif' && S3[6] == 'b.gif') { // Triple Bar
  2687. slotbar += 1; // triple bar +1;
  2688. setV('slotbar', slotbar);
  2689. }
  2690. var rex = new RegExp('Congratulations! You won \\$ (\\d+)');
  2691. var smw = str.match(rex); // get money
  2692. slotgames += 1; // games played +1;
  2693. setV('slotgames', slotgames);
  2694. slotgwon += 1; // games won +1;
  2695. setV('slotgwon', slotgwon);
  2696. slotmwon += parseInt(smw[1], 10); // money won;
  2697. slotmwon += parseInt(slotbet, 10); // bet back;
  2698. setV('slotmwon', slotmwon);
  2699. slotspent += parseInt(slotbet, 10); // money spent
  2700. setV('slotspent', slotspent);
  2701. }
  2702. if ($('#game_container:contains("Bummer")').length > 0) { // lost
  2703. slotgames += 1; // games played +1;
  2704. setV('slotgames', slotgames);
  2705. slotspent += parseInt(slotbet, 10); // money spent
  2706. setV('slotspent', slotspent);
  2707. }
  2708.  
  2709. var slotprofit = slotmwon - slotspent;
  2710. if (slotspent >= 0) {
  2711. if (slotprofit >= 0) {
  2712. slotprofit = '$' + commafy(slotprofit);
  2713. } else {
  2714. slotprofit = '-$' + commafy(slotspent - slotmwon);
  2715. }
  2716. }
  2717. var sgamesWon = Math.round((slotgwon / slotgames) * 100);
  2718. var sgamesWon2 = isNaN(sgamesWon) ? 0 : sgamesWon;
  2719.  
  2720. var SlTtop = parseInt(getV('SlTtop', '225'), 10);
  2721. var SlTleft = parseInt(getV('SlTleft', '300'), 10);
  2722. if ($('#SlTracker').length === 0) {
  2723. $('#game_container').append(
  2724. $('<div>').addClass('tracker').attr({
  2725. id: 'SlTracker',
  2726. 'data-beyond-fired': true
  2727. }).css({
  2728. top: SlTtop,
  2729. left: SlTleft
  2730. }).append(
  2731. $('<div>').attr({
  2732. id: 'slthead'
  2733. }).append(
  2734. $('<center>').text('SlotsTracker').css({
  2735. fontWeight: 'bold'
  2736. })
  2737. ).click(function () {
  2738. $('#SlTracker').draggable();
  2739. }),
  2740. $('<hr>').css({
  2741. color: 'gray'
  2742. }),
  2743. $('<div>').attr({
  2744. id: 'sltbody'
  2745. }).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>'),
  2746. $('<hr>').css({
  2747. color: 'gray'
  2748. }),
  2749. $('<div>').attr({
  2750. id: 'sltreset'
  2751. }).addClass('reset').text('Reset stats').click(function () {
  2752. $(this).text('Stats have been reset!');
  2753. $('#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>');
  2754. setV('slotgames', 0);
  2755. setV('slotgwon', 0);
  2756. setV('slotmwon', 0);
  2757. setV('slotspent', 0);
  2758. setV('slotjp', 0);
  2759. setV('slotbar', 0);
  2760. setV('jpmwon', 0);
  2761. })
  2762. )
  2763. );
  2764. }
  2765. $('#SlTracker').mouseup(function () {
  2766. var divOffset = $('#SlTracker').offset();
  2767. var left = divOffset.left;
  2768. var top = divOffset.top;
  2769. setV('SlTleft', left);
  2770. setV('SlTtop', top);
  2771. });
  2772. // m/k usage
  2773. betinput.each(function () {
  2774. $(this).keydown(function (event) {
  2775. var symcode = event.which;
  2776. if (symcode == 75) {
  2777. $(this).val($(this).val() + '000');
  2778. }
  2779. if (symcode == 77) {
  2780. $(this).val($(this).val() + '000000');
  2781. }
  2782. $(this).val($(this).val().replace(/k|m/g, ''));
  2783. return (symcode == 75 || symcode == 77) ? false : true;
  2784. });
  2785. });
  2786. }
  2787. // ---------------- Scratch tracker ----------------
  2788. if (on_page('/scratch.php') && (nn == 'center' || nn == 'form')) {
  2789. var monin = parseInt(getV('monin', 0), 10);
  2790. var mils = parseInt(getV('mils', 0), 10);
  2791. var bullets = parseInt(getV('bullets', 0), 10);
  2792. var scratches = parseInt(getV('scratches', 0), 10);
  2793.  
  2794. if ($('#game_container:contains("Congratulations!"), #game_container:contains("Gefeliciteerd!")').length) { // grab winning event
  2795. if ($('#game_container:contains("They have been added to your account!"), #game_container:contains("Ze zijn toegevoegd aan jouw account!")').length) { // bullets
  2796. var rex = new RegExp('(\\d+) (bullets|Kogels)');
  2797. var r = $('#game_container').text().match(rex);
  2798. bullets += parseInt(r[1], 10);
  2799. setV('bullets', bullets);
  2800. }
  2801. if ($('#game_container:contains("It has been added to your account!"), #game_container:contains("Het is toegevoegd aan je account!")').length) { // money
  2802. var rex = new RegExp('\\$ (\\d+)');
  2803. var str = $('#game_container').text().replace(/,/g, '');
  2804. var r = str.match(rex);
  2805. monin += parseInt(r[1], 10);
  2806. setV('monin', monin);
  2807. if (parseInt(r[1], 10) == 1000000) {
  2808. mils += 1;
  2809. setV('mils', mils);
  2810. }
  2811. $('input[name="scratch"]').focus();
  2812. }
  2813. }
  2814. if ($('#game_container:contains("Start scratching"), #game_container:contains("Start met krassen")').length) { // grab scratching event
  2815. scratches += 1;
  2816. setV('scratches', scratches);
  2817. if ($('input[name="Check"]').length) {
  2818. $('input[name="Check"]').focus();
  2819. } else {
  2820. $('input[type="submit"]').focus();
  2821. }
  2822. } else {
  2823. if ($('input[name="codescratch"]').length) { // focus on unclaimed prices
  2824. $('input[type="submit"]:eq(1)').focus();
  2825. } else { // focus on scratch
  2826. $('input[name="scratch"]').focus();
  2827. }
  2828. }
  2829.  
  2830. var monout = (scratches * 5000);
  2831. var profit;
  2832. if ((monin - monout) < 0) {
  2833. profit = '-$' + commafy(monout - monin);
  2834. } else {
  2835. profit = '$' + commafy(monin - monout);
  2836. }
  2837. var ppk = Math.round((((monout - monin) / bullets) * 100000) / 100000);
  2838. if (isNaN(ppk) || bullets === 0) {
  2839. ppk = 0;
  2840. }
  2841.  
  2842. var STtop = parseInt(getV('STtop', '225'), 10);
  2843. var STleft = parseInt(getV('STleft', '300'), 10);
  2844. if ($('#STracker').length === 0) {
  2845. $('#game_container').append(
  2846. $('<div>').addClass('tracker').attr({
  2847. id: 'STracker',
  2848. 'data-beyond-fired': true
  2849. }).css({
  2850. top: STtop,
  2851. left: STleft
  2852. }).append(
  2853. $('<div>').attr({
  2854. id: 'sthead'
  2855. }).append(
  2856. $('<center>').text('ScratchTracker').css({
  2857. fontWeight: 'bold'
  2858. })
  2859. ).click(function () {
  2860. $('#STracker').draggable();
  2861. }),
  2862. $('<hr>').css({
  2863. color: 'gray'
  2864. }),
  2865. $('<div>').attr({
  2866. id: 'stbody'
  2867. }).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>'),
  2868. $('<hr>').css({
  2869. color: 'gray'
  2870. }),
  2871. $('<div>').attr({
  2872. id: 'streset'
  2873. }).addClass('reset').text('Reset stats').click(function () {
  2874. $(this).text('Stats have been reset!');
  2875. $('#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>');
  2876. setV('monin', 0);
  2877. setV('mils', 0);
  2878. setV('bullets', 0);
  2879. setV('scratches', 0);
  2880. })
  2881. )
  2882. );
  2883. }
  2884. $('#STracker').mouseup(function () {
  2885. // alert('Set the x and y values using GM_getValue.');
  2886. var divOffset = $('#STracker').offset();
  2887. var left = divOffset.left;
  2888. var top = divOffset.top;
  2889. setV('STleft', left);
  2890. setV('STtop', top);
  2891. });
  2892. }
  2893.  
  2894. // ---------------- Bullet Tracker ----------------
  2895. if (on_page('/bullets2.php')) {
  2896. if (notificationsArray['Bullets'] !== undefined) {
  2897. notificationsArray['Bullets'].close();
  2898. delete notificationsArray['Bullets'];
  2899. }
  2900.  
  2901. var BTd = new Date();
  2902. var btdate = getV('btdate', 0);
  2903. if (BTd.getDate() > btdate) {
  2904. setV('bttoday', 0);
  2905. }
  2906. var obaybul = parseInt(getV('obaybul', 0), 10);
  2907. var btbullets = parseInt(getV('btbullets', 0), 10);
  2908. var bttoday = parseInt(getV('bttoday', 0), 10);
  2909. var btmoney = parseInt(getV('btmoney', 0), 10);
  2910. if (nn == 'br' && $('#game_container:contains("Success, you bought")').length) {
  2911. var rex = new RegExp('Success you bought (\\d+) bullets for \\$ (\\d+)');
  2912. var str = $('#game_container').text().split('Bulletfactory')[0].replace(/,/g, '');
  2913. var r = str.match(rex);
  2914. btbullets += parseInt(r[1], 10);
  2915. bttoday += parseInt(r[1], 10);
  2916. btmoney += parseInt(r[2], 10);
  2917. setV('btbullets', btbullets);
  2918. setV('bttoday', bttoday);
  2919. setV('btmoney', btmoney);
  2920. setV('btdate', BTd.getDate());
  2921. $('#BTracker').remove();
  2922. }
  2923. var btdolpbul;
  2924. if (btbullets === 0) {
  2925. btdolpbul = 0;
  2926. } else {
  2927. btdolpbul = Math.round((btmoney / btbullets) * 100) / 100;
  2928. }
  2929.  
  2930. var BTtop = parseInt(getV('BTtop', '300'), 10);
  2931. var BTleft = parseInt(getV('BTleft', '225'), 10);
  2932. if ($('#BTracker').length === 0) {
  2933. $('#game_container').append(
  2934. $('<div>').addClass('tracker').attr({
  2935. id: 'BTracker',
  2936. 'data-beyond-fired': true
  2937. }).css({
  2938. top: BTtop,
  2939. left: BTleft
  2940. }).append(
  2941. $('<div>').attr({
  2942. id: 'bthead'
  2943. }).append(
  2944. $('<center>').text('BulletTracker').css({
  2945. fontWeight: 'bold'
  2946. })
  2947. ).click(function () {
  2948. $('#BTracker').draggable();
  2949. }),
  2950. $('<hr>').css({
  2951. color: 'gray'
  2952. }),
  2953. $('<div>').attr({
  2954. id: 'btbody'
  2955. }).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>'),
  2956. $('<hr>').css({
  2957. color: 'gray'
  2958. }),
  2959. $('<div>').attr({
  2960. id: 'btreset'
  2961. }).addClass('reset').text('Reset stats').click(function () {
  2962. $(this).text('Stats have been reset!');
  2963. $('#btbody > font:not(:last-child) > b').text('0');
  2964. setV('btbullets', 0);
  2965. setV('btmoney', 0);
  2966. setV('bttoday', 0);
  2967. setV('btdate', 0);
  2968. setV('obaybul', 0);
  2969. })
  2970. )
  2971. );
  2972. }
  2973. $('#BTracker').mouseup(function () {
  2974. var divOffset = $('#BTracker').offset();
  2975. var left = divOffset.left;
  2976. var top = divOffset.top;
  2977. setV('BTleft', left);
  2978. setV('BTtop', top);
  2979. });
  2980. }
  2981. // ---------------- User Profile ----------------
  2982. if (on_page('user.php') && nn == 'center') {
  2983. var status = $('span#status').text();
  2984. var inFam = ($('span#family > a').length ? $('span#family > a').text() : $('span#family').text());
  2985. var alive = status.search(/Dead|Dood/);
  2986. var unick = $('span#username').first().text();
  2987. // DEAD or AKILLED ?
  2988. if (!alive) {
  2989. var rankings = '<a href="/BeO/webroot/index.php?module=Rankings&nick=' + unick + '">View Rankings</a>';
  2990. if ($('img[src*="/userbadges/rip.gif"]').parent().get(0).tagName != 'A') {
  2991. var akill = '<span style="color:red; font-weight:bold;"> (Akill) </span>';
  2992. status += akill;
  2993. }
  2994. $.getJSON(OB_API_WEBSITE + '/?p=stats&w=deaths&v=' + v + '&ing=' + unick, function (data) {
  2995. if (data['DiedAt'] === null) {
  2996. $('span#status').html(status + ' | Death date is not known');
  2997. } else {
  2998. $('span#status').html(status + ' | ' + rankings + ' | Died at ' + data['Date'] + ' OT (' + data['Agod'] + 'd ' + data['Agoh'] + 'h ' + data['Agom'] + 'm ago)');
  2999. }
  3000. });
  3001. }
  3002. if (status === 'Alive' || status === 'Levend') {
  3003. $.getJSON(OB_API_WEBSITE + '/?p=stats&w=laston&v=' + v + '&ing=' + unick, function (data) {
  3004. if (data['LastOn'] === 0) { // 1970, thus not seen by logger
  3005. $('span#status').text(status + ' | This user has not been seen online by our logger yet');
  3006. } else {
  3007. $('span#status').html(status + ' | Last on: ' + data['Date'] + ' OT (' + data['Agod'] + 'd ' + data['Agoh'] + 'h ' + data['Agom'] + 'm ago)');
  3008. }
  3009. });
  3010. }
  3011.  
  3012. // Wealth
  3013. var tr, x, y, z;
  3014. tr = 10;
  3015. x = $('#game_container').html().search('Marital status:');
  3016. y = $('#game_container').html().search('SMS Status');
  3017. z = $('#game_container').html().search('Family Buster of');
  3018.  
  3019. if (x == -1) {
  3020. tr--;
  3021. }
  3022. if (y == -1) {
  3023. tr--;
  3024. }
  3025. if (z == -1) {
  3026. tr--;
  3027. }
  3028.  
  3029. var wlth = $('#wealth').attr('value');
  3030.  
  3031. 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)'],
  3032. i = 1;
  3033. 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']);
  3034. var a = wealth.indexOf(wlth);
  3035.  
  3036. $('#wealth').text(wlth + kind[a]);
  3037.  
  3038. // Race form
  3039. var rf = $('#raceform').attr('value');
  3040. 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']);
  3041. var a = driver.indexOf(rf);
  3042. $('#raceform').text((a + 1) + ' - ' + rf);
  3043.  
  3044. // Bust ranks
  3045. var bustrank = $('#bustrank').attr('value');
  3046.  
  3047. 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+)'],
  3048. i = 1;
  3049. 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']);
  3050.  
  3051. var a = brank.indexOf(bustrank);
  3052.  
  3053. $('#bustrank').text(bustrank + amount[a]);
  3054.  
  3055. // Actions
  3056. var self = ($('table.thinline > tbody > tr:eq(2) > td:eq(1) > a > span').text() == getV('nick', ''));
  3057. $('td.tableheader').parent().after(
  3058. $('<tr>').append(
  3059. $('<td>').addClass('profilerow').attr({
  3060. id: 'actions',
  3061. colspan: '2',
  3062. align: 'center'
  3063. }).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>')
  3064. )
  3065. );
  3066. var historyLink = null;
  3067. if (versionHasLogger) {
  3068. historyLink = $('<span>').text('View History').css('cursor', 'pointer').click(function () {
  3069. $.get(OB_API_WEBSITE + '/?p=history&v=' + v + '&name=' + unick, function (data) {
  3070. $('#game_container').empty();
  3071. $('#game_container').html(data);
  3072. });
  3073. });
  3074. }
  3075. if (!self && alive) {
  3076. $('td.tableheader').append(
  3077. $('<span>').text(' | '),
  3078. historyLink,
  3079. $('<span>').text(' | '),
  3080. $('<span>').text('Actions').css('cursor', 'pointer').click(function () {
  3081. $('#actions').toggle();
  3082. })
  3083. );
  3084. } else {
  3085. $('td.tableheader').append(
  3086. $('<span>').text(' | '),
  3087. historyLink
  3088. );
  3089. }
  3090. if (parseInt(getPow('bninfo', 4, -1), 10) === 3 && inFam === 'None') {
  3091. $('#actions').html($('#actions').html() + ' | <a href="/BeO/webroot/index.php?module=Family&who=' + unick + '">Invite to Family</a>');
  3092. }
  3093. }
  3094. // ---------------- Linkify ----------------
  3095. // Messages
  3096. if (on_page('action=showMsg') && nn == 'center') {
  3097. var msgType = $('.tableheader:eq(1) > b > strong').text();
  3098. var msgType2 = $('.tableheader:eq(1) > b').text();
  3099. var msgTxt = '.thinline:eq(1) > tbody > tr:eq(4) > td';
  3100. var arr = $(msgTxt).html().split(' ');
  3101. 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!'];
  3102.  
  3103. var setArr = function (num) {
  3104. if (arr[num].substr(-1) == '.') {
  3105. return (arr[num] = '<a href="/user.php?nick=' + arr[num].match(/\w+/g)[0] + '"><b>' + arr[num].match(/\w+/g)[0] + '</b></a>.');
  3106. }
  3107. return (arr[num] = '<a href="/user.php?nick=' + arr[num].match(/\w+/g)[0] + '"><b>' + arr[num].match(/\w+/g)[0] + '</b></a>');
  3108. };
  3109.  
  3110. var WitnessMsg = new RegExp(linkify[7]); // Witness statement
  3111. if (WitnessMsg.test(msgType)) {
  3112. setArr(3);
  3113. setArr(5);
  3114. $(msgTxt).html(arr.join(' '));
  3115. }
  3116. var TnFMsg = new RegExp(linkify[3]); // Target not found
  3117. if (TnFMsg.test(msgType)) {
  3118. setArr(5);
  3119. $(msgTxt).html(arr.join(' '));
  3120. }
  3121. var HeistMsg = new RegExp(linkify[0]); // Route 66 heist
  3122. if (HeistMsg.test(msgType)) {
  3123. if (arr[2] == 'inviting') {
  3124. setArr(0);
  3125. setArr(13);
  3126. $(msgTxt).html(arr.join(' '));
  3127. } else {
  3128. $(msgTxt).html($(msgTxt).html());
  3129. }
  3130. }
  3131. var RaceMsg = new RegExp(linkify[4]); // Car Race invite
  3132. if (RaceMsg.test(msgType)) {
  3133. setArr(9);
  3134. arr[arr.length - 15] = '<a href="/races.php"><strong>' + arr[arr.length - 15];
  3135. arr[arr.length - 14] = arr[arr.length - 14] + '</strong></a>';
  3136. $(msgTxt).html(arr.join(' '));
  3137. }
  3138. var RaidMsg = new RegExp(linkify[13]); // Raid Notification
  3139. if (RaidMsg.test(msgType)) {
  3140. setArr(9);
  3141. 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>';
  3142. $(msgTxt).html(arr.join(' '));
  3143. }
  3144. var OCMsg = new RegExp(linkify[1]); // Organized Crime
  3145. if (OCMsg.test(msgType)) {
  3146. if (arr[2] == 'inviting') {
  3147. setArr(0);
  3148. setArr(arr.length - 8);
  3149. $(msgTxt).html(arr.join(' '));
  3150. } else {
  3151. $(msgTxt).html($(msgTxt).html());
  3152. }
  3153. }
  3154. var MOCMsg = new RegExp(linkify[2]); // Mega Organized Crime
  3155. if (MOCMsg.test(msgType2)) {
  3156. if (arr[2] == 'invited') {
  3157. setArr(0);
  3158. arr[arr.length - 8] = '<a href="/BeO/webroot/index.php?module=MegaOC"><strong>' + arr[arr.length - 8];
  3159. arr[arr.length - 7] = arr[arr.length - 7] + '</strong></a>';
  3160. $(msgTxt).html(arr.join(' '));
  3161. } else {
  3162. $(msgTxt).html($(msgTxt).html());
  3163. }
  3164. }
  3165. var KillMsg = new RegExp(linkify[6]); // Kill success
  3166. if (KillMsg.test(msgType)) {
  3167. setArr(2);
  3168. $(msgTxt).html(arr.join(' '));
  3169. }
  3170. var CondMsg = new RegExp(linkify[8]); // Condolences
  3171. if (CondMsg.test(msgType)) {
  3172. setArr(2);
  3173. setArr(arr.length - 15);
  3174. $(msgTxt).html(arr.join(' '));
  3175. }
  3176. var InvMsg = new RegExp(linkify[12]); // Invite
  3177. if (InvMsg.test(msgType)) {
  3178. setArr(8);
  3179. $(msgTxt).html(arr.join(' '));
  3180. }
  3181. }
  3182. // ---------------- Lackeys ----------------
  3183. if (on_page('module=Lackeys') && nn == 'div') {
  3184. // General
  3185. var logpath = 'table[data-info="log"] > tbody > tr';
  3186. var itemspath = 'table[data-info="items"] > tbody > tr[data-id]';
  3187. var credits = $('td[data-info="credits"]').text();
  3188. var money = $('td[data-info="money"]').text().replace(/,/g, '');
  3189. // Noodles
  3190. if (on_page('type=2') && nn == 'div') {
  3191. var carSuccess = parseInt(getV('carSuccess', 0), 10);
  3192. var carMoney = parseInt(getV('carMoney', 0), 10);
  3193.  
  3194. // Loop cars to grab values
  3195. var x = 0;
  3196. var totalCarval = 0;
  3197. $(itemspath).each(function () {
  3198. // grab value
  3199. var carVal = parseInt($(itemspath + ':eq(' + x + ') > td:eq(4)').text().replace(',', '').replace('$', ''), 10);
  3200. totalCarval += carVal;
  3201. ++x;
  3202. });
  3203.  
  3204. // Show total value of nicked cars
  3205. $('div.oheader:eq(2)').text($(itemspath).length + $('div.oheader:eq(2)').text()).append(
  3206. $('<span>').text('total value: $' + commafy(totalCarval))
  3207. );
  3208.  
  3209. // Save cars and value
  3210. $('table[data-info="items"] > tbody > tr > td > input[type="submit"]').click(function() {
  3211. setV('carSuccess', (x + carSuccess));
  3212. setV('carMoney', (totalCarval + carMoney));
  3213. });
  3214. }
  3215. // Sluggs
  3216. if (on_page('type=6') && nn == 'div') {
  3217. var sluggsHideLaughing = sets['sluggsHideLaughing'] === undefined ? true : sets['sluggsHideLaughing'];
  3218. var price = $('input#setting_bullets_max_price_price_6').val();
  3219.  
  3220. // commafy and alert money
  3221. var needed = (credits / 5) * (price * 1000);
  3222. var short = money.substr(1) - needed;
  3223. var enough = (short < 0) ? '<p style="color:red;">' + commafy(money) + ' ($' + commafy(short) + ')</p>' : '<p style="color:green;">' + commafy(money) + '</p>';
  3224. $('td[data-info="money"]').html(enough);
  3225.  
  3226. // Price per bullet
  3227. var x = 0;
  3228. $(logpath).each(function () {
  3229. // show price per bullet when Sluggs bought
  3230. // Let's see if we can put the regexes in a variable, makes it easier to edit/match them
  3231.  
  3232. var sluggs_bought_match_nl = /Sluggs kocht (\d+) kogels voor \$(\d+)/;
  3233. var sluggs_bought_match_com = /Sluggs bought (\d+) bullets for \$(\d+)/;
  3234.  
  3235. if (v == 'nl') {
  3236. if ($(logpath + ':eq(' + x + ') > td:eq(1)').html().replace(/,/g, '').match(sluggs_bought_match_nl) && x != logpath.length) {
  3237. var r = $(logpath + ':eq(' + x + ') > td:eq(1)').html().replace(/,/g, '').match(sluggs_bought_match_nl);
  3238. var ppb = Math.round(r[2] / r[1]);
  3239. $(logpath + ':eq(' + x + ') > td:eq(1)').html($(logpath + ':eq(' + x + ') > td:eq(1)').html() + ' ($' + ppb + '/kogel)');
  3240. }
  3241. ++x;
  3242. } else {
  3243. if ($(logpath + ':eq(' + x + ') > td:eq(1)').html().replace(/,/g, '').match(sluggs_bought_match_com) && x != logpath.length) {
  3244. var r = $(logpath + ':eq(' + x + ') > td:eq(1)').html().replace(/,/g, '').match(sluggs_bought_match_com);
  3245. var ppb = Math.round(r[2] / r[1]);
  3246. $(logpath + ':eq(' + x + ') > td:eq(1)').html($(logpath + ':eq(' + x + ') > td:eq(1)').html() + ' ($' + ppb + '/bullet)');
  3247. }
  3248. ++x;
  3249. }
  3250. });
  3251.  
  3252. // Hide useless entries
  3253. var hideLaughing = function(hide) {
  3254. setA('sets', 'sluggsHideLaughing', hide);
  3255. sluggsHideLaughing = hide;
  3256. x = 0;
  3257. $(logpath).each(function () {
  3258.  
  3259. var sluggs_laughs_match_nl = /Sluggs lacht om je lage limiet/;
  3260. var sluggs_laughs_match_com = /Sluggs is laughing at your measly limit/;
  3261.  
  3262. if (v == 'nl') {
  3263. if ($(logpath + ':eq(' + x + ') > td:eq(1)').html().match(sluggs_laughs_match_nl) && x != logpath.length) {
  3264. if (hide) {
  3265. $(this).hide();
  3266. } else {
  3267. $(this).show();
  3268. }
  3269. }
  3270. ++x;
  3271. } else {
  3272. if ($(logpath + ':eq(' + x + ') > td:eq(1)').html().match(sluggs_laughs_match_com) && x != logpath.length) {
  3273. if (hide) {
  3274. $(this).hide();
  3275. } else {
  3276. $(this).show();
  3277. }
  3278. }
  3279. ++x;
  3280. }
  3281. });
  3282. };
  3283. var hide_text = (v == 'nl' ? 'Verberg "Sluggs lacht om" meldingen' : 'Hide "Sluggs is laughing" entries');
  3284. $('div.oheader:last').append(
  3285. $('<span>').append(
  3286. $('<input>').attr({
  3287. id: 'cb',
  3288. type: 'checkbox'
  3289. }).click(function () {
  3290. hideLaughing($('#cb').is(':checked'));
  3291. }),
  3292. $('<label />').attr('for', 'cb').text(hide_text)
  3293. )
  3294. );
  3295. if (sluggsHideLaughing === true) {
  3296. $('#cb').prop('checked', true);
  3297. hideLaughing(true);
  3298. }
  3299. }
  3300. // Freekowtski
  3301. if (on_page('type=4') && nn == 'div') {
  3302. var x = 0;
  3303. $(logpath).each(function () {
  3304. // show price per unit when Freekowtski bought
  3305.  
  3306. var free_bought_match_nl = /Freekowtski heeft zojuist (\d+) (\w+) gekocht voor \$(\d+)/;
  3307. var free_bought_match_com = /Freekowtski just bought (\d+) of (\w+) for \$(\d+)/;
  3308.  
  3309. if (v == 'nl') {
  3310. if ($(logpath + ':eq(' + x + ') > td:eq(1)').html().replace(/,/g, '').match(free_bought_match_nl) && x != logpath.length) {
  3311. var r = $(logpath + ':eq(' + x + ') > td:eq(1)').html().replace(/,/g, '').match(free_bought_match_nl);
  3312. var ppu = Math.round(r[3] / r[1]);
  3313. $(logpath + ':eq(' + x + ') > td:eq(1)').html($(logpath + ':eq(' + x + ') > td:eq(1)').html() + ' ($' + commafy(ppu) + ' / eenheid)');
  3314. }
  3315. ++x;
  3316. } else {
  3317. if ($(logpath + ':eq(' + x + ') > td:eq(1)').html().replace(/,/g, '').match(free_bought_match_com) && x != logpath.length) {
  3318. var r = $(logpath + ':eq(' + x + ') > td:eq(1)').html().replace(/,/g, '').match(free_bought_match_com);
  3319. var ppu = Math.round(r[3] / r[1]);
  3320. $(logpath + ':eq(' + x + ') > td:eq(1)').html($(logpath + ':eq(' + x + ') > td:eq(1)').html() + ' ($' + commafy(ppu) + ' / unit)');
  3321. }
  3322. ++x;
  3323. }
  3324. });
  3325. }
  3326. // O'Rourke
  3327. if (on_page('type=3') && nn == 'div') {
  3328. var x = 0;
  3329. $(logpath).each(function () {
  3330. // show price per unit when O'Rourke bought
  3331.  
  3332. var rourke_bought_match_nl = /O'Rourke heeft zojuist (\d+) (\w+) gekocht voor \$(\d+)/;
  3333. var rourke_bought_match_com = /O'Rourke just bought (\d+) of (\w+) for \$(\d+)/;
  3334.  
  3335. if (v == 'nl') {
  3336. if ($(logpath + ':eq(' + x + ') > td:eq(1)').html().replace(/,/g, '').match(rourke_bought_match_nl) && x != logpath.length) {
  3337. var r = $(logpath + ':eq(' + x + ') > td:eq(1)').html().replace(/,/g, '').match(rourke_bought_match_nl);
  3338. var ppu = Math.round(r[3] / r[1]);
  3339. $(logpath + ':eq(' + x + ') > td:eq(1)').html($(logpath + ':eq(' + x + ') > td:eq(1)').html() + ' ($' + commafy(ppu) + ' / eenheid)');
  3340. }
  3341. ++x;
  3342. } else {
  3343. if ($(logpath + ':eq(' + x + ') > td:eq(1)').html().replace(/,/g, '').match(rourke_bought_match_com) && x != logpath.length) {
  3344. var r = $(logpath + ':eq(' + x + ') > td:eq(1)').html().replace(/,/g, '').match(rourke_bought_match_com);
  3345. var ppu = Math.round(r[3] / r[1]);
  3346. $(logpath + ':eq(' + x + ') > td:eq(1)').html($(logpath + ':eq(' + x + ') > td:eq(1)').html() + ' ($' + commafy(ppu) + ' / unit)');
  3347. }
  3348. ++x;
  3349. }
  3350. });
  3351. }
  3352. // Fire all button
  3353. $('input[data-action="addCredits"]').closest('td').css('width', '99%').after(
  3354. $('<td>').attr('align', 'right').append(
  3355. $('<input id="ob_fire_all" type="button" value="Fire all lackeys">').click(function() {
  3356. if (confirm('Are you sure you want to fire ALL lackeys?')) {
  3357. $('#ob_fire_all').val('Firing lackeys ...').prop('disabled', true);
  3358. var jailWarn = false;
  3359. var fireLackey = function (lackeyIndex) {
  3360. $.post('//' + document.location.hostname + 'BeO/webroot/?module=Lackeys&action=fire', { lackey: lackeyIndex }).done(function(data) {
  3361. if (data.indexOf('jail') !== -1) {
  3362. jailWarn = true;
  3363. }
  3364. if (lackeyIndex < 6) {
  3365. fireLackey(lackeyIndex + 1);
  3366. } else {
  3367. if (jailWarn) {
  3368. alert('At least one of your lackeys is in jail and cannot be fired!');
  3369. $('#ob_fire_all').val('Fire all lackeys').prop('disabled', false);
  3370. } else {
  3371. $('#ob_fire_all').val('Lackeys fired!');
  3372. }
  3373. }
  3374. });
  3375. };
  3376. fireLackey(1);
  3377. }
  3378. })
  3379. )
  3380. );
  3381. }
  3382. // ---------------- BRC ----------------
  3383. if ((on_page('prices.php') && nn == 'center') || (on_page('smuggling.php') && nn == 'center')) {
  3384. var carry_n, carry_b;
  3385. var bninfo = getV('bninfo', -1);
  3386. if (bninfo !== '' && bninfo != -1) { // extra checker for undefined crap
  3387. if (bninfo.search(/[^0-9]/) != -1) {
  3388. setV('bninfo', -1);
  3389. }
  3390. }
  3391. // grab Lex
  3392. var lex, lexDay, lexHour;
  3393. if ($('span#lexhelpsyou').length) {
  3394. var lex = parseInt($('span#lexhelpsyou').html().replace(/[^0-9]/g, ''), 10);
  3395. setV('lex', lex);
  3396. var BRCd = new Date();
  3397. lexDay = BRCd.getDay();
  3398. lexHour = BRCd.getHours();
  3399. setV('lexHour', lexHour);
  3400. setV('lexDay', lexDay);
  3401. } else {
  3402. lex = getV('lex', 0);
  3403. lexDay = getV('lexDay', -1);
  3404. lexHour = getV('lexHour', -1);
  3405. }
  3406.  
  3407. var fillBRC = function(n, b, mode) { // actually filling the forms
  3408. var values = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; // set defaults
  3409. // booze - narcs == maximum user can buy
  3410. // carry_b - carry_n == total user is carrying
  3411. // b_amount - n_amount == amount per item user is carrying
  3412. // b - n == item we want
  3413. if (n > -1 && !lnarcs && mode != 3) { // do we want narcs?
  3414. if (carry_n === 0) { // nothing in pocket, fill it all
  3415. values[7 + n] = narcs;
  3416. $('input[name="typedrugs"]:eq(1)').prop('checked', true); // buy
  3417. } else { // something in pocket
  3418. if (carry_n < narcs) { // we got space for more
  3419. if (n_amount[n] < narcs) { // not full of wanted
  3420. if (n_amount[n] != carry_n) { // there is unwanted stuff
  3421. for (i = 0; i <= 6; i++) {
  3422. if (i != n || mode == 1) { // only sell what we don't want
  3423. values[i + 7] = n_amount[i];
  3424. }
  3425. }
  3426. $('input[name="typedrugs"]:eq(0)').prop('checked', true); // sell
  3427. } else { // only carrying wanted narcs
  3428. values[7 + n] = narcs - carry_n; // if any, fill missing amount
  3429. $('input[name="typedrugs"]:eq(1)').prop('checked', true); // buy
  3430. }
  3431. } else { // full of wanted
  3432. if (mode > 0) { // CD/RP mode, sell all
  3433. values[7 + n] = n_amount[n];
  3434. $('input[name="typedrugs"]:eq(0)').prop('checked', true); // sell
  3435. }
  3436. }
  3437. } else { // we go too much, guess it was a good heist
  3438. for (i = 0; i <= 6; i++) { // check what we carry
  3439. if (mode === 0 && i == n) {
  3440. values[i + 7] = 0;
  3441. } else {
  3442. values[i + 7] = n_amount[i];
  3443. $('input[name="typedrugs"]:eq(0)').prop('checked', true); // sell
  3444. }
  3445. }
  3446. }
  3447. }
  3448. }
  3449. if (n == -1 && mode == 4 && !lnarcs) {
  3450. for (i = 0; i <= 6; i++) {
  3451. values[i + 7] = n_amount[i];
  3452. $('input[name="typedrugs"]:eq(0)').prop('checked', true); // sell
  3453. }
  3454. }
  3455.  
  3456. // check for scenario: failed selling narcs in high
  3457. var selling_n = 0;
  3458. for (i = 0; i <= 6; i++) {
  3459. selling_n += values[i + 7];
  3460. }
  3461. var fail_n = (carry_b === 0 && carry_n == narcs && mode === 0 && selling_n > 0) ? 1 : 0;
  3462.  
  3463. if (b > -1 && !fail_n && !lbooze && mode != 3) { // do we want booze? Or are we still selling narcs in high?
  3464. if (carry_b === 0) {
  3465. values[b] = booze; // nothing in pocket, fill it all
  3466. $('input[name="typebooze"]:eq(1)').prop('checked', true); // buy
  3467. } else {
  3468. if (carry_b < booze) { // we got space for more
  3469. if (b_amount[b] < booze) { // not full of wanted
  3470. if (b_amount[b] != carry_b) { // there is unwanted stuff
  3471. for (i = 0; i <= 6; i++) {
  3472. values[i] = b_amount[i];
  3473. }
  3474. $('input[name="typebooze"]:eq(0)').prop('checked', true); // sell
  3475. } else { // only carrying wanted narcs
  3476. if (mode == 2) {
  3477. values[b] = carry_b; // if any, fill missing amount
  3478. $('input[name="typebooze"]:eq(0)').prop('checked', true); // sell
  3479. } else {
  3480. values[b] = booze - carry_b; // if any, fill missing amount
  3481. $('input[name="typebooze"]:eq(1)').prop('checked', true); // buy
  3482. }
  3483. }
  3484. } else { // full of wanted
  3485. if (mode > 0) { // CD/RP mode, sell all
  3486. values[b] = b_amount[b];
  3487. $('input[name="typebooze"]:eq(0)').prop('checked', true); // sell
  3488. }
  3489. }
  3490. } else { // we go too much, guess it was a good heist
  3491. for (i = 0; i <= 6; i++) { // check what we carry
  3492. if (mode === 0 && i == b) {
  3493. values[i] = 0;
  3494. } else {
  3495. values[i] = b_amount[i];
  3496. $('input[name="typebooze"]:eq(0)').prop('checked', true); // sell
  3497. }
  3498. }
  3499. }
  3500. }
  3501. }
  3502. if (b == -1 && mode == 4 && !lbooze) {
  3503. for (i = 0; i <= 6; i++) {
  3504. values[i] = b_amount[i];
  3505. $('input[name="typebooze"]:eq(0)').prop('checked', true); // sell
  3506. }
  3507. }
  3508.  
  3509. // fill in the fields with the calculated values
  3510. var sorts = ['wine', 'cognac', 'whiskey', 'amaretto', 'beer', 'port', 'rum', 'morphine', 'heroin', 'opium', 'cocaine', 'marihuana', 'tabacco', 'glue'];
  3511. var start = (lbooze) ? 7 : 0;
  3512. var end = (lnarcs) ? 6 : 13;
  3513. for (i = start; i <= end; i++) {
  3514. var box = $('input[name="' + sorts[i] + '"]');
  3515. box.val(values[i]);
  3516. }
  3517.  
  3518. // focus
  3519. $('input[type=submit]').focus();
  3520. };
  3521.  
  3522. var highlightRow = function () {
  3523. $(this).css('backgroundColor', '#888');
  3524. };
  3525.  
  3526. var removeHighlight = function () {
  3527. $(this).css('backgroundColor', 'transparent');
  3528. };
  3529.  
  3530. var fillBRCForCity = function () {
  3531. fillBRC(parseInt($(this).attr('n'), 10), parseInt($(this).attr('b'), 10), 0);
  3532. };
  3533.  
  3534. var appBRC = function(BN) {
  3535. if (!lboth) {
  3536. var getInfo = $('div#info:eq(0)').text();
  3537. getInfo = getInfo.split('*');
  3538. var narc = getInfo[0];
  3539. var booze = getInfo[1];
  3540. var city = getInfo[2];
  3541. var plane = getInfo[3];
  3542. var fam = getInfo[4];
  3543. var lex = parseInt(getInfo[6], 10);
  3544. var lexHour = parseInt(getInfo[7], 10);
  3545. var lexDay = parseInt(getInfo[8], 10);
  3546.  
  3547. // extra city checker
  3548. if (on_page('smuggling.php') && nn == 'center') {
  3549. var smugCity = unsafeWindow.omerta.character.game.city();
  3550. for (i = 0; i < 8; i++) {
  3551. if (smugCity.search(cities[i]) != -1) {
  3552. city = i + 4;
  3553. setPow('bninfo', 2, city);
  3554. }
  3555. }
  3556. }
  3557. // calc profits per item per city
  3558. var lex = 1 + 0.01 * lex;
  3559. var j;
  3560. for (var nCityprofit = [], bCityprofit = [], i = 0; i <= 7; i++) { // get profit per single unit of b/n
  3561. for (nCityprofit[i] = [], bCityprofit[i] = [], j = 0; j <= 6; j++) { // price there - price here
  3562. nCityprofit[i].push(Math.round(BN[0][j][(i + 2)] * lex) - Math.round(BN[0][j][(city - 4 + 2)])); // -4 correction for city ID,
  3563. 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
  3564. }
  3565. nCityprofit[i].unshift(Math.max.apply(null, nCityprofit[i])); // most profit per unit in this city
  3566. bCityprofit[i].unshift(Math.max.apply(null, bCityprofit[i]));
  3567. }
  3568. // create BRC table
  3569. var table = $('<table>').addClass('thinline').attr('id', 'brc').css('width', '500').append(
  3570. $('<tr>').append(
  3571. $('<td>').addClass('tableheader').attr('colspan', '5').text('Best Run Calculator')
  3572. ),
  3573. $('<tr>').append(
  3574. $('<td>').attr({
  3575. colspan: '5',
  3576. height: '1'
  3577. }).css('background-color', '#000')
  3578. ),
  3579. $('<tr>').css({
  3580. 'border-bottom': '1px solid #000'
  3581. }).append(
  3582. $('<td>').html('&nbsp; City'),
  3583. $('<td>').html('&nbsp; Booze'),
  3584. $('<td>').html('&nbsp; Narc'),
  3585. $('<td>').html('&nbsp; Profit'),
  3586. $('<td>').html('&nbsp;')
  3587. )
  3588. );
  3589.  
  3590. // add city rows with individual profits
  3591. for (var allProfits = [], bestBN = [], i = 0; i <= 7; i++) {
  3592. var tr = $('<tr>').attr('id', '2row' + (i + 2));
  3593. tr.hover(highlightRow, removeHighlight);
  3594.  
  3595. var td = $('<td>').attr('colspan', '5').css({
  3596. 'border-bottom': '1px solid #000',
  3597. height: '19px'
  3598. });
  3599.  
  3600. // --Calc profits
  3601. if (i == city - 4) { // This is the current city
  3602. td.css('text-align', 'center');
  3603. td.html('<i>You are in ' + cities[i] + '</i>');
  3604. tr.append(td);
  3605. allProfits.push(0);
  3606. bestBN.push([0, 0]);
  3607. } 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
  3608. td.css('text-align', 'center');
  3609. td.html('<i>You can\'t fly to ' + cities[i] + '</i>');
  3610. tr.append(td);
  3611. allProfits.push(0);
  3612. bestBN.push([0, 0]);
  3613. } else { // Nothing wrong, clear to go
  3614. var bestNarc = nCityprofit[i][0] < 0 ? 0 : nCityprofit[i].lastIndexOf(nCityprofit[i][0]); // best, if any, narc?
  3615. var profitNarc = (bestNarc === 0) ? 0 : nCityprofit[i][bestNarc]; // profit per unit
  3616. profitNarc = profitNarc * narc;
  3617.  
  3618. var bestBooze = bCityprofit[i][0] < 0 ? 0 : bCityprofit[i].lastIndexOf(bCityprofit[i][0]); // best, if any, booze?
  3619. var profitBooze = (bestBooze === 0) ? 0 : bCityprofit[i][bestBooze]; // profit per unit
  3620. profitBooze = profitBooze * booze;
  3621.  
  3622. // calc travel cost
  3623. var travelPrices = [ // travel costs from A to B
  3624. [ 0, 600, 10350, 1575, 3600, 1350, 1050, 10800], // det
  3625. [ 600, 0, 11025, 2025, 3000, 1725, 1425, 11400], // chi
  3626. [10350, 11025, 0, 9075, 14025, 9450, 9750, 1875], // pal
  3627. [ 1575, 2025, 9075, 0, 5025, 375, 675, 9375], // ny
  3628. [ 3600, 3000, 14025, 5025, 0, 4650, 4350, 14400], // lv
  3629. [ 1350, 1725, 9450, 375, 4650, 0, 300, 9750], // phi
  3630. [ 1050, 1425, 9750, 675, 4350, 300, 0, 10050], // bal
  3631. [10800, 11400, 1875, 9375, 14400, 9750, 10050, 0] // cor
  3632. ]; // det chi pal ny lv phi bal cor
  3633. var travelCost = travelPrices[i][(city - 4)];
  3634. if (plane === 0) { // no plane => half travel cost
  3635. travelCost /= 2;
  3636. }
  3637.  
  3638. // Our total profit in this city
  3639. var totalProfit = (profitNarc + profitBooze) - Math.round(travelCost);
  3640.  
  3641. // save all profits in array for later
  3642. if (totalProfit < 0) {
  3643. bestBN.push([0, 0]); // push dummy to complete array
  3644. } else {
  3645. bestBN.push([bestNarc, bestBooze]);
  3646. }
  3647. var wnarc = (bestNarc === 0) ? 0 : bestNarc - 1;
  3648. var wbooze = (bestBooze === 0) ? 0 : bestBooze - 1;
  3649. var narcsell = (BN[0][wnarc][0] * narc) * lex;
  3650. var boozesell = (BN[1][wbooze][0] * booze) * lex;
  3651. 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
  3652. totalProfit = totalProfit - pay;
  3653. allProfits.push(totalProfit);
  3654.  
  3655. // What's the result
  3656. if (totalProfit < 0) { // no profit :(
  3657. td.css('text-align', 'center');
  3658. td.html('<i>You won\'t make any profit in ' + cities[i] + '</i>');
  3659. tr.append(td);
  3660. } else { // profit \o/
  3661. td.html('&nbsp;' + cities[i]);
  3662. td.attr('colspan', '1');
  3663. tr.append(td);
  3664. tr.append(
  3665. $('<td>').css({
  3666. 'border-left': '1px solid #000',
  3667. 'border-bottom': '1px solid #000'
  3668. }).html('&nbsp; ' + boozenames[bestBooze]),
  3669. $('<td>').css({
  3670. 'border-left': '1px solid #000',
  3671. 'border-bottom': '1px solid #000'
  3672. }).html(parseInt(narc, 10) === 0 ? 'NO NARCS' : '&nbsp; ' + narcnames[bestNarc]),
  3673. $('<td>').css({
  3674. 'border-left': '1px solid #000',
  3675. 'border-bottom': '1px solid #000'
  3676. }).html('&nbsp; $' + commafy(totalProfit))
  3677. );
  3678.  
  3679. if (on_page('smuggling.php') && nn == 'center') { // we need JS links @ smuggling and don't want to waste clicks
  3680. var key = [0, 4, 6, 1, 2, 3, 5]; // convert b/n - bot prices order to smuggling order
  3681. var n1 = key[bestNarc - 1];
  3682. var b1 = key[bestBooze - 1];
  3683.  
  3684. tr.append(
  3685. $('<td>').css({
  3686. 'border-left': '1px solid #000',
  3687. 'border-bottom': '1px solid #000'
  3688. }).html('&nbsp;').append(
  3689. $('<span>').attr({
  3690. id: 'go' + i,
  3691. n: n1,
  3692. b: b1
  3693. }).css({
  3694. 'font-weight': 'inherit',
  3695. 'text-align': 'center',
  3696. cursor: 'pointer'
  3697. }).text('Go!').click(fillBRCForCity)
  3698. )
  3699. );
  3700. } else { // we need to GET to smuggling too
  3701. tr.append(
  3702. $('<td>').css({
  3703. 'border-left': '1px solid #000',
  3704. 'border-bottom': '1px solid #000'
  3705. }).html('&nbsp;').append(
  3706. $('<a>').attr({
  3707. id: 'go' + i,
  3708. href: '/smuggling.php?action=go&n=' + (bestNarc - 1) + '&b=' + (bestBooze - 1)
  3709. }).css({
  3710. 'font-weight': 'inherit',
  3711. 'text-align': 'center',
  3712. cursor: 'pointer'
  3713. }).text('Go!')
  3714. )
  3715. );
  3716. }
  3717. }
  3718. }
  3719. table.append(tr);
  3720. }
  3721. // add lex row
  3722. if (lex > 1) {
  3723. var lexDate = new Date();
  3724. table.append(
  3725. $('<tr>').append(
  3726. $('<td>').attr('colspan', '5').css({
  3727. 'text-align': 'center',
  3728. 'font-size': '10px'
  3729. }).text('Lex Level: ' + parseInt((lex - 1) * 100, 10) + ' - Seen ' + ((lexDate.getDay() != lexDay) ? '1 Day ago' : lexDate.getHours() - lexHour + ' Hours ago'))
  3730. )
  3731. );
  3732. }
  3733. // add table to page
  3734. if (on_page('prices.php') && nn == 'center') {
  3735. if ($('#brc').length === 0) {
  3736. $('#game_container').append(
  3737. $('<br />'),
  3738. table
  3739. );
  3740. }
  3741. } else {
  3742. if ($('#brc').length === 0) {
  3743. $('#game_container').append(
  3744. $('<br />'),
  3745. table
  3746. );
  3747. }
  3748. }
  3749. // bold-ify Best Run
  3750. var bestRun = allProfits.lastIndexOf(Math.max.apply(null, allProfits));
  3751. $('#brc > tbody > tr:eq(' + (3 + bestRun) + ')').css('font-weight', 'bold');
  3752.  
  3753. if (on_page('smuggling.php') && nn == 'center') {
  3754. var AF = function (sel, Xn, Xb) {
  3755. sel = parseInt(sel, 10);
  3756. var n = -1;
  3757. var b = -1;
  3758. // assemble info for AF
  3759. inputs = $('input');
  3760. var bn_xp = '.smuggling-header';
  3761. var bn_text = $(bn_xp).html().split('|');
  3762.  
  3763. cash = parseInt(bn_text[0].replace(/[^0-9.]/g, ''), 10);
  3764. booze = parseInt(bn_text[1].replace(/[^0-9.]/g, ''), 10); // max amount user can carry
  3765. narcs = parseInt(bn_text[2].replace(/[^0-9.]/g, ''), 10);
  3766.  
  3767. var b_amount = [0, 0, 0, 0, 0, 0, 0];
  3768. var n_amount = [0, 0, 0, 0, 0, 0, 0]; // what is user carrying
  3769. var xpb = 'table.thinline > tbody > tr:eq(';
  3770. var xpn = 'table.thinline:eq(1) > tbody > tr:eq(';
  3771. for (i = 0; i <= 13; i++) { // define how much of this item is being carried
  3772. if (i < 7 && !lbooze) {
  3773. b_amount[i] = parseInt($(xpb + (i + 3) + ') > td:eq(2)').text(), 10);
  3774. }
  3775. if (i > 6 && !lnarcs) {
  3776. n_amount[(i - 7)] = parseInt($(xpn + (i - 4) + ') > td:eq(2)').text(), 10);
  3777. }
  3778. }
  3779. carry_n = array_sum(n_amount);
  3780. carry_b = array_sum(b_amount); // how much is the user carrying already
  3781. // which item do we want?
  3782. key = [0, 4, 6, 1, 2, 3, 5];
  3783. if (sel === 0) { // Calc for Best Run
  3784. n = key[(bestBN[bestRun][0] - 1)]; // this trick works, even I'm amazed
  3785. b = key[(bestBN[bestRun][1] - 1)];
  3786. if ((carry_n > 0 || carry_b > 0) && Math.max.apply(Math, allProfits) === 0) {
  3787. // HACK: in this scenario we're in a high where no other
  3788. // cities would generate any profit. Just pretend we're using
  3789. // RP mode so all units get sold.
  3790. sel = 2;
  3791. }
  3792. }
  3793. if (sel == 1) { // CD Run
  3794. for (i = 0; i <= 6; i++) {
  3795. var nItem = parseInt(BN[0][i][(city - 4 + 2)], 10);
  3796. var highNarc = ((i === 0) ? nItem : ((highNarc > nItem) ? highNarc : nItem));
  3797. if (highNarc == nItem) {
  3798. n = i;
  3799. }
  3800. var bItem = parseInt(BN[1][i][(city - 4 + 2)], 10);
  3801. var highBooze = ((i === 0) ? bItem : ((highBooze > bItem) ? highBooze : bItem));
  3802. if (highBooze == bItem) {
  3803. b = i;
  3804. }
  3805. }
  3806. n = key[n];
  3807. b = key[b];
  3808. }
  3809. if (sel == 2) { // RP Run
  3810. for (i = 0; i <= 6; i++) {
  3811. var nItem = parseInt(BN[0][i][(city - 4 + 2)], 10);
  3812. var lowNarc = ((i === 0) ? nItem : ((lowNarc < nItem) ? lowNarc : nItem));
  3813. if (lowNarc == nItem) {
  3814. n = i;
  3815. }
  3816. var bItem = parseInt(BN[1][i][(city - 4 + 2)], 10);
  3817. var lowBooze = ((i === 0) ? bItem : ((lowBooze < bItem) ? lowBooze : bItem));
  3818. if (lowBooze == bItem) {
  3819. b = i;
  3820. }
  3821. }
  3822.  
  3823. n = key[n];
  3824. b = key[b];
  3825.  
  3826. /*
  3827. * Don't fill in if we can't earn RP and AF would want to buy
  3828. * Omerta sometimes won't display "NOW" when rp can be earned for b/n actions.
  3829. * it just displays "The next time you can earn rank points from buying [booze|narcs] is<end>"
  3830. * we'll handle that case too.
  3831. */
  3832. if (!lbooze) {
  3833. 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) {
  3834. b = -1;
  3835. }
  3836. }
  3837. if (!lnarcs) {
  3838. 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) {
  3839. n = -1;
  3840. }
  3841. }
  3842. }
  3843. if (sel == 3) { // None
  3844. n = b = -1;
  3845. }
  3846. if (document.location.href.indexOf('action=go') !== -1) { // user manual override using external Go! link
  3847. n = key[(GetParam('n'))];
  3848. b = key[(GetParam('b'))];
  3849. }
  3850.  
  3851. // overrule with hotkeys [ ] =
  3852. if (Xn) {
  3853. n = -1;
  3854. }
  3855. if (Xb) {
  3856. b = -1;
  3857. }
  3858.  
  3859. // we know our n and b => fill it in!
  3860. fillBRC(n, b, sel);
  3861. };
  3862. AF(getInfo[5]);
  3863.  
  3864. var AFtop = parseInt(getV('AFtop', '225'), 10);
  3865. var AFleft = parseInt(getV('AFleft', '300'), 10);
  3866. if (!$('#AF').length) {
  3867. if ((sets['af_position'] || 'floating') == 'floating') {
  3868. $('#game_container').append(
  3869. $('<div>').addClass('BRCinfo').attr({
  3870. id: 'AF'
  3871. }).css({
  3872. top: AFtop,
  3873. left: AFleft
  3874. })
  3875. );
  3876. } else {
  3877. var AFNode = $('<div>').attr({
  3878. id: 'AF'
  3879. });
  3880. $('.smuggling-header').prepend(AFNode);
  3881.  
  3882. }
  3883.  
  3884. $('#AF').append(
  3885. $('<center>').text('Auto-Fill').css('font-weight', 'bold'),
  3886. $('<hr>').css({
  3887. color: 'gray'
  3888. }),
  3889. $('<span>').append(
  3890. $('<input>').attr({
  3891. id: 'brc0',
  3892. type: 'radio',
  3893. name: 'brc'
  3894. }).click(function () {
  3895. AF(0);
  3896. try {
  3897. setV('brcAF', 0);
  3898. } catch (e) {}
  3899. }),
  3900. $('<label>').attr({
  3901. id: 'a1',
  3902. for: 'brc0',
  3903. acceskey: '8',
  3904. title: 'Fill in the most profitable b/n (Hotkey: 8 )'
  3905. }).text('Best: (8)')
  3906. ),
  3907. $('<span>').append(
  3908. $('<br />'),
  3909. $('<input>').attr({
  3910. id: 'brc1',
  3911. type: 'radio',
  3912. name: 'brc'
  3913. }).click(function () {
  3914. AF(1);
  3915. try {
  3916. setV('brcAF', 1);
  3917. } catch (e) {}
  3918. }),
  3919. $('<label>').attr({
  3920. id: 'a2',
  3921. for: 'brc1',
  3922. acceskey: '9',
  3923. title: 'Fill in the most expensive b/n (Hotkey: 9 )'
  3924. }).text('CD: (9)')
  3925. ),
  3926. $('<span>').append(
  3927. $('<br />'),
  3928. $('<input>').attr({
  3929. id: 'brc2',
  3930. type: 'radio',
  3931. name: 'brc'
  3932. }).click(function () {
  3933. AF(2);
  3934. try {
  3935. setV('brcAF', 2);
  3936. } catch (e) {}
  3937. }),
  3938. $('<label>').attr({
  3939. id: 'a3',
  3940. for: 'brc2',
  3941. acceskey: '0',
  3942. title: 'Fill in the cheapest b/n (Hotkey: 0 )'
  3943. }).text('RP: (0)')
  3944. ),
  3945. $('<span>').append(
  3946. $('<br />'),
  3947. $('<input>').attr({
  3948. id: 'brc3',
  3949. type: 'radio',
  3950. name: 'brc'
  3951. }).click(function () {
  3952. AF(3);
  3953. try {
  3954. setV('brcAF', 3);
  3955. } catch (e) {}
  3956. }),
  3957. $('<label>').attr({
  3958. id: 'a4',
  3959. for: 'brc3',
  3960. acceskey: '-',
  3961. title: 'Don\'t fill anything (Hotkey: - )'
  3962. }).text('None: (-)')
  3963. )
  3964. );
  3965. }
  3966. if ((sets['af_position'] || 'floating') == 'floating') {
  3967. $(function () {
  3968. $('#AF').draggable();
  3969. });
  3970. $('#AF').mouseup(function () {
  3971. // alert('Set the x and y values using GM_getValue.');
  3972. var divOffset = $('#AF').offset();
  3973. var left = divOffset.left;
  3974. var top = divOffset.top;
  3975. setV('AFleft', left);
  3976. setV('AFtop', top);
  3977. });
  3978. } else {
  3979. // show static AF settings in one row
  3980. $('#AF hr, #AF br').remove();
  3981. }
  3982.  
  3983. var mode = getV('brcAF', 0);
  3984.  
  3985. if ($('#do_n').length === 0) {
  3986. $('.smuggling-header').append(
  3987. $('<br />'),
  3988. $('<span>').attr({
  3989. id: 'do_n',
  3990. title: 'AutoFill just narcs according to selected BRC mode (Hotkey: [ )',
  3991. acceskey: '['
  3992. }).css('cursor', 'pointer').text('Narcs'),
  3993. $('<span>').text(' | '),
  3994. $('<span>').attr({
  3995. id: 'do_b',
  3996. title: 'AutoFill just booze according to selected BRC mode (Hotkey: ] )',
  3997. acceskey: ']'
  3998. }).css('cursor', 'pointer').text('Booze'),
  3999. $('<span>').text(' | '),
  4000. $('<span>').attr({
  4001. id: 'do_sell',
  4002. title: 'Sell all you have (Hotkey: = )',
  4003. acceskey: '='
  4004. }).css('cursor', 'pointer').text('Sell All'),
  4005. $('<br />')
  4006. );
  4007. }
  4008. $('#do_n').click(function () {
  4009. AF(getV('brcAF', 0), 0, 1);
  4010. });
  4011. $('#do_b').click(function () {
  4012. AF(getV('brcAF', 0), 1, 0);
  4013. });
  4014. $('#do_sell').click(function () {
  4015. AF(4, 1, 1);
  4016. });
  4017.  
  4018. $('input#brc' + mode).prop('checked', true);
  4019. }
  4020. }
  4021. };
  4022. if (getV('bninfo', -1) > 0) { // do we have info data?
  4023. // create info div to transfer data to XHR function
  4024. var narc = getPow('bninfo', 0, -1);
  4025. var booze = getPow('bninfo', 1, -1);
  4026. var city = getPow('bninfo', 2, -1);
  4027. var plane = getPow('bninfo', 3, -1);
  4028. var fam = getPow('bninfo', 4, -1);
  4029.  
  4030. if ($('#info').length === 0) {
  4031. $('#game_container').append(
  4032. $('<div>').attr('id', 'info').css('display', 'none').text(narc + '*' + booze + '*' + city + '*' + plane + '*' + fam + '*' + getV('brcAF', 0) + '*' + lex + '*' + lexHour + '*' + lexDay)
  4033. );
  4034. }
  4035.  
  4036. // get all prices
  4037. var i;
  4038. if (on_page('prices.php') && nn == 'center') { // prices are on the page
  4039. var j, k;
  4040. for (var BN = [], i = 0; i <= 1; i++) { // B/N
  4041. for (BN[i] = [], j = 0; j <= 6; j++) { // type
  4042. for (BN[i][j] = [], k = 0; k <= 7; k++) { // city
  4043. 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));
  4044. }
  4045. BN[i][j].unshift(Math.min.apply(null, BN[i][j])); // get min
  4046. BN[i][j].unshift(Math.max.apply(null, BN[i][j])); // get max
  4047. }
  4048. }
  4049. appBRC(BN);
  4050. } else {
  4051. var parsePrices = function (dom) {
  4052. for (var BN = [], i = 0; i <= 1; i++) { // B/N
  4053. for (BN[i] = [], j = 0; j <= 6; j++) { // type
  4054. for (BN[i][j] = [], k = 0; k <= 7; k++) {
  4055. BN[i][j].push(parseInt(dom.getElementsByTagName((i === 0 ? (narcnames[(j + 1)]).replace('abacco', 'obacco') : boozenames[(j + 1)]).toLowerCase())[k].textContent, 10)); // city
  4056. }
  4057. BN[i][j].unshift(Math.min.apply(null, BN[i][j])); // get min
  4058. BN[i][j].unshift(Math.max.apply(null, BN[i][j])); // get max
  4059. }
  4060. }
  4061. appBRC(BN); // send prices to BRC function
  4062. };
  4063. $.get('//' + document.location.hostname + '/BeO/webroot/index.php?module=API&action=smuggling_prices', parsePrices);
  4064. }
  4065. }
  4066.  
  4067. if (on_page('prices.php') && nn == 'center') {
  4068. var i, j, k;
  4069. var BN;
  4070. if (typeof BN == 'undefined') { // see if prices are grabbed already
  4071. for (BN = [], i = 0; i <= 1; i++) { // B/N
  4072. for (BN[i] = [], j = 0; j <= 6; j++) { // type
  4073. for (BN[i][j] = [], k = 0; k <= 7; k++) { // city
  4074. 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));
  4075. }
  4076. BN[i][j].unshift(Math.min.apply(null, BN[i][j])); // get min
  4077. BN[i][j].unshift(Math.max.apply(null, BN[i][j])); // get max
  4078. }
  4079. }
  4080. }
  4081.  
  4082. var highlightPriceRow = function () {
  4083. $(this).css('backgroundColor', '#888');
  4084. $('#' + (i ? 0 : 1) + 'row' + k).css('backgroundColor', '#888');
  4085. };
  4086.  
  4087. var removeHighlightPriceRow = function () {
  4088. $(this).css('backgroundColor', 'transparent');
  4089. $('#' + (i ? 0 : 1) + 'row' + k).css('backgroundColor', 'transparent');
  4090. };
  4091.  
  4092. for (i = 0; i <= 1; i++) {
  4093. for (j = 0; j <= 6; j++) {
  4094. for (k = 2; k <= 9; k++) {
  4095. if (j === 0) { // add mouseover effects
  4096. var row = $('#game_container center:eq(' + i + ') > table > tbody > tr:eq(' + (k + 1) + ')');
  4097. row.attr('id', i + 'row' + k);
  4098. row.css('borderTop', '1px solid #000');
  4099. row.hover(highlightPriceRow, removeHighlightPriceRow);
  4100. }
  4101.  
  4102. var item = $('#game_container center:eq(' + i + ') > table > tbody > tr:eq(' + (k + 1) + ') > td:eq(' + (j + 1) + ')');
  4103. item.css({
  4104. 'border-top': '1px solid #000',
  4105. 'text-align': 'center',
  4106. width: '12%'
  4107. });
  4108. if (j % 2 === 0) { // add colors to rows
  4109. item.css('backgroundColor', '#B0B0B0');
  4110. }
  4111. if (BN[i][j][k] == BN[i][j][0]) { // HL max
  4112. item.css('fontWeight', 'bold');
  4113. item.css('color', '#FF0000');
  4114. }
  4115. if (BN[i][j][k] == BN[i][j][1]) { // HL min
  4116. item.css('fontWeight', 'bold');
  4117. item.css('color', '#16E54A');
  4118. }
  4119. if (j == 5 && i === 0) { // bold-ify cocaine
  4120. item.css('fontWeight', 'bold');
  4121. }
  4122. }
  4123. }
  4124. }
  4125. }
  4126. }
  4127. // ---------------- Smuggling ----------------
  4128. if (on_page('smuggling.php') && nn == 'center') {
  4129. var lbooze = 0,
  4130. lnarcs = 0,
  4131. lboth = 0,
  4132. lex = 0;
  4133.  
  4134. // check if lackeys on
  4135. if ($('#game_container').html().match('/orourke.jpg') !== null && $('#game_container').html().match('/freekowski.jpg') !== null) {
  4136. lboth = 1;
  4137. } else if ($('#game_container').html().match('/orourke.jpg') !== null) {
  4138. lbooze = 1;
  4139. } else if ($('#game_container').html().match('/freekowski.jpg') !== null) {
  4140. lnarcs = 1;
  4141. }
  4142.  
  4143. // get input fields
  4144. var inputs = $('input');
  4145. var bn_xp = '.smuggling-header';
  4146. var bn_text = $(bn_xp).html().split('<br>');
  4147.  
  4148. var cash = parseInt(bn_text[0].replace(/[^0-9.]/g, ''), 10);
  4149. var booze = parseInt(bn_text[1].match(/\d+/), 10); // max amount user can carry
  4150. var narcs = parseInt(bn_text[2].match(/\d+/), 10);
  4151. var lexD = new Date();
  4152. var lexDay = lexD.getDay();
  4153. var lexHour = lexD.getHours();
  4154. if (bn_text[6]) {
  4155. var lex = parseInt(bn_text[6].match(/\d+/), 10);
  4156. setV('lex', lex);
  4157. setV('lexHour', lexHour);
  4158. setV('lexDay', lexDay);
  4159. } else {
  4160. setV('lex', 0);
  4161. setV('lexHour', lexHour);
  4162. setV('lexDay', lexDay);
  4163. }
  4164.  
  4165. var b_amount = [0, 0, 0, 0, 0, 0]; // what is user carrying
  4166. var n_amount = [0, 0, 0, 0, 0, 0];
  4167.  
  4168. var xpb = 'table.thinline > tbody > tr:eq(';
  4169. var xpn = 'table.thinline:eq(1) > tbody > tr:eq(';
  4170.  
  4171. if (!lboth) {
  4172. for (var i = 0; i <= 13; i++) { // add click to fill stuff and hotkeys
  4173. if (i < 7 && !lbooze) { // booze
  4174. var x = i + 3;
  4175. var bname = $(xpb + x + ') > td:eq(0)').text();
  4176. b_amount[i] = parseInt($(xpb + x + ') > td:eq(2)').html(), 10); // define how much of this item is being carried
  4177. $(xpb + x + ') > td:eq(0)').empty();
  4178. $(xpb + x + ') > td:eq(0)').append(
  4179. $('<span>').attr({
  4180. id: 'bh' + i,
  4181. index: i,
  4182. acceskey: (i + 1),
  4183. title: 'Fill in this booze (Hotkey: ' + (i + 1) + ')'
  4184. }).css('cursor', 'pointer').text((i + 1) + ' ' + bname).click(function () {
  4185. var i = parseInt($(this).attr('index'), 10);
  4186. var inpt = $('input[type="text"]');
  4187. for (var j = 0; j <= 6; j++) { // reset form
  4188. if (j != i) {
  4189. inpt[j + 1].value = 0;
  4190. }
  4191. }
  4192. var total = array_sum(b_amount);
  4193. var missing = booze - b_amount[i];
  4194. var value = parseInt(inpt[(i + 1)].value, 10);
  4195. if (b_amount[i] === 0 && total < booze) {
  4196. if (value === 0) {
  4197. inpt[(i + 1)].value = booze;
  4198. $('input[type="radio"]:eq(1)').prop('checked', true);
  4199. } else {
  4200. inpt[(i + 1)].value = 0;
  4201. }
  4202. } else if (b_amount[i] == booze) {
  4203. if (value === 0) {
  4204. inpt[(i + 1)].value = booze;
  4205. $('input[type="radio"]:eq(0)').prop('checked', true);
  4206. } else {
  4207. inpt[(i + 1)].value = 0;
  4208. }
  4209. } else if (b_amount[i] < booze && total < booze) {
  4210. if (value === 0) {
  4211. inpt[(i + 1)].value = missing;
  4212. $('input[type="radio"]:eq(1)').prop('checked', true);
  4213. } else if (value == missing) {
  4214. inpt[(i + 1)].value = b_amount[i];
  4215. $('input[type="radio"]:eq(0)').prop('checked', true);
  4216. } else {
  4217. inpt[(i + 1)].value = 0;
  4218. }
  4219. } else if (n_amount[i - 9] > booze) {
  4220. if (value === 0) {
  4221. inpt[(i + 1)].value = b_amount[i];
  4222. $('input[type="radio"]:eq(0)').prop('checked', true);
  4223. } else {
  4224. inpt[(i + 1)].value = 0;
  4225. }
  4226. } else if (b_amount[i] < booze && total > booze) {
  4227. if (value === 0) {
  4228. inpt[(i + 1)].value = b_amount[i];
  4229. $('input[type="radio"]:eq(0)').prop('checked', true);
  4230. } else {
  4231. inpt[(i + 1)].value = 0;
  4232. }
  4233. }
  4234. $('input[type=submit]').focus();
  4235. })
  4236. );
  4237. }
  4238. if (i > 6 && !lnarcs) { // narcs
  4239. var x = i - 4;
  4240. var nname = $(xpn + x + ') > td:eq(0)').text();
  4241. n_amount[(i - 7)] = parseInt($(xpn + x + ') > td:eq(2)').html(), 10); // define how much of this item is being carried
  4242. $(xpn + x + ') > td:eq(0)').empty();
  4243. $(xpn + x + ') > td:eq(0)').append(
  4244. $('<span>').attr({
  4245. id: 'nh' + i,
  4246. index: i,
  4247. title: 'Fill in this narc'
  4248. }).css('cursor', 'pointer').text(nname).click(function () {
  4249. var i = parseInt($(this).attr('index'), 10);
  4250. var inpt = $('input[type="text"]');
  4251. for (var j = 0; j <= 6; j++) { // reset form
  4252. if (j != i - 7) {
  4253. if (lbooze) {
  4254. inpt[j + 1].value = 0;
  4255. } else {
  4256. inpt[j + 8].value = 0;
  4257. }
  4258. }
  4259. }
  4260. var total = array_sum(n_amount);
  4261. var missing = narcs - n_amount[i - 7];
  4262. var value;
  4263. if (lbooze) {
  4264. value = parseInt(inpt[i - 6].value, 10);
  4265. } else {
  4266. value = parseInt(inpt[(i + 1)].value, 10);
  4267. }
  4268. if (n_amount[i - 7] === 0 && total < narcs) {
  4269. if (value === 0) {
  4270. if (lbooze) {
  4271. inpt[i - 6].value = narcs;
  4272. $('input[type="radio"]:eq(1)').prop('checked', true);
  4273. } else {
  4274. inpt[(i + 1)].value = narcs;
  4275. $('input[type="radio"]:eq(3)').prop('checked', true);
  4276. }
  4277. } else {
  4278. inpt[(i + 1)].value = 0;
  4279. }
  4280. } else if (n_amount[i - 7] == narcs) {
  4281. if (value === 0) {
  4282. if (lbooze) {
  4283. inpt[i - 6].value = narcs;
  4284. $('input[type="radio"]:eq(0)').prop('checked', true);
  4285. } else {
  4286. inpt[(i + 1)].value = narcs;
  4287. $('input[type="radio"]:eq(2)').prop('checked', true);
  4288. }
  4289. } else {
  4290. inpt[(i + 1)].value = 0;
  4291. }
  4292. } else if (n_amount[i - 7] < narcs && total < narcs) {
  4293. if (value === 0) {
  4294. if (lbooze) {
  4295. inpt[i - 6].value = missing;
  4296. $('input[type="radio"]:eq(1)').prop('checked', true);
  4297. } else {
  4298. inpt[(i + 1)].value = missing;
  4299. $('input[type="radio"]:eq(3)').prop('checked', true);
  4300. }
  4301. } else if (value == missing) {
  4302. if (lbooze) {
  4303. inpt[i - 6].value = n_amount[i - 7];
  4304. $('input[type="radio"]:eq(0)').prop('checked', true);
  4305. } else {
  4306. inpt[(i + 1)].value = n_amount[i - 7];
  4307. $('input[type="radio"]:eq(3)').prop('checked', true);
  4308. }
  4309. } else {
  4310. inpt[(i + 1)].value = 0;
  4311. }
  4312. } else if (n_amount[i - 7] > narcs) {
  4313. if (value === 0) {
  4314. if (lbooze) {
  4315. inpt[i - 6].value = n_amount[i - 7];
  4316. $('input[type="radio"]:eq(0)').prop('checked', true);
  4317. } else {
  4318. inpt[(i + 1)].value = n_amount[i - 7];
  4319. $('input[type="radio"]:eq(3)').prop('checked', true);
  4320. }
  4321. } else {
  4322. inpt[(i + 1)].value = 0;
  4323. }
  4324. } else if (b_amount[i] < narcs && total > narcs) {
  4325. if (value === 0) {
  4326. if (lbooze) {
  4327. inpt[i - 6].value = n_amount[i - 7];
  4328. $('input[type="radio"]:eq(0)').prop('checked', true);
  4329. } else {
  4330. inpt[(i + 1)].value = n_amount[i - 7];
  4331. $('input[type="radio"]:eq(2)').prop('checked', true);
  4332. }
  4333. } else {
  4334. inpt[(i + 1)].value = 0;
  4335. }
  4336. }
  4337. $('input[type=submit]').focus();
  4338. })
  4339. );
  4340. }
  4341. }
  4342. }
  4343.  
  4344. var inp = $('input[name="typebooze"], input[name="typedrugs"]');
  4345. inp.each(function () {
  4346. $(this).click(function () {
  4347. if ($('input[type=submit]').length) {
  4348. $('input[type=submit]').focus();
  4349. }
  4350. });
  4351. });
  4352.  
  4353. // visual fix
  4354. if (lnarcs) {
  4355. $('form > table > tbody > tr:eq(1) > td:eq(1)').prepend(
  4356. $('<br />'),
  4357. $('<br />')
  4358. );
  4359. $('table.thinline:eq(1)').append(
  4360. $('<br />')
  4361. );
  4362. }
  4363. if (lbooze) {
  4364. $('form > table > tbody > tr:eq(1) > td:eq(0)').prepend(
  4365. $('<br />'),
  4366. $('<br />')
  4367. );
  4368. $('table.thinline:eq(0)').append(
  4369. $('<br />')
  4370. );
  4371. }
  4372.  
  4373. // create more efficient info text
  4374. var str = $('<span>').text('Pocket: $ ' + commafy(cash) + ' | Booze: ' + booze + ' | Narcs: ' + narcs + ' | Lex: ' + lex);
  4375. $(bn_xp).html(str).append(
  4376. $('<br />'),
  4377. $('<a>').attr({
  4378. href: 'prices.php',
  4379. target: 'main'
  4380. }).text('Current Booze/Narcotics Prices')
  4381. );
  4382. if (!lboth) {
  4383. $('input[type=submit]').focus(); // focus captcha field
  4384. }
  4385. }
  4386.  
  4387. if (on_page('module=travel')) {
  4388. if (notificationsArray['Travel'] !== undefined) {
  4389. notificationsArray['Travel'].close();
  4390. delete notificationsArray['Travel'];
  4391. }
  4392. }
  4393.  
  4394. // ---------------- Crime Page ----------------
  4395. if (on_page('module=Crimes') && nid == 'module_Crimes') {
  4396. if (notificationsArray['Crime'] !== undefined) {
  4397. notificationsArray['Crime'].close();
  4398. delete notificationsArray['Crime'];
  4399. }
  4400. // Grab money stolen
  4401. var moneyStolenText = $('#game_container').text().trim();
  4402. if (moneyStolenText.match(/\$ ([,\d]+)/) !== null) {
  4403. var oldValue = parseInt(getV('crimeMoney', 0), 10);
  4404. var sum = parseInt(moneyStolenText.match(/\$ ([,\d]+)/)[1].replace(',', ''), 10);
  4405. setV('crimeMoney', (sum + oldValue));
  4406.  
  4407. var totalSuccess = parseInt(getV('crimeSuccess', 0), 10);
  4408. ++totalSuccess;
  4409. setV('crimeSuccess', totalSuccess);
  4410. }
  4411. // focus and highlight last crime option
  4412. $('#crime-choices .popup-place-wrapper:last').addClass('active');
  4413. $('#crime-choices button:last').focus();
  4414. }
  4415.  
  4416. // ---------------- Cars Page ----------------
  4417. if (on_page('module=Cars') && nid == 'module_Cars') {
  4418. // Close notifications
  4419. if (notificationsArray['Car'] !== undefined) {
  4420. notificationsArray['Car'].close();
  4421. delete notificationsArray['Car'];
  4422. }
  4423. // Grab value of stolen car (does not include cars stolen by lackeys)
  4424. var carValText = $('#game_container').text().trim();
  4425. if (carValText.match(/\$ ([,\d]+)/) !== null) {
  4426. var oldValue = parseInt(getV('carMoney', 0), 10);
  4427. var sum = parseInt(carValText.match(/\$ ([,\d]+)/)[1].replace(',', ''), 10);
  4428. setV('carMoney', (sum + oldValue));
  4429. var totalSuccess = parseInt(getV('carSuccess', 0), 10);
  4430. ++totalSuccess;
  4431. setV('carSuccess', totalSuccess);
  4432. }
  4433. var maxValue = 0;
  4434. var maxIndex = 3;
  4435. $('#nick-car-choices .head h4').each(function (i) {
  4436. if (parseInt($(this).text().replace('%', ''), 10) > maxValue) {
  4437. maxValue = parseInt($(this).text().replace('%', ''), 10);
  4438. maxIndex = i;
  4439. }
  4440. });
  4441. $('#nick-car-choices .popup-place-wrapper:eq(' + maxIndex + ')').addClass('active');
  4442. $('#nick-car-choices button:eq(' + maxIndex + ')').focus();
  4443. }
  4444. // Lackeys are on, show lackey page enhancements
  4445. if (on_page('module=Cars') && nclass == 'otable widetable') {
  4446. var itemspath = 'table[data-info="items"] > tbody > tr[data-id]';
  4447. // Loop cars
  4448. var x = 0;
  4449. var totalCarval = 0;
  4450. $(itemspath).each(function () {
  4451. // grab value
  4452. var carVal = parseInt($(itemspath + ':eq(' + x + ') > td:eq(4)').text().replace(',', '').replace('$', ''), 10);
  4453. totalCarval += carVal;
  4454. ++x;
  4455. });
  4456. // Show total value
  4457. $('div.oheader:eq(2)').text($(itemspath).length + $('div.oheader:eq(2)').text()).append(
  4458. $('<span>').text('total value: $' + commafy(totalCarval))
  4459. );
  4460. }
  4461. // ---------------- Obay ----------------
  4462. if (on_page('obay.php') && !on_page('specific') && nn == 'center') {
  4463. $('table.thinline:eq(2) > tbody > tr').each(function () {
  4464. if (['one', 'two', 'three'].indexOf($(this).attr('class')) > -1) { // this row has an object
  4465. var sort_b = (on_page('type=11')) ? 1 : 0; // are we sorting on bullets?
  4466. // add price per bullets
  4467. if ($(this).text().indexOf('bullets') != -1) {
  4468. var bullets = parseInt($(this).find('td:eq(' + (2 - sort_b) + ')').text().replace(/[^0-9.]/g, ''), 10);
  4469. var money = parseInt($(this).find('td:eq(' + (3 - sort_b) + ')').text().replace(/[^0-9.]/g, ''), 10);
  4470. var ppb = parseInt(money / bullets, 10);
  4471. $(this).find('td:eq(' + (2 - sort_b) + ')').text($(this).find('td:eq(' + (2 - sort_b) + ')').text() + ' ($' + commafy(ppb) + ')');
  4472. }
  4473. }
  4474. });
  4475. }
  4476. if (on_page('obay.php?specific=') && nn == 'center') {
  4477. $('input[name="anon"][value="0"]').prop('checked', 'checked');
  4478. $('input[type="submit"]').focus();
  4479. }
  4480. // ---------------- Garage ----------------
  4481. if ((on_page('garage.php') || on_page('module=Cars')) && nn == 'h2') {
  4482. var totVal = 0;
  4483. var types = [
  4484. ['h', 8, 9, 13, 15, 16, 17, 18, 19, 21, 22, 27, 32, 34, 35, 40, 43],
  4485. ['oc', 23, 25, 26, 28, 29, 30, 31, 33, 39, 41, 42],
  4486. ['moc', 45, 47, 48],
  4487. ['tr', 23, 47, 54]
  4488. ];
  4489. $('tr.thinline').each(function () { // loop rows
  4490. var carid = $(this).find('td:eq(0)').text();
  4491. var carVal = parseInt($(this).find('td:eq(3)').html().replace(',', '').replace('$', ''), 10); // get value
  4492. totVal += carVal;
  4493. $(this).click(function (e) {
  4494. var check = $(this).find('input[value="' + carid + '"]');
  4495. if (e.target.tagName != 'INPUT') {
  4496. check.click();
  4497. }
  4498. });
  4499. });
  4500. // add amount of bullets
  4501. var head = $('h2');
  4502. var cars = head.text().match(/\d+/g)[2];
  4503. if (cars > 0) {
  4504. head.append(
  4505. $('<span>').text(' | Potential Bullets: ' + cars * 12)
  4506. );
  4507. }
  4508. // add amount of money
  4509. if (totVal > 0) {
  4510. head.append(
  4511. $('<span>').text(' | Total car value of this page: $' + commafy(totVal))
  4512. );
  4513. }
  4514. // scrolldown link
  4515. $('<div>').css({
  4516. float: 'right',
  4517. cursor: 'pointer'
  4518. }).append(
  4519. $('<span>').text('Scroll down').click(function () {
  4520. $('#game_container_wrapper').animate({
  4521. scrollTop: $('#game_container').height()
  4522. }, 1000);
  4523. })
  4524. ).insertBefore('table.thinline');
  4525. $(window).scroll(toggleFooterVisibility);
  4526. $('td:has(input[value="SH-cars"]), #footer').append(
  4527. $('<select>').attr({
  4528. name: 'selsort'
  4529. }).append(
  4530. $('<option>').attr('value', '0').text('-----'),
  4531. $('<option>').attr('value', '1').text('Above'),
  4532. $('<option>').attr('value', '2').text('Below'),
  4533. $('<option>').attr('value', '3').text('Between')
  4534. ).on('change', function() {
  4535. $(this).siblings('[name="selval2"]').toggle($(this).val() === '3');
  4536. }),
  4537. $('<input>').attr({
  4538. type: 'text',
  4539. name: 'selval',
  4540. size: '9'
  4541. }),
  4542. $('<input>').attr({
  4543. type: 'text',
  4544. name: 'selval2',
  4545. size: '9'
  4546. }).css('display', 'none'),
  4547. $('<input>').attr({
  4548. type: 'button',
  4549. name: 'selgo',
  4550. value: 'Select'
  4551. }).click(function () {
  4552. var sort = $(this).siblings('[name="selsort"]').val();
  4553. var val = $(this).siblings('[name="selval"]').val();
  4554. if (val !== '' && sort != '-----') {
  4555. var maxPrice = $(this).siblings('[name="selval2"]').val();
  4556. $('tr.thinline').each(function () { // loop rows
  4557. var carid = $(this).find('td:eq(0)').text();
  4558. var carVal = parseInt($(this).find('td:eq(3)').html().replace(',', '').replace('$', ''), 10); // get value
  4559. var check = $(this).find('input[value="' + carid + '"]');
  4560. var comment = $(this).find('td:eq(6)').text().trim();
  4561. if (check.prop('checked') === true) {
  4562. check.click();
  4563. }
  4564. var carWorthAbove = sort == 1 && carVal > val;
  4565. var carWorthBelow = sort == 2 && carVal < val;
  4566. var carWorthBetween = (sort == 3 && carVal >= val && (carVal <= maxPrice));
  4567. if (carWorthAbove || carWorthBelow || carWorthBetween) {
  4568. if (comment.indexOf('IN SAFEHOUSE') === -1) {
  4569. check.click();
  4570. }
  4571. }
  4572. });
  4573. }
  4574. })
  4575. );
  4576. }
  4577. // ---------------- Kill page ----------------
  4578. if (on_page('module=Detectives') && nn == 'div') {
  4579. if (nid == 'wrappertest') {
  4580. if (GetParam('search')) {
  4581. $('input[name="target"]').val(GetParam('search'));
  4582. }
  4583. }
  4584.  
  4585. // Fire all Detectives that have failed searching for person X
  4586. // Translation variables
  4587. var failedMessage = (v == 'nl' ? 'gefaald' : 'failed');
  4588. var fireDetectivesMessage = (v == 'nl' ? 'Verwijder gefaalde detectives' : 'Fire all failed detectives');
  4589.  
  4590. $('input[data-action="fireAll"]').closest('td').css('width', 'auto').after(
  4591. $('<td>').attr('align', 'right').append(
  4592. $('<input id="ob_fire_all" type="button" value="' + fireDetectivesMessage + '"">').click(function() {
  4593. $('#ob_fire_all').val('Firing..').prop('disabled', true);
  4594. var fireDetectives = function () {
  4595.  
  4596. // Loop over each row in the table, except the last row
  4597. $('.otable > table > tbody > tr:not(:last-child)').each(function() {
  4598. var detectiveText = $(this).find('td:first').text();
  4599. var ajaxID = $(this).find('td:nth-child(2) a').attr('data-id');
  4600. var elem = this;
  4601.  
  4602. // Check if the row contains 'failed', which means the detective hasn't found the person
  4603. // In case he hasn't, its safe to remove that detective
  4604.  
  4605. if (wordInString(detectiveText, failedMessage)) {
  4606. $.post('//' + document.location.hostname + '/BeO/webroot/?module=Detectives&action=fire', { id: ajaxID }).done(function() {
  4607. $('#ob_fire_all').val('Detectives fired!');
  4608. $(elem).closest('tr').hide();
  4609. });
  4610. }
  4611. });
  4612. };
  4613. fireDetectives();
  4614. })
  4615. )
  4616. );
  4617.  
  4618. // Disable the input box if there are no messages of failed detectives
  4619. if ($('#detectives-hired-div:contains("' + failedMessage + '")').length > 0) {
  4620. $('#ob_fire_all').prop('disabled', false);
  4621. } else {
  4622. $('#ob_fire_all').prop('disabled', true);
  4623. }
  4624.  
  4625. // If a user inserts '60k', automatically change it to '60.000'.
  4626. // This should work for every value in front of the 'k'
  4627.  
  4628. $('input[name="bullets"]').keydown(function (event) {
  4629. var symcode = event.which;
  4630. if (symcode == 75) {
  4631. $(this).val($(this).val() + '000');
  4632. }
  4633. $(this).val($(this).val().replace(/k/g, ''));
  4634. return (symcode == 75) ? false : true;
  4635. });
  4636.  
  4637. }
  4638. // ---------------- Misc ----------------
  4639. // look its me
  4640. if ((on_page('users_online') && nn == 'center') || (on_page('allusers.php') && nn == 'div') || (on_page('global_stats')) && nn == 'center') {
  4641. var nick = getV('nick', '');
  4642. if (nick !== '') {
  4643. $('a[class!="link"]').each(function () {
  4644. if ($(this).text() == nick || $(this).text() == nick + '+') {
  4645. $(this).html('<span style="color:green;font-weight:bold;">' + $(this).html() + '</span>');
  4646. }
  4647. });
  4648. }
  4649. }
  4650. // quick lookup
  4651. if (on_page('user.php') && nn == 'span') {
  4652. var input = GetParam('nick');
  4653. var str = (v == 'nl' ? 'Deze speler bestaat niet' : 'This user does not exist');
  4654. if ($('#game_container:contains("' + str + '")').length && input !== false) {
  4655. setTimeout(function () {
  4656. $.getJSON(OB_API_WEBSITE + '/?p=quicklookup&v=' + v + '&input=' + input, function (data) {
  4657. $('#game_container').html(str + ': ' + input);
  4658. var html = '';
  4659. var i = 0;
  4660. for (var results in data) {
  4661. if (data.hasOwnProperty(results)) {
  4662. if (i < 50) {
  4663. html += '<br /><a href="user.php?nick=' + results + '" id="' + i + '" class="sel">' + results + '</a>';
  4664. }
  4665. }
  4666. i++;
  4667. }
  4668. var total = i === 0 ? 0 : ++i;
  4669. if (input.length < 3) {
  4670. $('#game_container').html(str + ': ' + input + '<br />This will give too many results. Try to be more specific.');
  4671. } else if (total !== 0) {
  4672. $('#game_wrapper_container').css('height', '99%');
  4673. $('span.title-main').text('Quick lookup by Omerta Beyond');
  4674. $('#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 />');
  4675. $('#game_container').html($('#game_container').html() + html);
  4676. $('#0').focus();
  4677. var j = 0;
  4678. $(window).keydown(function (event) {
  4679. if (event.keyCode == 40) {
  4680. if (j < num - 1) {
  4681. j++;
  4682. $('#' + j).focus();
  4683. }
  4684. }
  4685. });
  4686. $(window).keydown(function (event) {
  4687. if (event.keyCode == 38) {
  4688. if (j !== 0) {
  4689. j--;
  4690. $('#' + j).focus();
  4691. }
  4692. }
  4693. });
  4694. } else {
  4695. $('#game_container').html(str + ': ' + input + '<br />Sorry, we also couldn\'t find any alternatives.');
  4696. }
  4697. });
  4698. }, 100);
  4699. }
  4700. }
  4701. // ---------------- Blood AF ----------------
  4702. if (on_page('module=Bloodbank') && nn == 'table') {
  4703. var table, tr, A, B, m, type, types;
  4704. type = getV('bloodType');
  4705.  
  4706. var bloodAF = function (t) {
  4707. // setup costs row
  4708. table = $('table.thinline:eq(1)');
  4709. 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>');
  4710. table.append(tr);
  4711.  
  4712. function getType(num) {
  4713. return parseInt($('table.thinline:eq(1) > tbody > tr:eq(2) > td:eq(' + num + ')').text().replace('$ ', ''), 10);
  4714. }
  4715.  
  4716. function setType(num) {
  4717. return ($('select').get(0).selectedIndex = num);
  4718. }
  4719.  
  4720. function calc(a, b, ab, o) { // see if user can buy bloodtype and then calc total price
  4721. $('font#A').text(a ? '$ ' + m * $('td[align="center"]:eq(9)').text().replace('$ ', '') : 'X');
  4722. $('font#B').text(b ? '$ ' + m * $('td[align="center"]:eq(10)').text().replace('$ ', '') : 'X');
  4723. $('font#AB').text(ab ? '$ ' + m * $('td[align="center"]:eq(11)').text().replace('$ ', '') : 'X');
  4724. $('font#O').text(o ? '$ ' + m * $('td[align="center"]:eq(12)').text().replace('$ ', '') : 'X');
  4725. }
  4726. if ($('input[name="UnitsToBuy"]').length) {
  4727. m = parseInt($('input[name="UnitsToBuy"]').val(), 10);
  4728. types = [getType('1'), getType('2'), getType('3'), getType('4')];
  4729. A = [types[0], types[3]];
  4730. B = [types[1], types[3]];
  4731.  
  4732. if (t == 'A') {
  4733. calc(1, 0, 0, 1);
  4734. setType(iMin(A));
  4735. }
  4736. if (t == 'B') {
  4737. calc(0, 1, 0, 1);
  4738. setType(iMin(B));
  4739. }
  4740. if (t == 'AB') {
  4741. calc(1, 1, 1, 1);
  4742. setType(iMin(types));
  4743. }
  4744. if (t == 'O') {
  4745. calc(0, 0, 0, 1);
  4746. setType(0);
  4747. }
  4748. $('input[name="Buy"]').focus();
  4749. } else {
  4750. calc(0, 0, 0, 0);
  4751. }
  4752. };
  4753. bloodAF(type);
  4754. }
  4755. // ---------------- Bodyguards ----------------
  4756. if (on_page('module=Bodyguards') && nn == 'div') {
  4757. // Hide bio
  4758. $('div[id$="BoughtBG"]').css('display', 'none');
  4759. // set timer for BG if it counts down
  4760. ScheduleNotification(
  4761. 'bg',
  4762. $('[data-timecb="bodyguard"]').attr('data-time-end'),
  4763. 'Train Bodyguard (' + v + ')',
  4764. (v == 'nl' ? 'Je kunt je bodyguard weer trainen' : 'You can train your bodyguard again'),
  4765. 'bodyguard',
  4766. '/?module=Bodyguards',
  4767. assetUrl('/images/red-star.png')
  4768. );
  4769. }
  4770. // ---------------- Raid Result @ Statistics and Spots ----------------
  4771. if (on_page('global_stats') || on_page('module=Spots')) {
  4772. var isSpots = on_page('module=Spots');
  4773. // add possible raid profit in a new column for all objects
  4774. $('td:contains("Profit"), td:contains("Winst"), td:contains("Kazanc")').closest('table').find('tr').each(function() {
  4775. var tableHeader;
  4776. if (isSpots) {
  4777. tableHeader = $(this).find('td[colspan="7"]');
  4778. } else {
  4779. tableHeader = $(this).find('td.tableheader, td[bgcolor="black"]');
  4780. }
  4781. if (tableHeader.length > 0) {
  4782. // increase colspan of table header
  4783. tableHeader.each(function() {
  4784. $(this).attr('colspan', parseInt($(this).attr('colspan'), 10) + 1);
  4785. });
  4786. return;
  4787. }
  4788. if (isSpots && $(this).find('td:first').hasClass('tableheader')) {
  4789. $(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>'));
  4790. return;
  4791. }
  4792. var firstRowText = $(this).find('td:first').text();
  4793. if (firstRowText == 'City:' || firstRowText == 'Stad:') {
  4794. // add table header
  4795. $(this).append($('<td><b class="raid_profit_tooltip" title="Best Possible Raid Result per Player">Raid Result:</b></td>'));
  4796. return;
  4797. }
  4798. if (isSpots && $(this).find('td[colspan="3"]').length > 0) {
  4799. // make Bankrupt/OOB columns wider
  4800. $(this).find('td[colspan="3"]').attr('colspan', '4');
  4801. return;
  4802. }
  4803. if (!isSpots) {
  4804. // make city column a bit smaller
  4805. $(this).find('td:first').attr('width', '130');
  4806. }
  4807. var profit;
  4808. if (isSpots) {
  4809. profit = parseInt($(this).find('td.text-green').text().replace(/,|\$/g, ''), 10);
  4810. } else {
  4811. if ($(this).find('.profit').length > 0) {
  4812. profit = parseInt($(this).find('.profit').text().replace(/,|\$/g, ''), 10);
  4813. } else {
  4814. profit = 0;
  4815. }
  4816. }
  4817. if (profit > 0) {
  4818. // row with running + profitable object
  4819. var protection = parseInt($(this).find('.percent').text().replace('%', ''), 10);
  4820. var raidResult = calcRaidResult(profit, protection);
  4821. if (isSpots) {
  4822. $(this).find('td:eq(4)').after('<td>$ ' + commafy(Math.floor(raidResult)) + '</td>');
  4823. } else {
  4824. $(this).append('<td>$ ' + commafy(Math.floor(raidResult)) + '</td>');
  4825. }
  4826. } else if (isSpots || $(this).find('.loss').length > 0 || $(this).text().indexOf('None') !== -1 || $(this).text().indexOf('Geen') !== -1) {
  4827. // append empty column for spots with losses or no profit
  4828. // border will be gone otherwise
  4829. if (isSpots) {
  4830. $(this).find('td:eq(4)').after('<td></td>');
  4831. } else {
  4832. $(this).append('<td></td>');
  4833. }
  4834. }
  4835. });
  4836. }
  4837. // ---------------- Statistics ----------------
  4838. if (on_page('module=Statistics') || on_page('allusers.php')) {
  4839. $('a[data-href*="/allusers.php"]').attr('href', '/allusers.php?start=0&order=lastrank&sort=DESC&dead=HIDE');
  4840. }
  4841. // ---------------- END OF MAIN GAME CONTAINER ----------------
  4842.  
  4843. // prefs circle
  4844. var prefs_div = $('<div>').addClass('sm-circle-bg ob-prefs-bg').append(
  4845. $('<span>').addClass('sm-circle sm-health').append(
  4846. $('<img>').attr({
  4847. src: assetUrl('/images/favicon.png'),
  4848. title: 'Omerta Beyond Preferences'
  4849. }).addClass('ob-prefs-img')
  4850. ).hover(
  4851. function() {
  4852. $(this).css('background', '#000FF0');
  4853. },
  4854. function() {
  4855. $(this).css('background', '#FFF');
  4856. }
  4857. )
  4858. ).click(function () {
  4859. $('span.title-main').text('Omerta Beyond Preferences');
  4860. $('#game_container').empty();
  4861. $('#game_wrapper_container').css('height', '99%');
  4862. $('#game_container').append(GetPrefPage());
  4863. });
  4864. if (versionHasLogger) {
  4865. // live famstats circle (needs new icon!)
  4866. var lf_div = $('<div>').addClass('sm-circle-bg ob-lf-bg').append(
  4867. $('<span>').addClass('sm-circle sm-health').append(
  4868. $('<img>').attr({
  4869. src: assetUrl('/images/favicon.png'),
  4870. title: 'Omerta Beyond Live Famstats'
  4871. }).addClass('ob-prefs-img')
  4872. ).hover(
  4873. function() {
  4874. $(this).css('background', '#1EB418');
  4875. },
  4876. function() {
  4877. $(this).css('background', '#FFF');
  4878. }
  4879. )
  4880. ).click(function () {
  4881. window.open(OB_RIX_WEBSITE + '/stats.php?v=' + v + '&d=n');
  4882. });
  4883.  
  4884. if ($('.ob-lf-bg').length === 0) {
  4885. $('div.omerta-widget-avatar-body').append(lf_div);
  4886. }
  4887. }
  4888.  
  4889. if ($('.ob-prefs-bg').length === 0) {
  4890. $('div.omerta-widget-avatar-body').append(prefs_div);
  4891. }
  4892. };
  4893. }
  4894.  
  4895. /*
  4896. * Pages without only text nodes
  4897. */
  4898.  
  4899. $('#game_container').on('DOMNodeInserted', function() {
  4900. if (on_page('jail.php')) {
  4901. // Return when self bo
  4902. if ($('#game_container:contains("You busted yourself out of jail")').length) {
  4903. if (!$('#bo_fired').length) {
  4904. var bos = parseInt(getV('bustouts', 0), 10);
  4905. bos = (bos + 1);
  4906. setV('bustouts', bos);
  4907. $('#game_container').append($('<span>').attr('id', 'bo_fired'));
  4908. unsafeWindow.omerta.GUI.container.loadPage(window.location.hash.substr(1));
  4909. }
  4910. }
  4911. // Return when busted
  4912. if ($('#game_container:contains("You are not in jail!")').length) {
  4913. if (!$('#bo_fired').length) {
  4914. $('#game_container').append($('<span>').attr('id', 'bo_fired'));
  4915. unsafeWindow.omerta.GUI.container.loadPage(window.location.hash.substr(1));
  4916. }
  4917. }
  4918. }
  4919. });
  4920.  
  4921. /*
  4922. * Notifications trigger & marquee
  4923. */
  4924.  
  4925. var prevPrices = [];
  4926. var firstTimePrice = true;
  4927. $('#game_container').one('DOMNodeInserted', function () {
  4928. if (versionHasLogger) {
  4929. setTimeout(function () {
  4930. CheckBmsg();
  4931. }, 1000);
  4932. }
  4933. setTimeout(function() {
  4934. CheckServiceVariable();
  4935. }, 1000);
  4936.  
  4937. function buildMarquee() {
  4938. setTimeout(function () {
  4939. $.get('//' + document.location.hostname + '/BeO/webroot/index.php?module=API&action=smuggling_prices', function (dom) {
  4940. function getPrice(drug, city) {
  4941. return dom.getElementsByTagName(drug)[city].textContent;
  4942. }
  4943.  
  4944. function refreshMarquee(h, m) {
  4945. h = (m >= 31 ? h + 1 : h);
  4946. m = (m >= 31 ? 1 : 31);
  4947. var marQd = new Date();
  4948. marQd.setHours(h);
  4949. marQd.setMinutes(m);
  4950. marQd.setSeconds(0);
  4951. marQd.setMilliseconds(0);
  4952. return (marQd.getTime() - getOmertaTime());
  4953. }
  4954.  
  4955. var p = [];
  4956. var q = [];
  4957. var pricesChanged = false;
  4958.  
  4959. for (var i = 0; i <= 7; i++) {
  4960. p[i] = getPrice('cocaine', i);
  4961. q[i] = p[i];
  4962. if ((prevPrices === undefined || prevPrices[i] === undefined) || prevPrices[i] != p[i]) {
  4963. pricesChanged = true;
  4964. }
  4965. }
  4966.  
  4967. if (pricesChanged) {
  4968. prevPrices = JSON.parse(JSON.stringify(q));
  4969. } else {
  4970. setTimeout(buildMarquee, 30000);
  4971. return;
  4972. }
  4973.  
  4974. var max = p.sort(function (a, b) {
  4975. return b - a;
  4976. })[0];
  4977. var min = p[(p.length - 1)];
  4978.  
  4979. var highCity = '';
  4980. var highCityPrice = 0;
  4981. var lowCity = '';
  4982. var lowCityPrice = 0;
  4983. i = 0;
  4984. q.forEach(function ($n) {
  4985. if ($n == min) {
  4986. q[i] = '<span style="color:#00ff00;">' + $n + '</span>';
  4987. lowCity = cities[i];
  4988. lowCityPrice = $n;
  4989. }
  4990. if ($n == max) {
  4991. q[i] = '<span style="color:' + '#ff5353' + ';">' + $n + '</span>';
  4992. highCity = cities[i];
  4993. highCityPrice = $n;
  4994. }
  4995. i++;
  4996. });
  4997.  
  4998. if (!firstTimePrice && (prefs['notify_bn'] || prefs['notify_bn_sound'])) {
  4999. if (prefs['notify_bn']) {
  5000. 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'));
  5001. }
  5002.  
  5003. if (prefs['notify_bn_sound']) {
  5004. playSound('bn');
  5005. }
  5006. }
  5007.  
  5008. firstTimePrice = false;
  5009.  
  5010. var time = dom.getElementsByTagName('humantime')[0].textContent;
  5011. time = time.split(' ')[0];
  5012. time = time.split(':');
  5013. time = (time[1] < 30) ? time[0] + ':00 OT' : time[0] + ':30 OT';
  5014.  
  5015. function hovermenu(city) {
  5016. var hoverStyle = {
  5017. display: 'block',
  5018. position: 'fixed',
  5019. left: $('#marquee').offset().left,
  5020. top: '42px',
  5021. zIndex: '102',
  5022. opacity: 0.8,
  5023. backgroundColor: 'black',
  5024. color: '#EEE',
  5025. border: 'none',
  5026. padding: '5px 15px 5px 15px'
  5027. };
  5028. $('#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));
  5029. }
  5030.  
  5031. function flytolink(city, priceStr) {
  5032. var link = $('<a>').attr({
  5033. id: cities[city],
  5034. href: '#'
  5035. }).css({
  5036. color: '#FFF',
  5037. fontSize: '10px'
  5038. }).click(function () {
  5039. unsafeWindow.omerta.GUI.container.loadPage('./BeO/webroot/index.php?module=Travel&action=FetchInfo&CityId=' + ((city == 'nul') ? 0 : city));
  5040. });
  5041.  
  5042. if (city == 5 || city == 6 || city == 7) {
  5043. link.mouseover(function () {
  5044. hovermenu(city);
  5045. $(this).css('textDecoration', 'underline');
  5046. });
  5047. } else if (city === 0 || city == 1 || city == 2) {
  5048. link.mouseover(function () {
  5049. hovermenu(city);
  5050. $(this).css('textDecoration', 'underline');
  5051. });
  5052. } else {
  5053. link.mouseover(function () {
  5054. hovermenu(city);
  5055. $(this).css('textDecoration', 'underline');
  5056. });
  5057. }
  5058. link.mouseout(function () {
  5059. $('#hiddenbox').css('display', 'none');
  5060. $(this).css('textDecoration', 'none');
  5061. });
  5062. link.html(priceStr);
  5063.  
  5064. return link;
  5065. }
  5066.  
  5067. var span = $('<span>').append(
  5068. $('<span>').text(time + ': ').css('font-size', '10px')
  5069. );
  5070.  
  5071. i = 0;
  5072. p.forEach(function () {
  5073. span.css('color', '#FFF');
  5074. span.append(flytolink(i, cities[i] + ':' + q[i]), $('<span>').text(' | '));
  5075. i++;
  5076. });
  5077.  
  5078. span.append(
  5079. $('<a>').attr({
  5080. href: 'prices.php'
  5081. }).text('All Prices').css({
  5082. color: '#FFF',
  5083. fontSize: '10px'
  5084. }).hover(function () {
  5085. $(this).css('textDecoration', 'underline');
  5086. }, function () {
  5087. $(this).css('textDecoration', 'none');
  5088. })
  5089. );
  5090.  
  5091. $('#marquee').html(span);
  5092. setTimeout(buildMarquee, refreshMarquee(new Date().getHours(), new Date().getMinutes()));
  5093. });
  5094. });
  5095. }
  5096.  
  5097. $('.top-nav').append(
  5098. $('<li>').addClass('pull-left').css({
  5099. width: '40%',
  5100. padding: '0',
  5101. display: 'table',
  5102. lineHeight: '14px'
  5103. }).append(
  5104. $('<div>').attr('id', 'marquee').css({
  5105. display: 'table-cell',
  5106. verticalAlign: 'middle'
  5107. }),
  5108. $('<div>').attr('id', 'hiddenbox').addClass('marqueebox')
  5109. )
  5110. );
  5111.  
  5112. buildMarquee();
  5113.  
  5114. var city = getPow('bninfo', 2, -1);
  5115. if (city > 0) {
  5116. city = cities[city - 4];
  5117. $('#' + city).css('font-style', 'italic');
  5118. }
  5119. });
  5120.  
  5121. function GetPrefPage() {
  5122. // set location.hash so other code doesn't get triggered
  5123. // window.location.hash = 'OB_preferences';
  5124. // ^ gonna comment this out for a quick .dm patch for new layout
  5125.  
  5126. var setGroupPriority = function () {
  5127. setA('sets', $(this).attr('id'), $(this).val());
  5128. };
  5129.  
  5130. var jailHL = (prefs['jailHL'] ? true : false);
  5131. var jailHL_sel = sets['jailHL_sel'] || 'highest';
  5132. var jailHL_other = sets['jailHL_other'] || 9;
  5133. var jailHL_friends = sets['jailHL_friends'] || 5;
  5134. var jailHL_own_lackey = sets['jailHL_own_lackey'] || 7;
  5135. var jailHL_fr_lackey = sets['jailHL_fr_lackey'] || 8;
  5136. var jailHL_other_lackey = sets['jailHL_other_lackey'] || 11;
  5137. var autoCloseNotificationsSecs = sets['autoCloseNotificationsSecs'] || 0;
  5138. var bo_hotkey = sets['bo_hotkey'] || '/';
  5139. var custom_groups = getV('custom_groups', '').split('|');
  5140. custom_groups.pop();
  5141. var nobust = getV('nobust', '').split(',');
  5142. var af_position = sets['af_position'] || 'floating';
  5143. setA('prefs', 'NR', 1);
  5144.  
  5145. // Build custom groups priority settings
  5146. var c_group_div = null;
  5147. for (var i = 0; i < custom_groups.length; i++) {
  5148. var group_name = custom_groups[i].split(':')[0];
  5149. var group_prio = sets['jailHL_' + group_name] || (i + 12);
  5150. var group_lackey_prio = sets['jailHL_' + group_name + '_lackey'] || (i + 13);
  5151. var jailTr = [
  5152. $('<tr>').append(
  5153. $('<td>').text(group_name),
  5154. $('<td>').append(
  5155. $('<input>').attr({
  5156. id: 'jailHL_' + group_name,
  5157. type: 'text',
  5158. value: group_prio
  5159. }).blur(setGroupPriority)
  5160. )
  5161. ),
  5162. $('<tr>').append(
  5163. $('<td>').text(group_name + ' lackeys'),
  5164. $('<td>').append(
  5165. $('<input>').attr({
  5166. id: 'jailHL_' + group_name + '_lackey',
  5167. type: 'text',
  5168. value: group_lackey_prio
  5169. }).blur(setGroupPriority)
  5170. )
  5171. )
  5172. ];
  5173. if (c_group_div === null) {
  5174. c_group_div = jailTr;
  5175. } else {
  5176. c_group_div = c_group_div.concat(jailTr);
  5177. }
  5178. }
  5179.  
  5180. function deleteNoBustEntry() {
  5181. var entrySpan = $(this).prev();
  5182. var index = nobust.indexOf(entrySpan.attr('id'));
  5183. nobust.splice(index, 1);
  5184. entrySpan.hide();
  5185. $(this).hide();
  5186. setV('nobust', nobust);
  5187. }
  5188. // Build no bust list
  5189. var nobust_div = $('<div>').attr('id', 'nobust');
  5190. for (var i = 0; i < nobust.length; i++) {
  5191. if (nobust[i].length > 0) {
  5192. nobust_div.append(
  5193. $('<span>').attr({id: nobust[i]}).text(nobust[i]),
  5194. $('<img />').addClass('inboxImg').attr({
  5195. src: assetUrl('/images/delete.png'),
  5196. title: 'Delete'
  5197. }).click(deleteNoBustEntry),
  5198. $('<br>')
  5199. );
  5200. }
  5201. }
  5202. nobust_div.append(
  5203. $('<input>').attr({
  5204. id: 'new_nobust',
  5205. type: 'text'
  5206. }),
  5207. $('<button>').text('Add').click(function() {
  5208. // let's not add empty entries
  5209. var newVal = $('#new_nobust').val();
  5210. if (newVal.length > 0) {
  5211. $('<span>').attr({id: newVal}).text(newVal).insertBefore($('#new_nobust'));
  5212. $('<img />').addClass('inboxImg').attr({
  5213. src: assetUrl('/images/delete.png'),
  5214. title: 'Delete'
  5215. }).click(deleteNoBustEntry).insertBefore($('#new_nobust'));
  5216. $('<br>').insertBefore($('#new_nobust'));
  5217. nobust.push(newVal);
  5218. setV('nobust', nobust);
  5219. $('#new_nobust').val('');
  5220. }
  5221. })
  5222. );
  5223.  
  5224. var getNotificationItem = function(name, label) {
  5225. return $('<tr>').append(
  5226. $('<td>').text(label),
  5227. $('<td>').css('text-align', 'center').append(
  5228. $('<input>').attr({
  5229. type: 'checkbox',
  5230. checked: prefs[name] ? true : false
  5231. }).click(function () {
  5232. setA('prefs', name, $(this).prop('checked'));
  5233. })
  5234. ),
  5235. $('<td>').css('text-align', 'center').append(
  5236. $('<input>').attr({
  5237. type: 'checkbox',
  5238. checked: prefs[name + '_sound'] ? true : false
  5239. }).click(function () {
  5240. setA('prefs', name + '_sound', $(this).prop('checked'));
  5241. })
  5242. )
  5243. );
  5244. };
  5245.  
  5246. var notificationOptions = [
  5247. { name: 'bmsgDeaths', label: 'Deaths' },
  5248. { name: 'bmsgNews', label: 'News' },
  5249. { name: 'notify_bn', label: 'B/N prices changes'},
  5250. { name: 'notify_crime', label: 'Crime' },
  5251. { name: 'notify_gta', label: 'Nick a car' },
  5252. { name: 'notify_heist', label: 'Heist' },
  5253. { name: 'notify_oc', label: 'OC' },
  5254. { name: 'notify_moc', label: 'Mega OC' },
  5255. { name: 'notify_raid', label: 'Spot raid' },
  5256. { name: 'notify_race', label: 'Car race' },
  5257. { name: 'notify_travel', label: 'Travel' },
  5258. { name: 'notify_bullets', label: 'Buy bullets' },
  5259. { name: 'notify_health', label: 'When losing health' },
  5260. { name: 'notify_kill', label: 'When you can kill' },
  5261. { name: 'notify_blood', label: 'When you can buy blood' },
  5262. { name: 'notify_messages', label: 'Receive new message' },
  5263. { name: 'notify_alerts', label: 'New alerts' },
  5264. { name: 'notify_bg', label: 'Train BG' },
  5265. { name: 'notify_highlight', label: 'Name mentioned in chat' }
  5266. ];
  5267.  
  5268. var notificationMarkup = $('<table>').addClass('thinline').attr({ cellspacing: 0, cellpading: 2, width: '100%' }).append(
  5269. $('<tr>').append(
  5270. $('<td>').addClass('tableitem').attr('align', 'center').append(
  5271. $('<b>').text('Event')
  5272. ),
  5273. $('<td>').addClass('tableitem').attr('align', 'center').append(
  5274. $('<b>').text('Notification')
  5275. ),
  5276. $('<td>').addClass('tableitem').attr('align', 'center').append(
  5277. $('<b>').text('Sound')
  5278. )
  5279. ),
  5280. notificationOptions.map(function(element) {
  5281. return getNotificationItem(element.name, element.label);
  5282. })
  5283. );
  5284.  
  5285. var prefs_page = $('<center>').attr({
  5286. id: 'prefsContainer'
  5287. }).append(
  5288. $('<table>').addClass('thinline').attr({ cellspacing: 0, cellpading: 2, width: '90%' }).append(
  5289. $('<tr>').append(
  5290. $('<td>').addClass('tableheader').attr('align', 'center').css('text-align', 'center').append(
  5291. $('<span>').css('font-weight', 'bold').text('OmertaBeyond Preferences')
  5292. )
  5293. ),
  5294. $('<tr>').append(
  5295. $('<td>').attr({ height: '1', bgcolor: 'black' })
  5296. ),
  5297. $('<tr>').append(
  5298. $('<td>').addClass('tableitem').attr('align', 'center').css('text-align', 'center').css('font-weight', 'normal').text('Version ' + OB_VERSION)
  5299. ),
  5300. $('<tr>').append(
  5301. $('<td>').attr({ height: '1', bgcolor: 'black' })
  5302. ),
  5303. $('<tr>').append(
  5304. $('<td>').addClass('tableitem').attr('align', 'center').css('text-align', 'center').text('Notifications')
  5305. ),
  5306. $('<tr>').append(
  5307. $('<td>').attr({ height: '1', bgcolor: 'black' })
  5308. ),
  5309. $('<tr>').append(
  5310. $('<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(
  5311. $('<br>'),
  5312. $('<div>').attr('id', 'Authmsg'),
  5313. $('<button id="btnNotification">').text('Authorize for notifications').click(function () {
  5314. if ('Notification' in window) {
  5315. Notification.requestPermission(function (perm) {
  5316. $('#Authmsg').text('Authorization for notification is: ' + perm);
  5317. });
  5318. }
  5319. }),
  5320. $('<br>'),
  5321. $('<label>').attr('for', 'autoCloseNotificationsSecs').text('Show notifications for X seconds (0 = always show)'),
  5322. $('<input>').attr({
  5323. id: 'autoCloseNotificationsSecs',
  5324. type: 'text',
  5325. value: autoCloseNotificationsSecs
  5326. }).blur(function() {
  5327. setA('sets', 'autoCloseNotificationsSecs', $('#autoCloseNotificationsSecs').val());
  5328. }),
  5329. $('<br>'),
  5330. $('<input>').attr({
  5331. id: 'use_tts',
  5332. type: 'checkbox',
  5333. checked: prefs['use_tts'] ? true : false
  5334. }).click(function () {
  5335. setA('prefs', 'use_tts', $(this).prop('checked'));
  5336. }),
  5337. $('<label>').attr('for', 'use_tts').text('Enable Text-to-Speech'),
  5338. $('<br>'),
  5339. $('<div>').addClass('notify').append(
  5340. notificationMarkup
  5341. )
  5342. )
  5343. ),
  5344. $('<tr>').append(
  5345. $('<td>').attr({ height: '1', bgcolor: 'black' })
  5346. ),
  5347. $('<tr>').append(
  5348. $('<td>').addClass('tableitem').attr('align', 'center').css('text-align', 'center').text('Bust Priorities')
  5349. ),
  5350. $('<tr>').append(
  5351. $('<td>').attr({ height: '1', bgcolor: 'black' })
  5352. ),
  5353. $('<tr>').append(
  5354. $('<td>').attr('align', 'center').css('text-align', 'center').text(
  5355. 'Here you can choose which groups you want to bust before others.'
  5356. ).append(
  5357. $('<br>'),
  5358. $('<input>').attr({
  5359. id: 'jailHL',
  5360. type: 'checkbox',
  5361. checked: jailHL
  5362. }).click(function () {
  5363. setA('prefs', 'jailHL', $('#jailHL:checked').length);
  5364. }),
  5365. $('<label>').attr('for', 'jailHL').text('Enable Bust Priorities'),
  5366. $('<br>'),
  5367. $('<span>').css('font-style', 'italic').text('Lower value means higher priority'),
  5368. $('<table>').css('text-align', 'left').css('margin-left', '30%').append(
  5369. $('<tr>').append(
  5370. $('<td>').text('Other'),
  5371. $('<td>').append(
  5372. $('<input>').attr({
  5373. id: 'jailHL_other',
  5374. type: 'text',
  5375. value: jailHL_other
  5376. }).blur(function () {
  5377. setA('sets', 'jailHL_other', $('#jailHL_other').val());
  5378. })
  5379. )
  5380. ),
  5381. $('<tr>').append(
  5382. $('<td>').text('Friends and Family'),
  5383. $('<td>').append(
  5384. $('<input>').attr({
  5385. id: 'jailHL_friends',
  5386. type: 'text',
  5387. value: jailHL_friends
  5388. }).blur(function () {
  5389. setA('sets', 'jailHL_friends', $('#jailHL_friends').val());
  5390. })
  5391. )
  5392. ),
  5393. $('<tr>').append(
  5394. $('<td>').text('Own lackeys'),
  5395. $('<td>').append(
  5396. $('<input>').attr({
  5397. id: 'jailHL_own_lackey',
  5398. type: 'text',
  5399. value: jailHL_own_lackey
  5400. }).blur(function () {
  5401. setA('sets', 'jailHL_own_lackey', $('#jailHL_own_lackey').val());
  5402. })
  5403. )
  5404. ),
  5405. $('<tr>').append(
  5406. $('<td>').text('Friend/Family lackeys'),
  5407. $('<td>').append(
  5408. $('<input>').attr({
  5409. id: 'jailHL_fr_lackey',
  5410. type: 'text',
  5411. value: jailHL_fr_lackey
  5412. }).blur(function () {
  5413. setA('sets', 'jailHL_fr_lackey', $('#jailHL_fr_lackey').val());
  5414. })
  5415. )
  5416. ),
  5417. $('<tr>').append(
  5418. $('<td>').text('Other lackeys'),
  5419. $('<td>').append(
  5420. $('<input>').attr({
  5421. id: 'jailHL_other_lackey',
  5422. type: 'text',
  5423. value: jailHL_other_lackey
  5424. }).blur(function () {
  5425. setA('sets', 'jailHL_other_lackey', $('#jailHL_other_lackey').val());
  5426. })
  5427. )
  5428. ),
  5429. c_group_div,
  5430. $('<tr>').append(
  5431. $('<td>')
  5432. ),
  5433. $('<tr>').append(
  5434. $('<td>').text('Buyout hotkey'),
  5435. $('<td>').append(
  5436. $('<input>').attr({
  5437. id: 'bo_hotkey',
  5438. type: 'text',
  5439. value: bo_hotkey
  5440. }).blur(function () {
  5441. setA('sets', 'bo_hotkey', $('#bo_hotkey').val());
  5442. $('.ob_hotkey_pref').text($('#bo_hotkey').val());
  5443. })
  5444. )
  5445. )
  5446. ),
  5447. $('<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.'),
  5448. $('<span>').text('Do you want to choose players with highest/lowest remaining jailtime first, or pick one randomly?'),
  5449. $('<br>'),
  5450. $('<div>').addClass('notify').append(
  5451. $('<input>').attr({
  5452. name: 'jailHL_sel',
  5453. id: 'jailHL_high',
  5454. type: 'radio',
  5455. checked: (jailHL_sel == 'highest' ? true : false)
  5456. }).click(function () {
  5457. setA('sets', 'jailHL_sel', 'highest');
  5458. }),
  5459. $('<span>').append(
  5460. $('<label>').attr('for', 'jailHL_high').text('highest')
  5461. ),
  5462. $('<br>'),
  5463. $('<input>').attr({
  5464. name: 'jailHL_sel',
  5465. id: 'jailHL_low',
  5466. type: 'radio',
  5467. checked: (jailHL_sel == 'lowest' ? true : false)
  5468. }).click(function () {
  5469. setA('sets', 'jailHL_sel', 'lowest');
  5470. }),
  5471. $('<span>').append(
  5472. $('<label>').attr('for', 'jailHL_low').text('lowest')
  5473. ),
  5474. $('<br>'),
  5475. $('<input>').attr({
  5476. name: 'jailHL_sel',
  5477. id: 'jailHL_rand',
  5478. type: 'radio',
  5479. checked: (jailHL_sel == 'random' ? true : false)
  5480. }).click(function () {
  5481. setA('sets', 'jailHL_sel', 'random');
  5482. }),
  5483. $('<span>').append(
  5484. $('<label>').attr('for', 'jailHL_rand').text('random')
  5485. )
  5486. )
  5487. )
  5488. ),
  5489. $('<tr>').append(
  5490. $('<td>').attr({ height: '1', bgcolor: 'black' })
  5491. ),
  5492. $('<tr>').append(
  5493. $('<td>').addClass('tableitem').attr('align', 'center').css('text-align', 'center').text('Scumbag List')
  5494. ),
  5495. $('<tr>').append(
  5496. $('<td>').attr({ height: '1', bgcolor: 'black' })
  5497. ),
  5498. $('<tr>').append(
  5499. $('<td>').attr('align', 'center').css('text-align', 'center').text(
  5500. 'There is this one scumbag you wouldn\'t want to bust even if their life depended on it? Just add them here!'
  5501. ).append(
  5502. $('<br>'),
  5503. nobust_div,
  5504. $('<span>').text('You can add family names too, by the way.')
  5505. )
  5506. ),
  5507. $('<tr>').append(
  5508. $('<td>').attr({ height: '1', bgcolor: 'black' })
  5509. ),
  5510. $('<tr>').append(
  5511. $('<td>').addClass('tableitem').attr('align', 'center').css('text-align', 'center').text('Best Run Calculator - Autofiller')
  5512. ),
  5513. $('<tr>').append(
  5514. $('<td>').attr({ height: '1', bgcolor: 'black' })
  5515. ),
  5516. $('<tr>').append(
  5517. $('<td>').attr('align', 'center').css('text-align', 'center').text(
  5518. 'Settings for the Best Run Calculator are visible on the Smuggling page'
  5519. ).append(
  5520. $('<br>'),
  5521. $('<br>'),
  5522. $('<span>').text('You can choose between a movable window or showing the options on top of the page.'),
  5523. $('<br>'),
  5524. $('<div>').addClass('notify').append(
  5525. $('<input>').attr({
  5526. type: 'radio',
  5527. id: 'AF_Floating',
  5528. name: 'AF_Position',
  5529. checked: af_position == 'floating'
  5530. }).click(function() {
  5531. setA('sets', 'af_position', 'floating');
  5532. }),
  5533. $('<label>').attr({ for: 'AF_Floating' }).text('Show settings in movable window'),
  5534. $('<br>'),
  5535. $('<input>').attr({
  5536. type: 'radio',
  5537. id: 'AF_Static',
  5538. name: 'AF_Position',
  5539. checked: af_position == 'static'
  5540. }).click(function() {
  5541. setA('sets', 'af_position', 'static');
  5542. }),
  5543. $('<label>').attr({ for: 'AF_Static' }).text('Show settings on top of the page')
  5544. ),
  5545. $('<br>'),
  5546. $('<br>'),
  5547. $('<span>').text('If the movable window is gone, click here to reset its position.'),
  5548. $('<br>'),
  5549. $('<button>').text('Clear').click(function () {
  5550. if (confirm('Are you sure?')) {
  5551. setV('AFtop', '225');
  5552. setV('AFleft', '300');
  5553. }
  5554. })
  5555.  
  5556. )
  5557. ),
  5558. $('<tr>').append(
  5559. $('<td>').attr({ height: '1', bgcolor: 'black' })
  5560. ),
  5561. $('<tr>').append(
  5562. $('<td>').addClass('tableitem').attr('align', 'center').css('text-align', 'center').text('Reset data')
  5563. ),
  5564. $('<tr>').append(
  5565. $('<td>').attr({ height: '1', bgcolor: 'black' })
  5566. ),
  5567. $('<tr>').append(
  5568. $('<td>').attr('align', 'center').css('text-align', 'center').text(
  5569. 'Manually reset all saved OB data.'
  5570. ).append(
  5571. $('<br>'),
  5572. $('<span>').text('Click the button to clear all settings, WARNING this resets all OB data'),
  5573. $('<br>'),
  5574. $('<button>').text('Clear').click(function () {
  5575. if (confirm('Are you sure you want to clear ALL OB data?')) {
  5576. clearUserData();
  5577. alert('Please reload Omerta for the changes to take effect.');
  5578. }
  5579. })
  5580. )
  5581. ),
  5582. $('<tr>').append(
  5583. $('<td>').attr({ height: '1', bgcolor: 'black' })
  5584. ),
  5585. $('<tr>').append(
  5586. $('<td>').addClass('tableitem').attr('align', 'center').css('text-align', 'center').text('Report a Bug')
  5587. ),
  5588. $('<tr>').append(
  5589. $('<td>').attr({ height: '1', bgcolor: 'black' })
  5590. ),
  5591. $('<tr>').append(
  5592. $('<td>').attr('align', 'center').css('text-align', 'center').text(
  5593. 'Please report any bugs you might encounter on IRC in #beyond or post a comment '
  5594. ).append(
  5595. $('<a>').text('here.').css('text-decoration', 'underline').click(function() {
  5596. window.open('https://omertabeyond.net/');
  5597. }),
  5598. $('<br>'),
  5599. $('<span>').html('To help us track down the issue, please include the following code:'),
  5600. $('<br>'),
  5601. $('<strong>').text(localStorage.getItem('ob_uid'))
  5602. )
  5603. ),
  5604. $('<tr>').append(
  5605. $('<td>').attr({ height: '1', bgcolor: 'black' })
  5606. ),
  5607. $('<tr>').append(
  5608. $('<td>').addClass('tableitem').attr('align', 'center').css('text-align', 'center').text('Legal')
  5609. ),
  5610. $('<tr>').append(
  5611. $('<td>').attr({ height: '1', bgcolor: 'black' })
  5612. ),
  5613. $('<tr>').append(
  5614. $('<td>').attr('align', 'center').css('text-align', 'center').html(
  5615. 'By using OmertaBeyond you agree to our <a target="_blank" href="https://news.omertabeyond.net/terms">Terms of Service</a> and <a target="_blank" href="https://news.omertabeyond.net/privacy">Privacy Policy</a>.'
  5616. )
  5617. )
  5618. )
  5619. ); // here we can build prefs page
  5620.  
  5621. if (!('Notification' in window)) {
  5622. $('#Authmsg', prefs_page).text('Your browser doesn\'t support notifications');
  5623. $('#btnNotification', prefs_page).remove();
  5624. } else if (Notification.permission == 'granted') {
  5625. $('#Authmsg', prefs_page).text('Authorization for notification is: ').append(
  5626. $('<span>').text('granted').css({
  5627. 'font-weight': 'bold'
  5628. })
  5629. );
  5630. $('#btnNotification', prefs_page).remove();
  5631. }
  5632.  
  5633. return prefs_page;
  5634. }
  5635.  
  5636. /*
  5637. * Info grabber
  5638. */
  5639.  
  5640. var infoD = new Date(); // check once every hour for new info
  5641. if (typeof unsafeWindow.omerta !== 'undefined' && (getV('bninfo', -1) == -1 || getV('brcDate', -1) != infoD.getHours())) {
  5642. // Update shizzle
  5643. bnUpdate();
  5644. var nick = unsafeWindow.omerta.character.info.name();
  5645. $.get('//' + document.location.hostname + '/user.php?nick=' + nick, function (data) {
  5646. var a = data.split('<script');
  5647. $('#game_wrapper').append(
  5648. $('<div>').css('display', 'none').attr('id', 'xhr').html(a[0])
  5649. );
  5650. if ($('#xhr').length) {
  5651. var role = 1; // default is in a family
  5652. var pos = $('span#position').attr('value');
  5653. var fam = ($('span#family > a').length ? $('span#family > a').text() : $('span#family').text());
  5654. var hascapo = ($('span#capo').length) ? 1 : 0;
  5655. if (/None|Geen/.test(fam)) {
  5656. role = 0;
  5657. } else {
  5658. if (/Capo (of|van):/.test(pos)) {
  5659. role = 2;
  5660. }
  5661. if (/(Sottocapo|Consiglieri|Don) (of|van):/.test(pos)) {
  5662. role = 3;
  5663. }
  5664. if (hascapo) {
  5665. role = 4;
  5666. }
  5667. }
  5668. setV('family', fam);
  5669. setPow('bninfo', 4, role); // save
  5670. }
  5671. setV('brcDate', infoD.getHours());
  5672. $('#xhr').remove();
  5673. $('#str2dom').remove();
  5674. });
  5675. }
  5676.  
  5677. // Reset on death
  5678. 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')) {
  5679. if (confirm('Do you want to reset all OB data?')) {
  5680. clearUserData();
  5681. }
  5682. }
  5683.  
  5684. // Add focus on front page
  5685. $('input[name="email"]').focus();
  5686.  
  5687. // Replace Omerta's favicon
  5688. $('<link rel="shortcut icon" type="image/x-icon"/>').appendTo('head').attr('href', assetUrl('/images/favicon.png'));
  5689.  
  5690. /*
  5691. * Logos replacing
  5692. */
  5693.  
  5694. // Main logo in the game
  5695. $('#game_header_left').children('img').attr('src', assetUrl('/images/logo.png'));
  5696. if (v === 'dm') {
  5697. $('#omerta_header #logo').css({
  5698. 'background-image': 'url(' + assetUrl('/images/logo.png') + ')',
  5699. top: '2px',
  5700. left: '0px',
  5701. width: '549px',
  5702. height: '104px'
  5703. });
  5704. }
  5705. // Logo on homepage
  5706. $('img[src*="omerta-game-logo.gif"]').attr('src', assetUrl('/images/logo-old.png'));
  5707. $('img[src*="pic_bg-logo.png"]').attr('src', assetUrl('/images/logo-old.png'));
  5708. // Logo on /servers.php
  5709. $('img[src*="logo0.gif"]').attr('src', assetUrl('/images/logo-old.png'));
  5710.  
  5711. $.get(assetUrl('/scripts/beyond.css'), function(data) {
  5712. $('head').append('<style type="text/css">' + data + '</style>');
  5713. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement