Guest User

Untitled

a guest
Feb 19th, 2019
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 69.59 KB | None | 0 0
  1. // ==UserScript==
  2. // @name SE 4.0 Dark Version
  3. // @namespace
  4. // @version SE 3.0
  5. // @description Productivity fixes for chattcentralen
  6. // @author
  7. // @match https://chattcentralen.se/*
  8. // @grant none
  9. // ==/UserScript==a
  10.  
  11.  
  12. (function() {
  13. 'use strict';
  14. loadConfig();
  15. console.log(config);
  16. document.title = "✉ Chattcentralen - " + window.location.pathname.substr(1);
  17. switch(window.location.pathname) {
  18. case '/':
  19. console.log("Main page: inserting username and password");
  20. if(config.username)
  21. document.getElementsByClassName('username')[0].value = config.username;
  22. if(config.password)
  23. document.getElementsByClassName('password')[0].value = config.password;
  24. document.getElementsByClassName('ui-button')[1].focus();
  25. if(config.autoLogin && document.getElementsByClassName("messages")[0].textContent.indexOf("Please enter") > -1) {
  26. console.log("Autologin");
  27. document.getElementsByClassName('ui-button')[1].click();
  28. }
  29. break;
  30. case '/messages':
  31. shimFunctions();
  32. case '/announcements':
  33. case '/statistics':
  34. if(config.showCounters) {
  35. createCounters();
  36. getStats();
  37. }
  38. registerHotkeys();
  39. createSettingsButton();
  40. if(config.goToMessagesFirst && document.referrer == window.location.origin+'/')
  41. window.location = window.location.origin+'/messages';
  42. break;
  43. }
  44. })();
  45.  
  46. function loadConfig() {
  47. console.log("Loading config");
  48. var defaults = {
  49. hotkeys: ['', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''],
  50. username: '',
  51. password: '',
  52. autoLogin: false,
  53. showCounters: true,
  54. goToMessagesFirst: false,
  55. highlightMessagesNotes: true,
  56. searchAndOpen: false,
  57. notificationSound: true,
  58. hideProfilePics: false
  59. };
  60.  
  61. var local = JSON.parse(localStorage.getItem('config'));
  62. if(local === null)
  63. local = defaults;
  64. for (let i in defaults)
  65. if (!local.hasOwnProperty(i))
  66. local[i] = defaults[i];
  67. for (let i in local)
  68. if (!defaults.hasOwnProperty(i))
  69. delete local[i];
  70. console.log("\tConfig loaded");
  71.  
  72. Notification.requestPermission().then(function(result) {
  73. local.showNotifications = result === "granted";
  74. });
  75. config = local;
  76. }
  77.  
  78.  
  79.  
  80.  
  81. function focusMessageBox() {
  82. window.scroll(0, 0);
  83. document.getElementsByClassName('conversation-message-text')[0].focus();
  84. }
  85.  
  86. function getTargetName() {
  87. return document.getElementsByClassName('target-name')[0].textContent.slice(1);
  88. }
  89. function getUsername() {
  90. return document.getElementsByClassName("user")[0].textContent.match(/\w+/)[0];
  91. }
  92.  
  93. function notifyOperator() {
  94. if(document.hidden) {
  95. if(notifyOperator.notificationSound === undefined) {
  96. notifyOperator.notificationSound = new Audio("https://youtu.be/llcQu-XB6oE?t=10");
  97. }
  98. console.log("Sending notification");
  99. let oldTitle = document.title;
  100. let newTitle = "✉ New message!";
  101. let notification = new Notification("Chattcentralen", {body: "New message received!"});
  102. if(config.notificationSound) {
  103. notifyOperator.notificationSound.play();
  104. }
  105. setTimeout(() => {
  106. notification.close.bind(notification);
  107. }, 5000);
  108. var n = 0;
  109. function blinkTitle() {
  110. document.title = n%2 ? newTitle : oldTitle;
  111. n++;
  112. if(document.hidden)
  113. window.setTimeout(blinkTitle, 500);
  114. else
  115. document.title = oldTitle;
  116. }
  117. blinkTitle();
  118. window.focus();
  119. }
  120. }
  121.  
  122. function highlightMessagesNotes(element) {
  123. console.log("Highlighting messages and notes");
  124. let username = document.getElementsByClassName('target-name')[0].textContent.match(/\w+/)[0];
  125. for (let e of document.getElementsByClassName("from-to")) {
  126. if(e.textContent.indexOf(username) > -1) {
  127. e.parentElement.parentElement.style.background = highlightColor;
  128. }
  129. }
  130. let target = getTargetName();
  131.  
  132. }
  133.  
  134. (function(){
  135. let allowCopyAndPaste = function(e){
  136. e.stopImmediatePropagation();
  137. return true;
  138. };
  139.  
  140. document.addEventListener('copy', allowCopyAndPaste, true);
  141. document.addEventListener('paste', allowCopyAndPaste, true);
  142. document.addEventListener('contextmenu', allowCopyAndPaste, true);
  143. document.addEventListener('keydown', allowCopyAndPaste, true);
  144. })();
  145.  
  146.  
  147. /**
  148. * jQuery.autotype -
  149. */
  150. (function($){
  151.  
  152. // code type constants
  153. var CHARACTER = 1,
  154. NON_CHARACTER = 2,
  155. MODIFIER_BEGIN = 3,
  156. MODIFIER_END = 4,
  157. isNullOrEmpty = function(val) { return val === null || val.length === 0; },
  158. isUpper = function(char) { return char.toUpperCase() === char; },
  159. isLower = function(char) { return char.toLowerCase() === char; },
  160. areDifferentlyCased = function(char1,char2) {
  161. return (isUpper(char1) && isLower(char2)) ||
  162. (isLower(char1) && isUpper(char2));
  163. },
  164. convertCase = function(char) {
  165. return isUpper(char) ? char.toLowerCase() : char.toUpperCase();
  166. },
  167. parseCodes = function(value, codeMap) {
  168. // buffer to hold a collection of key/char code pairs corresponding to input string value
  169. var codes = [],
  170. // buffer to hold the name of a control key as it's being parsed
  171. definingControlKey = false,
  172. // hold a collection of currently pushed modifier keys
  173. activeModifiers = {
  174. alt: false,
  175. meta: false,
  176. shift: false,
  177. ctrl: false
  178. },
  179. explicitModifiers = $.extend({}, activeModifiers),
  180. // buffer to hold construction of current control key
  181. currentControlKey = '',
  182. previousChar = '',
  183. pushCode = function(opts) {
  184. codes.push($.extend({}, opts, activeModifiers));
  185. },
  186. pushModifierBeginCode = function(modifierName) {
  187. activeModifiers[modifierName] = true;
  188. pushCode({
  189. keyCode: codeMap[modifierName],
  190. charCode: 0,
  191. char: '',
  192. type: MODIFIER_BEGIN
  193. });
  194. },
  195. pushModifierEndCode = function(modifierName) {
  196. activeModifiers[modifierName] = false;
  197. pushCode({
  198. keyCode: codeMap[modifierName],
  199. charCode: 0,
  200. char: '',
  201. type: MODIFIER_END
  202. });
  203. };
  204.  
  205. for(var i=0;i<value.length;i++) {
  206. // if the character is about to define a control key
  207. if(!definingControlKey &&
  208. i <= value.length - 5 &&
  209. value.charAt(i) === '{' &&
  210. value.charAt(i+1) === '{')
  211. {
  212. // skip the next "{"
  213. i++;
  214.  
  215. definingControlKey = true;
  216. }
  217. // if the character is about to end definition of control key
  218. else if (definingControlKey &&
  219. i <= value.length - 2 &&
  220. value.charAt(i) === '}' &&
  221. value.charAt(i+1) === '}')
  222. {
  223. // skip the next "}"
  224. i++;
  225.  
  226. // check if this key is a modifier-opener (is a ctrl,alt,del,shift)
  227. if(activeModifiers[currentControlKey] !== undefined)
  228. {
  229. explicitModifiers[currentControlKey] = true;
  230. pushModifierBeginCode(currentControlKey);
  231. }
  232. // check if this key is a modifier-closer (is a /ctrl,/alt,/del,.shift)
  233. else if(activeModifiers[currentControlKey.substring(1)] !== undefined)
  234. {
  235. explicitModifiers[currentControlKey] = false;
  236. pushModifierEndCode(currentControlKey.substring(1));
  237. }
  238. // otherwise is some other kind of non-modifier control key
  239. else
  240. {
  241. pushCode({
  242. keyCode: codeMap[currentControlKey],
  243. charCode: 0,
  244. char: '',
  245. type: NON_CHARACTER,
  246. controlKeyName: currentControlKey
  247. });
  248. }
  249.  
  250. definingControlKey = false;
  251. currentControlKey = '';
  252. }
  253. // currently defining control key
  254. else if (definingControlKey)
  255. {
  256. currentControlKey += value.charAt(i);
  257. }
  258. // otherwise is just a text character
  259. else
  260. {
  261. var character = value.charAt(i);
  262.  
  263. // check for any implicitly changing of cases, and register presses/releases
  264. // of the shift key in accord with them.
  265. if(
  266. (!isNullOrEmpty(previousChar) && areDifferentlyCased(previousChar, character)) ||
  267. (isNullOrEmpty(previousChar) && isUpper(character))
  268. )
  269. {
  270. if(isUpper(character) && !activeModifiers.shift) {
  271. pushModifierBeginCode("shift");
  272. } else if (isLower(character) && activeModifiers.shift && !explicitModifiers.shift){
  273. pushModifierEndCode("shift");
  274. }
  275. }
  276.  
  277. // modify the current character if there are active modifiers
  278. if((activeModifiers.shift && isLower(character)) ||
  279. (!activeModifiers.shift && isUpper(character))) {
  280. // shift converts case
  281. character = convertCase(character);
  282. }
  283.  
  284. var code = {
  285. // if can't identify a keycode, just fudge with the char code.
  286. // nope, this isn't ideal by any means.
  287. keyCode: codeMap[character] || character.charCodeAt(0),
  288. charCode: character.charCodeAt(0),
  289. char: character,
  290. type: CHARACTER
  291. };
  292.  
  293. // modify the current character if there are active modifiers
  294. if(activeModifiers.alt ||
  295. activeModifiers.ctrl ||
  296. activeModifiers.meta) {
  297. // alt, ctrl, meta make it so nothing is typed
  298. code.char = '';
  299. }
  300. pushCode(code);
  301. if(code.char !== '') { previousChar = code.char; }
  302. }
  303. }
  304. return codes;
  305. },
  306. triggerCodeOnField = function(code, field) {
  307. // build up base content that every event should contain
  308. // with information about whether certain chord keys are
  309. // simulated as being pressed
  310. var evnt = {
  311. altKey: code.alt,
  312. metaKey: code.meta,
  313. shiftKey: code.shift,
  314. ctrlKey: code.ctrl
  315. };
  316.  
  317. // build out 3 event instances for all the steps of a key entry
  318. var keyDownEvent = $.extend($.Event(), evnt, {type:'keydown', keyCode: code.keyCode, charCode: 0, which: code.keyCode});
  319. var keyPressEvent = $.extend($.Event(), evnt, {type:'keypress', keyCode: 0, charCode: code.charCode, which: code.charCode || code.keyCode});
  320. var keyUpEvent = $.extend($.Event(), evnt, {type:'keyup', keyCode: code.keyCode, charCode: 0, which: code.keyCode});
  321.  
  322. // go ahead and trigger the first 2 (down and press)
  323. // a keyup of a modifier shouldn't also re-trigger a keydown
  324. if(code.type !== MODIFIER_END) {
  325. field.trigger(keyDownEvent);
  326. }
  327.  
  328. // modifier keys don't have a keypress event, only down or up
  329. if(code.type !== MODIFIER_BEGIN && code.type !== MODIFIER_END) {
  330. field.trigger(keyPressEvent);
  331. }
  332.  
  333. // only actually add the new character to the input if the keydown or keypress events
  334. // weren't cancelled by any consuming event handlers
  335. if(!keyDownEvent.isPropagationStopped() &&
  336. !keyPressEvent.isPropagationStopped()) {
  337. if(code.type === NON_CHARACTER) {
  338. switch(code.controlKeyName) {
  339. case 'enter':
  340. field.val(field.val() + "\n");
  341. break;
  342. case 'back':
  343. field.val(field.val().substring(0,field.val().length-1));
  344. break;
  345. }
  346. } else {
  347. field.val(field.val() + code.char);
  348. }
  349. }
  350.  
  351. // then also trigger the 3rd event (up)
  352. // a keydown of a modifier shouldn't also trigger a keyup until coded
  353. if(code.type !== MODIFIER_BEGIN) {
  354. field.trigger(keyUpEvent);
  355. }
  356. },
  357. triggerCodesOnField = function(codes, field, delay, global) {
  358. if(delay > 0) {
  359. codes = codes.reverse();
  360. var keyInterval = global.setInterval(function(){
  361. var code = codes.pop();
  362. triggerCodeOnField(code, field);
  363. if(codes.length === 0) {
  364. global.clearInterval(keyInterval);
  365. field.trigger('autotyped');
  366. }
  367. }, delay);
  368. } else {
  369. $.each(codes,function(){
  370. triggerCodeOnField(this, field);
  371. });
  372. field.trigger('autotyped');
  373. }
  374. };
  375.  
  376. $.fn.autotype = function(value, options) {
  377. if(value === undefined || value === null) { throw("Value is required by jQuery.autotype plugin"); }
  378. var settings = $.extend({}, $.fn.autotype.defaults, options);
  379.  
  380. // 1st Pass
  381. // step through the input string and convert it into
  382. // a logical sequence of steps, key, and charcodes to apply to the inputs
  383. var codes = parseCodes(value, settings.keyCodes[settings.keyBoard]);
  384.  
  385. // 2nd Pass
  386. // Run the translated codes against each input through a realistic
  387. // and cancelable series of key down/press/up events
  388. return this.each(function(){ triggerCodesOnField(codes, $(this), settings.delay, settings.global); });
  389. };
  390.  
  391. $.fn.autotype.defaults = {
  392. version: '0.5.0',
  393. keyBoard: 'enUs',
  394. delay: 0,
  395. global: window,
  396. keyCodes: {
  397. enUs: { 'back':8,'ins':45,'del':46,'enter':13,'shift':16,'ctrl':17,'meta':224,
  398. 'alt':18,'pause':19,'caps':20,'esc':27,'pgup':33,'pgdn':34,
  399. 'end':35,'home':36,'left':37,'up':38,'right':39,'down':40,
  400. 'printscr':44,'num0':96,'num1':97,'num2':98,'num3':99,'num4':100,
  401. 'num5':101,'num6':102,'num7':103,'num8':104,'num9':105,
  402. 'multiply':106,'add':107,'subtract':109,'decimal':110,
  403. 'divide':111,'f1':112,'f2':113,'f3':114,'f4':115,'f5':116,
  404. 'f6':117,'f7':118,'f8':119,'f9':120,'f10':121,'f11':122,
  405. 'f12':123,'numlock':144,'scrolllock':145,' ':9,' ':32,
  406. 'tab':9,'space':32,'0':48,'1':49,'2':50,'3':51,'4':52,
  407. '5':53,'6':54,'7':55,'8':56,'9':57,')':48,'!':49,'@':50,
  408. '#':51,'$':52,'%':53,'^':54,'&':55,'*':56,'(':57,';':186,
  409. '=':187,',':188,'-':189,'.':190,'/':191,'[':219,'\\':220,
  410. ']':221,"'":222,':':186,'+':187,'<':188,'_':189,'>':190,
  411. '?':191,'{':219,'|':220,'}':221,'"':222,'a':65,'b':66,'c':67,
  412. 'd':68,'e':69,'f':70,'g':71,'h':72,'i':73,'j':74,'k':75,
  413. 'l':76,'m':77,'n':78,'o':79,'p':80,'q':81,'r':82,'s':83,
  414. 't':84,'u':85,'v':86,'w':87,'x':88,'y':89,'z':90,'A':65,
  415. 'B':66,'C':67,'D':68,'E':69,'F':70,'G':71,'H':72,'I':73,
  416. 'J':74,'K':75,'L':76,'M':77,'N':78,'O':79,'P':80,'Q':81,
  417. 'R':82,'S':83,'T':84,'U':85,'V':86,'W':87,'X':88,'Y':89,'Z':90, 'Å':197, 'Ä':196, 'Ö':214}
  418. }
  419. };
  420.  
  421. })(jQuery);
  422.  
  423. //Function to focus end of text
  424. (function($){
  425. $.fn.focusTextToEnd = function(){
  426. this.focus();
  427. var $thisVal = this.val();
  428. this.val('').val($thisVal);
  429. return this;
  430. }
  431. }(jQuery));
  432. //Copy text between textareas
  433. $(".counters-column6").on("input", function(e){
  434. var length = $(".counters-column6").val().length;
  435. if (length > 4) {
  436. //Transfering text
  437. var Text = $(".counters-column6").val();
  438. $(".conversation-message-text").autotype(Text);
  439. //Delete Text in first field
  440. $(".counters-column6").val('');
  441. //Focus main TextField
  442. window.scroll(0, 0);
  443. $(".conversation-message-text").focusTextToEnd();
  444. }
  445. });
  446.  
  447. function copySelectionText(){
  448. var copysuccess // var to check whether execCommand successfully executed
  449. try{
  450. copysuccess = document.execCommand("copy") // run command to copy selected text to clipboard
  451. } catch(e){
  452. copysuccess = false
  453. }
  454. return copysuccess
  455. }
  456.  
  457.  
  458. window.afterConversationLoaded = function() {
  459. console.log("Loaded conversation");
  460. getStats();
  461. notifyOperator();
  462.  
  463. console.log("Registering emoji click refocusing");
  464. for(let e of document.getElementsByClassName('emoji-insert')) {
  465. e.addEventListener('click', focusMessageBox);
  466. }
  467.  
  468. console.log("Registering automatic photo adding");
  469. for(let e of document.getElementById('AddMediaDialog').getElementsByClassName("mediaAddContainer")) {
  470. e.addEventListener('click', () => {
  471. e.getElementsByTagName("img")[0].click();
  472. e.getElementsByTagName("input")[0].click();
  473. $('#btnAddMedia').button('enable')[0].click();
  474. focusMessageBox();
  475. });
  476. }
  477.  
  478. //Textfield to show after conversation loaded//
  479. $(".counters-column6").css("visibility","visible");
  480.  
  481. //Hidning profile Pics//
  482. var picL = document.getElementsByClassName('player-photo-src');
  483. var picR = document.getElementsByClassName('target-photo-src');
  484. if (config.hideProfilePics) {
  485. $(picL).css("visibility","hidden");
  486. $(picR).css("visibility","hidden");
  487.  
  488. };
  489.  
  490.  
  491. let highlightColor = "rgb(255, 211, 20)";
  492. var target = document.getElementById('conversation-content');
  493. if(config.highlightMessagesNotes) {
  494. console.log("Highlighting own messages");
  495. for(let e of document.getElementById("conversation-messages").getElementsByClassName('from-to')) {
  496. let parentParent = e.parentElement.parentElement;
  497. if(e.textContent.slice(1).indexOf(getTargetName()) > -1) {
  498. parentParent.style.background = "rgb(145, 145, 145)";
  499.  
  500. }else{
  501.  
  502. parentParent.style.background = "rgb(107, 107, 107)";
  503. }
  504.  
  505. }
  506.  
  507. console.log("Highlighting target notes");
  508. let ending = getTargetName().toUpperCase();
  509. for(let e of document.getElementsByClassName('player-last-notes')[0].children) {
  510. if(e.children[2].textContent.toUpperCase().replace(/[\ \)]*$/,"").indexOf(ending) > -1) {
  511. e.style.background = highlightColor;
  512. }
  513. }
  514. }
  515.  
  516.  
  517. let targetNotesContent = document.getElementsByClassName('target-note-content')[0];
  518. document.addEventListener('selectionchange', (e) => {
  519. let anchor = document.getSelection().anchorNode;
  520. if(anchor && anchor.nodeType === Node.TEXT_NODE) {
  521. anchor = anchor.parentElement;
  522. }
  523. if(anchor.classList.contains('message-text')) {
  524. targetNotesContent.value = window.getSelection().toString();
  525. }
  526. });
  527.  
  528. setTimeout(function () {
  529. var convId = $('#conversation-content .message-last-in-id').val(), image = document.getElementById("conversation-messages").getElementsByClassName('attach'),
  530. messId = 'table-msg-row table-msg-row-' + (convId);
  531. if(config.searchAndOpen) {
  532. for(let e of document.getElementById("conversation-messages").getElementsByClassName('from-to')) {
  533. let img = e.parentElement.parentElement.parentElement.parentElement;
  534. if(img.className.match(messId) && e.textContent.slice(1).indexOf(getTargetName()) > -1) {
  535. let e = document.getElementsByClassName('conversation-attachment')[0];
  536. var f = e.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement;
  537. if(e !== undefined && f.className.match(messId)) {
  538. e.click();
  539. }
  540. }
  541.  
  542. }
  543. }
  544. }, 1500);
  545.  
  546. // Adds :containsNC - non case-sensitive :contains
  547. $.extend($.expr[":"], {
  548. "containsNC": function(elem, i, match, array) {
  549. return (elem.textContent || elem.innerText || "").toLowerCase().indexOf((match[3] || "").toLowerCase()) >= 0;
  550. }
  551. });
  552. var e = document.getElementsByClassName('conversation-attachment')[0];
  553. var winClosed = setInterval(function () {
  554.  
  555. if (e.closed) {
  556. clearInterval(winClosed);
  557. var text = prompt('Save Picture:', )
  558. // Insert text to note
  559. $('.target-note-content.area').val(text);
  560. // Select note category
  561. var category = 'bilder';
  562. // Categories
  563. $('select.target-note-categories option:containsNC("' + category + '")').attr('selected', 'selected');
  564. // Save note
  565. $('.target-save-note').trigger('click')
  566. //Focus TextField
  567. window.scroll(0, 0);
  568. $( ".conversation-message-text" ).focus();
  569. }
  570.  
  571. }, 250);
  572.  
  573.  
  574.  
  575.  
  576.  
  577.  
  578. }
  579.  
  580. function shimFunctions() {
  581. /*
  582. if(config.showCounters) {
  583. console.log("Adding statistics counters");
  584. loadConversation = (function() {
  585. var cached_loadConversation = loadConversation;
  586. return function() {
  587. var result = cached_loadConversation.apply(this, arguments);
  588. afterConversationLoaded();
  589. return result;
  590. };
  591. })();
  592. }
  593. /*/
  594. console.log("Adding statistics counters????");
  595. if(config.showCounters) {
  596. console.log("Adding statistics counters");
  597. loadConversation = new Function(
  598. "id",
  599. "doPreload",
  600. "review",
  601. "fromClaimNext",
  602. "claimNextType",
  603. loadConversation.toString()
  604. .replace("userIdleTime = 0;", "userIdleTime = 0;\n\t\tafterConversationLoaded();")
  605. .replace(/^function[^{]+{/i,"")
  606. .replace(/}[^}]*$/i, "")
  607. );
  608. }
  609. //*/
  610.  
  611. }
  612.  
  613. function registerHotkeys() {
  614. console.log("Registering hotkeys");
  615. var helperFunctions = new Map();
  616. var helpFunctions = new Map();
  617.  
  618. helperFunctions.set(config.hotkeys[0], //
  619. () => {
  620. let e = document.getElementsByClassName('conversation-attachment')[0];
  621. if(e !== undefined) {
  622. e.click();
  623. if (e.closed) {
  624. clearInterval(winClosed);
  625. var text = prompt('Save Picture:', )
  626. // Insert text to note
  627. $('.target-note-content.area').val(text);
  628. // Select note category
  629. var category = 'bilder';
  630. // Categories
  631. $('select.target-note-categories option:containsNC("' + category + '")').attr('selected', 'selected');
  632. // Save note
  633. $('.target-save-note').trigger('click')
  634. //Focus TextField
  635. window.scroll(0, 0);
  636. $( ".conversation-message-text" ).focus();
  637. }
  638. }
  639.  
  640. });
  641. helperFunctions.set(config.hotkeys[1], //
  642. () => {
  643. // Adds :containsNC - non case-sensitive :contains
  644. $.extend($.expr[":"], {
  645. "containsNC": function(elem, i, match, array) {
  646. return (elem.textContent || elem.innerText || "").toLowerCase().indexOf((match[3] || "").toLowerCase()) >= 0;
  647. }
  648. });
  649.  
  650.  
  651. var copysuccess = copySelectionText() // copy user selected text to clipboard
  652. var mypopup = window.open('https://www.google.se/maps', '_blank', 'height=600px, width=1200px')
  653.  
  654. var winClosed = setInterval(function () {
  655.  
  656. if (mypopup.closed) {
  657. clearInterval(winClosed);
  658. // Insert Stad
  659. var text = prompt('Player Stad:', );
  660. // Extract target name
  661. var targetName = $('.target-name').text();
  662. // Trim period from target name
  663. var targetNamee = targetName.substr(1);
  664. // Insert text to note
  665. $('.player-note-content.area').val(text);
  666. var f = $('.player-note-content.area').val();
  667. var e = $('.player-note-content.area');
  668. $(e).val( f + ' (' + targetNamee + ')');
  669. // Select note category
  670. var category = 'stad';
  671. // Categories
  672. $('select.player-note-categories option:containsNC("' + category + '")').attr('selected', 'selected');
  673. // Save note
  674. $('.player-save-note').trigger('click')
  675. //Focus TextField
  676. window.scroll(0, 0);
  677. $(".counters-column6").val('Jag bor i ' + f);
  678. $('.counters-column6').focusTextToEnd();
  679. $(".counters-column6").trigger({type: 'keypress', which: 32, keyCode: 32});
  680. }
  681.  
  682. }, 250);
  683.  
  684. });
  685. helperFunctions.set(config.hotkeys[2], focusMessageBox); // Go to message box
  686. helperFunctions.set(config.hotkeys[3], // Focus Custom TextField(Column6)
  687. () => {
  688. //Focus TextField
  689. $( ".counters-column6" ).focusTextToEnd();
  690. });
  691. helperFunctions.set(config.hotkeys[4], // Add image
  692. () => {
  693. $('.conversation-show-more').trigger('click');
  694. });
  695. helperFunctions.set(config.hotkeys[5], // Remove image
  696. () => {
  697. let e = document.getElementsByClassName('message-delmedia-button')[0];
  698. if(e !== undefined) {
  699. e.click();
  700. }
  701. });
  702. helperFunctions.set(config.hotkeys[6], // Go to Messages
  703. () => {
  704. $('button[rel="messages"]').click();
  705. });
  706. helperFunctions.set(config.hotkeys[7], // Go to Stopped Messages
  707. () => {
  708. $('button[rel="stopped"]').click();
  709. });
  710. helperFunctions.set(config.hotkeys[8], // Go to Unread Messages
  711. () => {
  712. $('button[rel="unread"]').click();
  713. });
  714. helperFunctions.set(config.hotkeys[9], // Generate Hobbies and save to Notes
  715. () => {
  716. // Adds :containsNC - non case-sensitive :contains
  717. $.extend($.expr[":"], {
  718. "containsNC": function(elem, i, match, array) {
  719. return (elem.textContent || elem.innerText || "").toLowerCase().indexOf((match[3] || "").toLowerCase()) >= 0;
  720. }
  721. });
  722.  
  723. var interests = [' astrologi' ,'bakning' ,'basta' ,'bilar' ,'bio' ,'brädspel' ,'båtar' ,'böcker' ,'campa' ,'cykla' ,'dansa' ,'datorer' ,'dekorera' ,'djur' ,'film' ,'fiska' ,'flyga' ,'fotboll' ,'fotografera' ,'friluftsliv' ,'friskvård' ,'gymnastik' ,'hund' ,'husdjur' ,'hälsa' ,'jogga' ,'katt' ,'klättring' ,'konserter' ,'konst' ,'litteratur' ,'matlagning' ,'meditera' ,'motorcyklar' ,'museum' ,'musik' ,'måla' ,'natur' ,'opera' ,'politik' ,'promenera' ,'pyssla' ,'religion' ,'renovera' ,'resa' ,'rida' ,'segla' ,'simma' ,'skidor' ,'skådespel' ,'social media' ,'spela kort' ,'tatueringar' ,'teater' ,'teckna' ,'teknik' ,'trädgård' ,'träna' ,'tv' ,'umgås' ,'uteliv' ,'vandra' ,'vinprovning' ,'vintersport' ,'äta ute'];
  724.  
  725. var n = ~~(Math.random() * 4) + 2;
  726.  
  727. var rand = [];
  728. do {
  729. rand[rand.length] = interests.splice(Math.floor(Math.random() * interests.length), 1)[0];
  730. } while (rand.length < n);
  731.  
  732. var hoBB = rand;
  733.  
  734. // Extract target name
  735. var targetName = $('.target-name').text();
  736. // Trim period from target name
  737. var targetNamee = targetName.substr(1);
  738. // Insert text to note
  739. $('.player-note-content.area').val(hoBB);
  740. var f = $('.player-note-content.area').val();
  741. var e = $('.player-note-content.area');
  742. $(e).val( f + ' (' + targetNamee + ')');
  743. // Select note category
  744. var category = 'Hobby';
  745.  
  746. $('select.player-note-categories option:containsNC("' + category + '")').attr('selected', 'selected');
  747. // Save note
  748. $('.player-save-note').trigger('click')
  749.  
  750. //Autotype text to Message
  751. $('.conversation-message-text').autotype(f);
  752. });
  753. helperFunctions.set(config.hotkeys[10], // Generera Sexintressen + spara i Notes
  754. () => {
  755. // Adds :containsNC - non case-sensitive :contains
  756. $.extend($.expr[":"], {
  757. "containsNC": function(elem, i, match, array) {
  758. return (elem.textContent || elem.innerText || "").toLowerCase().indexOf((match[3] || "").toLowerCase()) >= 0;
  759. }
  760. });
  761.  
  762. var interests = [' analt' ,' bakifrån' ,' bli bunden' ,' att binda' ,' använda buttplug' ,' använda dildo' ,' dominans' ,' kyssar' ,' långa förspel' ,' missionären' ,' ögonbindel' ,' offentliga platser' ,' onani' ,' hårdare smisk' ,' att rida' ,' rollspel' ,' sexiga underkläder' ,' sexleksaker' ,' skeda' ,' att suga' ,' att svälja' ,' teasing' ,' vaniljsex'];
  763.  
  764. var n = ~~(Math.random() * 4) + 2;
  765.  
  766. var rand = [];
  767. do {
  768. rand[rand.length] = interests.splice(Math.floor(Math.random() * interests.length), 1)[0];
  769. } while (rand.length < n);
  770.  
  771. var sex = rand;
  772.  
  773. // Extract target name
  774. var targetName = $('.target-name').text();
  775. // Trim period from target name
  776. var targetNamee = targetName.substr(1);
  777. // Insert text to note
  778. $('.player-note-content.area').val(sex);
  779. var f = $('.player-note-content.area').val();
  780. var e = $('.player-note-content.area');
  781. $(e).val( f + ' (' + targetNamee + ')');
  782.  
  783. // Select note category
  784. var category = 'Sexuella preferenser';
  785.  
  786. $('select.player-note-categories option:containsNC("' + category + '")').attr('selected', 'selected');
  787. // Save note
  788. $('.player-save-note').trigger('click')
  789.  
  790. //Autotype text to Message
  791. $('.conversation-message-text').autotype(f);
  792. });
  793. helperFunctions.set(config.hotkeys[11], // Player Jobb+Spara i Notes
  794. () => {
  795. // Adds :containsNC - non case-sensitive :contains
  796. $.extend($.expr[":"], {
  797. "containsNC": function(elem, i, match, array) {
  798. return (elem.textContent || elem.innerText || "").toLowerCase().indexOf((match[3] || "").toLowerCase()) >= 0;
  799. }
  800. });
  801.  
  802. //Extract Player Proffesion//
  803. var playerjob = $('.profession').text().toLowerCase();
  804. // Extract target name
  805. var targetName = $('.target-name').text();
  806. // Trim period from target name
  807. var targetNamee = targetName.substr(1);
  808. // Insert text to note
  809. $('.player-note-content.area').val(playerjob + ' (' + targetNamee + ')');
  810. // Select note category
  811. var category = 'jobb/utbildning';
  812. // Categories
  813. $('select.player-note-categories option:containsNC("' + category + '")').attr('selected', 'selected');
  814. // Save note
  815. $('.player-save-note').trigger('click')
  816.  
  817. //paste proffesion//
  818.  
  819. $('.conversation-message-text').autotype(playerjob);
  820. });
  821. helperFunctions.set(config.hotkeys[12], // Retrieve Player Name and Save to Notes
  822. () => {
  823. // Adds :containsNC - non case-sensitive :contains
  824. $.extend($.expr[":"], {
  825. "containsNC": function(elem, i, match, array) {
  826. return (elem.textContent || elem.innerText || "").toLowerCase().indexOf((match[3] || "").toLowerCase()) >= 0;
  827. }
  828. });
  829.  
  830. var playername = $('.real_name').text();
  831. // Extract target name
  832. var targetName = $('.target-name').text();
  833. // Trim period from target name
  834. var targetNamee = targetName.substr(1);
  835. // Insert text to note
  836. $('.player-note-content.area').val(playername + ' (' + targetNamee + ')');
  837. // Select note category
  838. var category = 'namn';
  839. // Categories
  840. $('select.player-note-categories option:containsNC("' + category + '")').attr('selected', 'selected');
  841. // Save note
  842. $('.player-save-note').trigger('click')
  843.  
  844. //Autotype text to Message
  845. $('.conversation-message-text').autotype(playername);
  846. });
  847.  
  848. helperFunctions.set(config.hotkeys[13], // Target Notes+Autoval av Kategori
  849. () => {
  850. // Adds :containsNC - non case-sensitive :contains
  851. $.extend($.expr[":"], {
  852. "containsNC": function(elem, i, match, array) {
  853. return (elem.textContent || elem.innerText || "").toLowerCase().indexOf((match[3] || "").toLowerCase()) >= 0;
  854. }
  855. });
  856.  
  857. // Extract selected text
  858. var note = window.getSelection().toString();
  859. // Modify and verify selected text
  860. var text = prompt('Target note:', note);
  861. // Insert text to note
  862. $('.target-note-content.area').val(text);
  863. // Select note category
  864. var category;
  865. if (text.match(/bild|selfie|kuk|gif/i)) {
  866. var category = 'Bilder';
  867. } else if (text.match(/singel|barn|son|söner|döttrar|dotter|fru|särbo|sambo|gift|skild|änk/i)) {
  868. var category = 'Familj/Relationer';
  869. } else if (text.match(/jobb|arbetar|plugg|stude|pension|kör buss|kör lastbil|kör taxi|på järnvägen|chef|kock|vakt|pilot|polis|bagare|förare|frisör|jurist|läkare|lärare|ledare|målare|montör|rektor|advokat|konsult|optiker|pedagog|säljare|väktare|arbetare|arkitekt|brandman|chaufför|designer|fotograf|ingenjör|operatör|snickare|arbetslös|assistent|bartender|maskinist|sköterska|veterinär|elektriker|journalist|hantverkare|programmerare|projektledare|mekaniker|driver eget|företag|firma|måleri|snickeri|verkstad/i)) {
  870. var category = 'Jobb/Utbildning';
  871. } else if (text.match(/hund|katt|husdjur|spela|träna|astrologi|basta|bakning|bilar|bio|film|brädspel|båtar|böcker|litteratur|campa|cykla|dansa|datorer|dekorera|djur|fiska|flyga|fotboll|fotografera|friluftsliv|gymnastik|hälsa|friskvård|jogga|klättring|konserter|konst|museum|matlagning|meditera|motorcyklar|musik|måla|natur|nyheter|politik|opera|promenera|pyssla|religion|renovera|resa|rida|resa|segla|simma|skidor|skådespel|social media|tatueringar|teater|teckna|teknik|trädgård|träna|tv|umgås|uteliv|vandra|vinprovning|vintersport|äta ute/i)) {
  872. var category = 'Hobby';
  873. } else if (text.match(/bor i|Karlskrona|Karlshamn|Borås|Borlänge/i)) {
  874. var category = 'Stad';
  875. } else if (text.match(/heter|Abbe|Abdullah|Abraham|Adam|Adel|Adis|Agris|Agua|Alaga|Albert|Albin|Alek|Alex|Alexander|Alf|Alfred|Ali|Allan|Amir|Anders|Andreas|André|Andy|Ante|Anton|Ants|Ari|Aristides|Arne|Arto|Arvid|Axel|Azar|Behzad|Bengt/i)) {
  876. var category = 'Namn';
  877. } else if (text.match(/Bengt-Åke|Benny|Bernt|Bernt-Olov|Bernth|Bert|Bertil|Birger|Birgir|Bjarne|Björn|Bo|Bogdan|Boris|Bosse|Bror|Börge|Börje|Calle|Calmer|Carl|Carsten|Chaban|Charlie|Chris|Christer|Christian|Christoffer|Christophe|Christopher/i)) {
  878. var category = 'Namn';
  879. } else if (text.match(/Claes|Classe|Claudiu|Conny|Costas|Dan|Dane|Daniel|Danne|David|Davide|Davor|Deivys|Demir|Dennis|Derek|Dick|Edi|Edvard|Edvin|Ego|Eije|Einar|Eki|Elias|Emanuel|Emil|Emir|Eric|Erik|Erland|Evert|Ewen|Farid|Filip|Folke|Francesco/i)) {
  880. var category = 'Namn';
  881. } else if (text.match(/Franjo|Frank|Freddie|Fredrik|Friedhelm|Frode|Fugus|Gabriel|Georg|Gerald|Gerd|Gerra|Gert|Gert-Owe|Getahun|Gunnar|Gustaf|Gustav|Göran|Görgen|Görgen|Gösta|Göte|Habib|Hans|Hans Börge|Harald|Harri|Harry|Hasse|Helmut|Henke|Henrik|Henry|Hossein|Hugo|Håkan|Ihsan|Inge|Ingemar|Ingmar/i)) {
  882. var category = 'Namn';
  883. } else if (text.match(/Ingvar|Isaac|Isac|Isak|Ismail|Ivar|Jack|Jakob|Jan|Janne|Jean|Jens|Jerry|Jesper|Jhonatan|Jimmy|Joakim|Joar|Jocke|Joel|Johan|Johannes|John|Johnny|Jon|Jonas|Jonathan|Jonny|Juan|Julius|Jyrki|Jörgen|Kai|Kaj|Kalle|Kari|Karl|Karl Gustav|Karl-Erik|Karl-Olov|Karol|Ken|Kenneth|Kenny|Kent|Kenta/i)) {
  884. var category = 'Namn';
  885. } else if (text.match(/Kenth|Kieren|Kim|Kjell|Kjelle|Klas|Knut|Krister|Kristian|Kristoffer|Kurt|Kurt-Lennart|Kutte|Kåge|Lars|Lars Olov|Larsa|Larte|Larui|Lasse|Leif|Lellas|Lennart|Leo|Leon|Linus|Lucky|Ludvig|Magnus|Manne|Manuel|Marco|Marcus|Marek|Marian|Mario|Mark|Marko|Markus|Martin|Mathias|Mats|Matsvo|Matte|Matti|Mattias|Max|Melker|Michael|Michel|Micke|Mika|Mikael|Mikael|Mille|Miron|Misa|Mohamed|Mohammed/i)) {
  886. var category = 'Namn';
  887. } else if (text.match(/Morgan|Musa|Mustapha|Måns|Mårten|Nicke|Nicklas|Nicky|Niclas|Niklas|Nille|Nils|Nisse|Nurko|Ola|Oliver|Olle|Olof|Olov|Oscar|Oskar|Ove|Owe|Parsia|Pasi|Patric|Patrick|Patrik|Paul|Pavel|Peder|Pelle|Peo|Per|Per-Olof|Peter|Pether|Petter|Philip|Pierre|Pontus|Poul|Putte|Pär|Rafael|Rafeo|Ragnar|Raimo|Rasmus|Riccardo|Richard|Rickard|Rikard|Rimtaf|Risto|Robban|Robert|Robin|Roffe|Roger|Roland|Rolf|Rolle|Romii|Ronnie|Ronny|Ruben|Rune|Sabah|Sajad|Saladin|Sam|Samuel|Sebastian|Seed|Serko|Sigge|Silvo|Simon|Stefan|Steffen|Sten|Sten-Åke|Stig|Stig-Evert|Sture|Sune|Sven|Sven Erik|Sven Ingvar|Sven Åke|Sven-Erik|Sven-Gunnar|Sven-Åke|Sören|Tage|Taha|Tapio|Ted|Thomas|Thorbjörn|Tobbe|Tobias|Tobias|Tom|Tomas|Tommy|Tony|Torbjörn|Tord|Tore|Torgny|Torsten|Uffe|Ulf|Ulrik|Uno|Urban|Valentin|Victor|Viktor|Vilhelm|Waldemar|Wiktor|Wilhelm|William|Wojtek|Yngve|Yousef|Zdislav|Åke|Öyvind/i)) {
  888. var category = 'Namn';
  889. } else if (text.match(/anal|bakifrån|bunden|buttplug|dildo|dominans|kyssar|förspel|missionär|mystik|offentlig|onan|piska|rollspel|underkläder|sexleksaker|strap-on|suga|svälja|teasing|trekant|kondom|vaniljsex|wet/i)) {
  890. var category = 'Sexuella preferenser';
  891. } else if (text.match(/bil|mc|motorcykel/i)) {
  892. var category = 'Transportmedel';
  893. } else if (text.match(/mejl|mail|telef|skype|kik|fb|facebook/i)) {
  894. var category = 'Mejl och telefon';
  895. } else if (text.match(/sjuk/i)) {
  896. var category = 'Hälsa';
  897. } else var category = prompt('Select category:');
  898. // Categories
  899. $('select.target-note-categories option:containsNC("' + category + '")').attr('selected', 'selected');
  900. // Save note
  901. $('.target-save-note').trigger('click')
  902. //Focus TextField
  903. window.scroll(0, 0);
  904. $( ".conversation-message-text" ).focus();
  905. });
  906. helperFunctions.set(config.hotkeys[14], // Save to Target Aktuellt
  907. () => {
  908. // Adds :containsNC - non case-sensitive :contains
  909. $.extend($.expr[":"], {
  910. "containsNC": function(elem, i, match, array) {
  911. return (elem.textContent || elem.innerText || "").toLowerCase().indexOf((match[3] || "").toLowerCase()) >= 0;
  912. }
  913. });
  914.  
  915. // Extract selected text
  916. var note = window.getSelection().toString();
  917. // Insert text to note
  918. $('.target-note-content.area').val(note);
  919. // Select note category
  920. var category = 'aktuella saker';
  921. // Categories
  922. $('select.target-note-categories option:containsNC("' + category + '")').attr('selected', 'selected');
  923. // Save note
  924. $('.target-save-note').trigger('click')
  925. //Focus TextField
  926. window.scroll(0, 0);
  927. $( ".conversation-message-text" ).focus();
  928. });
  929. helperFunctions.set(config.hotkeys[15], // Save To Player Auto Category
  930. () => {
  931. // Adds :containsNC - non case-sensitive :contains
  932. $.extend($.expr[":"], {
  933. "containsNC": function(elem, i, match, array) {
  934. return (elem.textContent || elem.innerText || "").toLowerCase().indexOf((match[3] || "").toLowerCase()) >= 0;
  935. }
  936. });
  937. //Function to focus end of text
  938. (function($){
  939. $.fn.focusTextToEnd = function(){
  940. this.focus();
  941. var $thisVal = this.val();
  942. this.val('').val($thisVal);
  943. return this;
  944. }
  945. }(jQuery));
  946. // Extract selected text
  947. var note = window.getSelection().toString();
  948. // Modify and verify selected text
  949. var text = prompt('Player note:', note);
  950. // Extract target name
  951. var targetName = $('.target-name').text();
  952. // Trim period from target name
  953. var targetNamee = targetName.substr(1);
  954. // Insert text to note
  955. $('.player-note-content.area').val(text + ' (' + targetNamee + ')');
  956. // Select note category
  957. var category;
  958. if (text.match(/bild|selfie|kuk|gif/i)) {
  959. var category = 'Bilder';
  960. } else if (text.match(/singel|barn|son|söner|döttrar|dotter|fru|särbo|sambo|gift|skild|änk/i)) {
  961. var category = 'Familj/Relationer';
  962. } else if (text.match(/jobb|arbetar|plugg|stude|pension|kör buss|kör lastbil|kör taxi|på järnvägen|chef|kock|vakt|pilot|polis|bagare|förare|frisör|jurist|läkare|lärare|ledare|målare|montör|rektor|advokat|konsult|optiker|pedagog|säljare|väktare|arbetare|arkitekt|brandman|chaufför|designer|fotograf|ingenjör|operatör|snickare|arbetslös|assistent|bartender|maskinist|sköterska|veterinär|elektriker|journalist|hantverkare|programmerare|projektledare|mekaniker|driver eget|företag|firma|måleri|snickeri|verkstad/i)) {
  963. var category = 'Jobb/Utbildning';
  964. } else if (text.match(/hund|katt|husdjur|spela|träna|astrologi|basta|bakning|bilar|bio|film|brädspel|båtar|böcker|litteratur|campa|cykla|dansa|datorer|dekorera|djur|fiska|flyga|fotboll|fotografera|friluftsliv|gymnastik|hälsa|friskvård|jogga|klättring|konserter|konst|museum|matlagning|meditera|motorcyklar|musik|måla|natur|nyheter|politik|opera|promenera|pyssla|religion|renovera|resa|rida|resa|segla|simma|skidor|skådespel|social media|tatueringar|teater|teckna|teknik|trädgård|träna|tv|umgås|uteliv|vandra|vinprovning|vintersport|äta ute/i)) {
  965. var category = 'Hobby';
  966. } else if (text.match(/bor i|Karlskrona|Karlshamn|Borås|Borlänge/i)) {
  967. var category = 'Stad';
  968. } else if (text.match(/heter/i)) {
  969. var category = 'Namn';
  970. } else if (text.match(/anal|bakifrån|bunden|buttplug|dildo|dominans|kyssar|förspel|missionär|mystik|offentlig|onan|piska|rollspel|underkläder|sexleksaker|strap-on|suga|svälja|teasing|trekant|kondom|vaniljsex|wet/i)) {
  971. var category = 'Sexuella preferenser';
  972. } else if (text.match(/bil|mc|motorcykel/i)) {
  973. var category = 'Transportmedel';
  974. } else if (text.match(/mejl|mail|telef|skype|kik|fb|facebook/i)) {
  975. var category = 'Mejl och telefon';
  976. } else if (text.match(/sjuk/i)) {
  977. var category = 'Hälsa';
  978. } else var category = prompt('Select category:');
  979. // Categories
  980. $('select.player-note-categories option:containsNC("' + category + '")').attr('selected', 'selected');
  981. // Save note
  982. $('.player-save-note').trigger('click')
  983. //Focus TextField
  984. window.scroll(0, 0);
  985. $('.conversation-message-text').focusTextToEnd();
  986. });
  987. helperFunctions.set(config.hotkeys[16], // Player Save to Stad
  988. () => {
  989. // Adds :containsNC - non case-sensitive :contains
  990. $.extend($.expr[":"], {
  991. "containsNC": function(elem, i, match, array) {
  992. return (elem.textContent || elem.innerText || "").toLowerCase().indexOf((match[3] || "").toLowerCase()) >= 0;
  993. }
  994. });
  995. //Function to focus end of text
  996. (function($){
  997. $.fn.focusTextToEnd = function(){
  998. this.focus();
  999. var $thisVal = this.val();
  1000. this.val('').val($thisVal);
  1001. return this;
  1002. }
  1003. }(jQuery));
  1004. // Extract selected text
  1005. var note = window.getSelection().toString();
  1006. // Extract target name
  1007. var targetName = $('.target-name').text();
  1008. // Trim period from target name
  1009. var targetNamee = targetName.substr(1);
  1010. // Insert text to note
  1011. $('.player-note-content.area').val(note + ' (' + targetNamee + ')');
  1012. // Select note category
  1013. var category = 'stad';
  1014. // Categories
  1015. $('select.player-note-categories option:containsNC("' + category + '")').attr('selected', 'selected');
  1016. // Save note
  1017. $('.player-save-note').trigger('click')
  1018. //Focus TextField
  1019. window.scroll(0, 0);
  1020. $('.conversation-message-text').focusTextToEnd();
  1021.  
  1022. });
  1023. helperFunctions.set(config.hotkeys[17], // Player Save to Aktuellt
  1024. () => {
  1025. // Adds :containsNC - non case-sensitive :contains
  1026. $.extend($.expr[":"], {
  1027. "containsNC": function(elem, i, match, array) {
  1028. return (elem.textContent || elem.innerText || "").toLowerCase().indexOf((match[3] || "").toLowerCase()) >= 0;
  1029. }
  1030. });
  1031. //Function to focus end of text
  1032. (function($){
  1033. $.fn.focusTextToEnd = function(){
  1034. this.focus();
  1035. var $thisVal = this.val();
  1036. this.val('').val($thisVal);
  1037. return this;
  1038. }
  1039. }(jQuery));
  1040. // Extract selected text
  1041. var note = window.getSelection().toString();
  1042. // Extract target name
  1043. var targetName = $('.target-name').text();
  1044. // Trim period from target name
  1045. var targetNamee = targetName.substr(1);
  1046. // Insert text to note
  1047. $('.player-note-content.area').val(note + ' (' + targetNamee + ')');
  1048. // Select note category
  1049. var category = 'Aktuella saker';
  1050. // Categories
  1051. $('select.player-note-categories option:containsNC("' + category + '")').attr('selected', 'selected');
  1052. // Save note
  1053. $('.player-save-note').trigger('click')
  1054. //Focus TextField
  1055. window.scroll(0, 0);
  1056. $('.conversation-message-text').focusTextToEnd();
  1057. });
  1058. helperFunctions.set(config.hotkeys[18], // Target Notes No Prompt
  1059. () => {
  1060. // Adds :containsNC - non case-sensitive :contains
  1061. $.extend($.expr[":"], {
  1062. "containsNC": function(elem, i, match, array) {
  1063. return (elem.textContent || elem.innerText || "").toLowerCase().indexOf((match[3] || "").toLowerCase()) >= 0;
  1064. }
  1065. });
  1066.  
  1067.  
  1068. // Extract selected text
  1069. var text = window.getSelection().toString();
  1070. // Insert text to note
  1071. $('.target-note-content.area').val(text);
  1072. // Select note category
  1073. var category;
  1074. if (text.match(/bild|selfie|kuk|gif/i)) {
  1075. var category = 'Bilder';
  1076. } else if (text.match(/singel|barn|son|söner|döttrar|dotter|fru|särbo|sambo|gift|skild|änk/i)) {
  1077. var category = 'Familj/Relationer';
  1078. } else if (text.match(/jobb|arbetar|plugg|stude|pension|kör buss|kör lastbil|kör taxi|på järnvägen|chef|kock|vakt|pilot|polis|bagare|förare|frisör|jurist|läkare|lärare|ledare|målare|montör|rektor|advokat|konsult|optiker|pedagog|säljare|väktare|arbetare|arkitekt|brandman|chaufför|designer|fotograf|ingenjör|operatör|snickare|arbetslös|assistent|bartender|maskinist|sköterska|veterinär|elektriker|journalist|hantverkare|programmerare|projektledare|mekaniker|driver eget|företag|firma|måleri|snickeri|verkstad/i)) {
  1079. var category = 'Jobb/Utbildning';
  1080. } else if (text.match(/hund|katt|husdjur|spela|träna|astrologi|basta|bakning|bilar|bio|film|brädspel|båtar|böcker|litteratur|campa|cykla|dansa|datorer|dekorera|djur|fiska|flyga|fotboll|fotografera|friluftsliv|gymnastik|hälsa|friskvård|jogga|klättring|konserter|konst|museum|matlagning|meditera|motorcyklar|musik|måla|natur|nyheter|politik|opera|promenera|pyssla|religion|renovera|resa|rida|resa|segla|simma|skidor|skådespel|social media|tatueringar|teater|teckna|teknik|trädgård|träna|tv|umgås|uteliv|vandra|vinprovning|vintersport|äta ute/i)) {
  1081. var category = 'Hobby';
  1082. } else if (text.match(/bor i|Karlskrona|Karlshamn|Borås|Borlänge/i)) {
  1083. var category = 'Stad';
  1084. } else if (text.match(/heter|Abbe|Abdullah|Abraham|Adam|Adel|Adis|Agris|Agua|Alaga|Albert|Albin|Alek|Alex|Alexander|Alf|Alfred|Ali|Allan|Amir|Anders|Andreas|André|Andy|Ante|Anton|Ants|Ari|Aristides|Arne|Arto|Arvid|Axel|Azar|Behzad|Bengt/i)) {
  1085. var category = 'Namn';
  1086. } else if (text.match(/Bengt-Åke|Benny|Bernt|Bernt-Olov|Bernth|Bert|Bertil|Birger|Birgir|Bjarne|Björn|Bo|Bogdan|Boris|Bosse|Bror|Börge|Börje|Calle|Calmer|Carl|Carsten|Chaban|Charlie|Chris|Christer|Christian|Christoffer|Christophe|Christopher/i)) {
  1087. var category = 'Namn';
  1088. } else if (text.match(/Claes|Classe|Claudiu|Conny|Costas|Dan|Dane|Daniel|Danne|David|Davide|Davor|Deivys|Demir|Dennis|Derek|Dick|Edi|Edvard|Edvin|Ego|Eije|Einar|Eki|Elias|Emanuel|Emil|Emir|Eric|Erik|Erland|Evert|Ewen|Farid|Filip|Folke|Francesco/i)) {
  1089. var category = 'Namn';
  1090. } else if (text.match(/Franjo|Frank|Freddie|Fredrik|Friedhelm|Frode|Fugus|Gabriel|Georg|Gerald|Gerd|Gerra|Gert|Gert-Owe|Getahun|Gunnar|Gustaf|Gustav|Göran|Görgen|Görgen|Gösta|Göte|Habib|Hans|Hans Börge|Harald|Harri|Harry|Hasse|Helmut|Henke|Henrik|Henry|Hossein|Hugo|Håkan|Ihsan|Inge|Ingemar|Ingmar/i)) {
  1091. var category = 'Namn';
  1092. } else if (text.match(/Ingvar|Isaac|Isac|Isak|Ismail|Ivar|Jack|Jakob|Jan|Janne|Jean|Jens|Jerry|Jesper|Jhonatan|Jimmy|Joakim|Joar|Jocke|Joel|Johan|Johannes|John|Johnny|Jon|Jonas|Jonathan|Jonny|Juan|Julius|Jyrki|Jörgen|Kai|Kaj|Kalle|Kari|Karl|Karl Gustav|Karl-Erik|Karl-Olov|Karol|Ken|Kenneth|Kenny|Kent|Kenta/i)) {
  1093. var category = 'Namn';
  1094. } else if (text.match(/Kenth|Kieren|Kim|Kjell|Kjelle|Klas|Knut|Krister|Kristian|Kristoffer|Kurt|Kurt-Lennart|Kutte|Kåge|Lars|Lars Olov|Larsa|Larte|Larui|Lasse|Leif|Lellas|Lennart|Leo|Leon|Linus|Lucky|Ludvig|Magnus|Manne|Manuel|Marco|Marcus|Marek|Marian|Mario|Mark|Marko|Markus|Martin|Mathias|Mats|Matsvo|Matte|Matti|Mattias|Max|Melker|Michael|Michel|Micke|Mika|Mikael|Mikael|Mille|Miron|Misa|Mohamed|Mohammed/i)) {
  1095. var category = 'Namn';
  1096. } else if (text.match(/Morgan|Musa|Mustapha|Måns|Mårten|Nicke|Nicklas|Nicky|Niclas|Niklas|Nille|Nils|Nisse|Nurko|Ola|Oliver|Olle|Olof|Olov|Oscar|Oskar|Ove|Owe|Parsia|Pasi|Patric|Patrick|Patrik|Paul|Pavel|Peder|Pelle|Peo|Per|Per-Olof|Peter|Pether|Petter|Philip|Pierre|Pontus|Poul|Putte|Pär|Rafael|Rafeo|Ragnar|Raimo|Rasmus|Riccardo|Richard|Rickard|Rikard|Rimtaf|Risto|Robban|Robert|Robin|Roffe|Roger|Roland|Rolf|Rolle|Romii|Ronnie|Ronny|Ruben|Rune|Sabah|Sajad|Saladin|Sam|Samuel|Sebastian|Seed|Serko|Sigge|Silvo|Simon|Stefan|Steffen|Sten|Sten-Åke|Stig|Stig-Evert|Sture|Sune|Sven|Sven Erik|Sven Ingvar|Sven Åke|Sven-Erik|Sven-Gunnar|Sven-Åke|Sören|Tage|Taha|Tapio|Ted|Thomas|Thorbjörn|Tobbe|Tobias|Tobias|Tom|Tomas|Tommy|Tony|Torbjörn|Tord|Tore|Torgny|Torsten|Uffe|Ulf|Ulrik|Uno|Urban|Valentin|Victor|Viktor|Vilhelm|Waldemar|Wiktor|Wilhelm|William|Wojtek|Yngve|Yousef|Zdislav|Åke|Öyvind/i)) {
  1097. var category = 'Namn';
  1098. } else if (text.match(/anal|bakifrån|bunden|buttplug|dildo|dominans|kyssar|förspel|missionär|mystik|offentlig|onan|piska|rollspel|underkläder|sexleksaker|strap-on|suga|svälja|teasing|trekant|kondom|vaniljsex|wet/i)) {
  1099. var category = 'Sexuella preferenser';
  1100. } else if (text.match(/bil|mc|motorcykel/i)) {
  1101. var category = 'Transportmedel';
  1102. } else if (text.match(/mejl|mail|telef|skype|kik|fb|facebook/i)) {
  1103. var category = 'Mejl och telefon';
  1104. } else if (text.match(/sjuk/i)) {
  1105. var category = 'Hälsa';
  1106. } else var category = prompt('Select category:');
  1107. // Categories
  1108. $('select.target-note-categories option:containsNC("' + category + '")').attr('selected', 'selected');
  1109. // Save note
  1110. $('.target-save-note').trigger('click')
  1111. //Focus TextField
  1112. window.scroll(0, 0);
  1113. $( ".conversation-message-text" ).focus();
  1114. });
  1115. helperFunctions.set(config.hotkeys[19], // Focus TextField Column6
  1116. () => {
  1117. //Focus TextField
  1118. $( ".counters-column6" ).focusTextToEnd();
  1119. });
  1120.  
  1121. //Key Event Listensers for Hotkeys
  1122.  
  1123. document.addEventListener('keyup', (e) =>{ // Send Mssg and Lap Time on hit Enter Key
  1124. if (e.which == 13) {
  1125. var isFocused = $(".conversation-message-text").is(":focus"),
  1126. len = $('.conversation-message-text').val().length;
  1127.  
  1128. if (len >= 75 && isFocused) {
  1129. $('#counters-column5').trigger("click");
  1130. $('.message-submit-button').trigger("click");
  1131. $(".counters-column6").css("visibility","hidden");
  1132.  
  1133. }
  1134. }
  1135. });
  1136.  
  1137.  
  1138. document.addEventListener('keyup', (e) => { // Adds Alt Key event listeners for the hotkeys
  1139. if(e.altKey && isOkHotkey(e.code)) {
  1140. e.preventDefault();
  1141. e.stopPropagation();
  1142. let f = helperFunctions.get(e.code);
  1143. if(f !== undefined) f();
  1144. }
  1145. });
  1146.  
  1147. document.addEventListener('keyup', (e) => { // Adds Ctrl Key event listeners for the hotkeys
  1148. if(e.ctrlKey && isOkHotkey(e.code)) {
  1149. e.preventDefault();
  1150. e.stopPropagation();
  1151. let r = helpFunctions.get(e.code);
  1152. if(r !== undefined) r();
  1153. }
  1154. });
  1155.  
  1156.  
  1157. console.log("\tHotkeys registered");
  1158. }
  1159.  
  1160. function isOkHotkey(code) {
  1161. return code.startsWith("Key") || code.startsWith("Digit") || code.startsWith("Numpad") || code.startsWith("Arrow") || code.startsWith("F") || code.startsWith("R");
  1162. }
  1163.  
  1164. function createSettingsButton() {
  1165. function addSetting(value, name) {
  1166. var id_name = (name + 'Setting').replace(/[^A-Za-z_]/g,'');
  1167. var label = document.createElement('label');
  1168. label.innerHTML = name + ": ";
  1169. label.setAttribute('for', id_name);
  1170. label.style.gridColumn = '1';
  1171. var element = document.createElement('input');
  1172. if(typeof value == 'boolean') {
  1173. element.type = 'checkbox';
  1174. element.checked = value;
  1175. } else {
  1176. element.type = 'text';
  1177. element.value = value !== undefined ? value : "";
  1178. }
  1179. element.id = id_name;
  1180. element.name = id_name;
  1181. element.style.gridColumn = '2';
  1182. settingsDialog.appendChild(label);
  1183. settingsDialog.appendChild(element);
  1184. return element;
  1185. }
  1186.  
  1187. function setHotkey(n, e) {
  1188. if(isOkHotkey(e.code) || ['Backspace', 'Delete'].includes(e.code)) {
  1189. e.preventDefault();
  1190. e.stopPropagation();
  1191. var code = (['Backspace', 'Delete'].includes(e.code)) ? "" : e.code;
  1192. e.target.value = code;
  1193. config.hotkeys[n] = code;
  1194. }
  1195. }
  1196. console.log("Creating settings button");
  1197.  
  1198. var menu = $('#topmenu1')[0];
  1199. var settingsDialog = document.createElement('div');
  1200. settingsDialog.id = 'SettingsDialog';
  1201. settingsDialog.style.display = 'none';
  1202. settingsDialog.style.alignItems = 'center';
  1203.  
  1204. addSetting(config.username, 'Username') .addEventListener('change', (e) => {config.username = e.target.value;});
  1205. addSetting(config.password, 'Password') .addEventListener('change', (e) => {config.password = e.target.value;});
  1206. addSetting(config.autoLogin, 'Autologin') .addEventListener('change', (e) => {config.autoLogin = e.target.checked;});
  1207. addSetting(config.showCounters, 'Show counters') .addEventListener('change', (e) => {config.showCounters = e.target.checked;});
  1208. addSetting(config.goToMessagesFirst, 'Go to Messages after login')
  1209. .addEventListener('change', (e) => {config.goToMessagesFirst = e.target.checked;});
  1210. addSetting(config.highlightMessagesNotes, 'Highlights messages and notes')
  1211. .addEventListener('change', (e) => {config.highlightMessagesNotes = e.target.checked;});
  1212. addSetting(config.searchAndOpen, 'AutoSearch Attachment')
  1213. .addEventListener('change', (e) => {config.searchAndOpen = e.target.checked;});
  1214. addSetting(config.notificationSound, 'Play sound on new message')
  1215. .addEventListener('change', (e) => {config.notificationSound = e.target.checked;});
  1216. addSetting(config.hideProfilePics, 'Hide Profile Pics')
  1217. .addEventListener('change', (e) => {config.hideProfilePics = e.target.checked;});
  1218. settingsDialog.appendChild(document.createElement('span'));
  1219. settingsDialog.appendChild(document.createElement('br'));
  1220. settingsDialog.appendChild(document.createElement('span')); settingsDialog.lastChild.innerHTML = 'Functions Starting With ALT Key';
  1221. settingsDialog.appendChild(document.createElement('span'));
  1222. settingsDialog.appendChild(document.createElement('br'));
  1223. addSetting(config.hotkeys[ 0], '??') .addEventListener('keyup', (e) => {setHotkey( 0, e);});
  1224. addSetting(config.hotkeys[ 1], 'Maps Player Stad') .addEventListener('keyup', (e) => {setHotkey( 1, e);});
  1225. addSetting(config.hotkeys[ 2], 'Go to message box') .addEventListener('keyup', (e) => {setHotkey( 2, e);});
  1226. addSetting(config.hotkeys[ 3], 'Focus Textarea').addEventListener('keyup', (e) => {setHotkey( 3, e);});
  1227. addSetting(config.hotkeys[ 4], '??') .addEventListener('keyup', (e) => {setHotkey( 4, e);});
  1228. addSetting(config.hotkeys[ 5], '??') .addEventListener('keyup', (e) => {setHotkey( 5, e);});
  1229. addSetting(config.hotkeys[ 6], 'Go to Messages') .addEventListener('keyup', (e) => {setHotkey( 6, e);});
  1230. addSetting(config.hotkeys[ 7], 'Go to Stopped Messages') .addEventListener('keyup', (e) => {setHotkey( 7, e);});
  1231. addSetting(config.hotkeys[8], 'Go to Unread Messages') .addEventListener('keyup', (e) => {setHotkey(8, e);});
  1232. addSetting(config.hotkeys[9], 'Generate Hobbies') .addEventListener('keyup', (e) => {setHotkey(9, e);});
  1233. addSetting(config.hotkeys[10], 'SexIntressen') .addEventListener('keyup', (e) => {setHotkey(10, e);});
  1234. addSetting(config.hotkeys[11], 'Player Jobb') .addEventListener('keyup', (e) => {setHotkey(11, e);});
  1235. addSetting(config.hotkeys[12], 'Player Namn') .addEventListener('keyup', (e) => {setHotkey(12, e);});
  1236. addSetting(config.hotkeys[13], 'Target AutoNotes') .addEventListener('keyup', (e) => {setHotkey(13, e);});
  1237. addSetting(config.hotkeys[14], 'Target Aktuellt') .addEventListener('keyup', (e) => {setHotkey(14, e);});
  1238. addSetting(config.hotkeys[15], 'Player AutoNotes') .addEventListener('keyup', (e) => {setHotkey(15, e);});
  1239. addSetting(config.hotkeys[16], 'Player Stad') .addEventListener('keyup', (e) => {setHotkey(16, e);});
  1240. addSetting(config.hotkeys[17], 'Player Aktuellt') .addEventListener('keyup', (e) => {setHotkey(17, e);});
  1241. addSetting(config.hotkeys[18], 'Target Notes Utan Prompt') .addEventListener('keyup', (e) => {setHotkey(18, e);});
  1242. addSetting(config.hotkeys[19], '??') .addEventListener('keyup', (e) => {setHotkey(19, e);});
  1243.  
  1244. var settingsButton = menu.children[5].cloneNode();
  1245. settingsButton.id = 'SettingsButton';
  1246. settingsButton.setAttribute('rel', 'settings');
  1247. settingsButton.addEventListener('click', () => {
  1248. $('#SettingsDialog').dialog({
  1249. title: "Settings",
  1250. resizable: false,
  1251. modal: true,
  1252. position: 'top',
  1253. width: '400',
  1254. open: () => {
  1255. $('#SettingsDialog')[0].style.display = 'grid';
  1256. },
  1257. buttons: [
  1258. {
  1259. text: "Save",
  1260. click: () => {
  1261. console.log("Storing config");
  1262. localStorage.setItem('config', JSON.stringify(config));
  1263. console.log("\tConfig stored:");
  1264. console.log(localStorage.getItem('config'));
  1265. loadConfig();
  1266. //window.location.reload();
  1267. }
  1268. }
  1269. ]
  1270. });
  1271. });
  1272. $('button[rel="documents/manual.pdf"]')[0].insertAdjacentElement('afterend', settingsButton);
  1273. $('button[rel="documents/manual.pdf"]')[0].insertAdjacentText('afterend', '\n');
  1274. $('#SettingsButton').button();
  1275. settingsButton.children[0].innerHTML = 'Settings';
  1276. document.getElementById('informDialog').insertAdjacentElement('afterend', settingsDialog);
  1277. console.log("\tSettings button created");
  1278. }
  1279.  
  1280. function createCounters() {
  1281. console.log("Creating counter elements");
  1282. var menu = document.getElementById('topmenu1');
  1283. menu.style.position = 'relative';
  1284.  
  1285. var counters = document.createElement('div');
  1286. counters.id = 'counters-container';
  1287. counters.style.position = 'absolute';
  1288. counters.style.left = '39%';
  1289. counters.style.top = '10px';
  1290. counters.style.display = 'block';
  1291.  
  1292.  
  1293. var column1 = document.createElement('div');
  1294. column1.id = 'counters-column1';
  1295. column1.style.display = 'inline-block';
  1296. column1.style.marginLeft = '1em';
  1297. column1.style.verticalAlign = 'top';
  1298. column1.appendChild(document.createElement('span')); column1.lastChild.innerHTML = 'Sent: ';
  1299. column1.appendChild(document.createElement('span'));
  1300. column1.appendChild(document.createElement('br'));
  1301. column1.appendChild(document.createElement('span')); column1.lastChild.innerHTML = 'Earned: €';
  1302. column1.appendChild(document.createElement('span'));
  1303. column1.appendChild(document.createElement('br'));
  1304.  
  1305.  
  1306. var column2 = document.createElement('div');
  1307. column2.id = 'counters-column2';
  1308. column2.style.display = 'inline-block';
  1309. column2.style.marginLeft = '2em';
  1310. column2.style.verticalAlign = 'top';
  1311. column2.appendChild(document.createElement('span')); column2.lastChild.innerHTML = 'This week: ';
  1312. column2.appendChild(document.createElement('span'));
  1313. column2.appendChild(document.createElement('br'));
  1314. column2.appendChild(document.createElement('span')); column2.lastChild.innerHTML = 'Earned: €';
  1315. column2.appendChild(document.createElement('span'));
  1316. column2.appendChild(document.createElement('br'));
  1317. column2.appendChild(document.createElement('span')); column2.lastChild.innerHTML = 'Rate: €';
  1318. column2.appendChild(document.createElement('span'));
  1319. column2.appendChild(document.createElement('br'));
  1320.  
  1321. var column4 = document.createElement('div');
  1322. column4.id = 'counters-column4';
  1323. column4.style.display = 'inline-block';
  1324. column4.style.marginLeft = '3em';
  1325. column4.style.verticalAlign = 'top';
  1326. column4.appendChild(document.createElement('span')); column4.lastChild.innerHTML = 'Time: ';
  1327. column4.appendChild(document.createElement('span'));
  1328. column4.appendChild(document.createElement('br'));
  1329. column4.appendChild(document.createElement('span')); column4.lastChild.innerHTML = 'Last Msg: ';
  1330. column4.appendChild(document.createElement('span'));
  1331.  
  1332. var column5 = document.createElement('div');
  1333. column5.id = 'counters-column5';
  1334. column5.style.display = 'none';
  1335. column5.style.marginLeft = '3em';
  1336. column5.style.verticalAlign = 'top';
  1337. column5.appendChild(document.createElement('button')); column5.lastChild.innerHTML = 'Clear';
  1338.  
  1339. counters.appendChild(column1);
  1340. counters.appendChild(column2);
  1341. counters.appendChild(column4);
  1342. counters.appendChild(column5);
  1343. menu.insertBefore(counters, menu.lastElementChild);
  1344.  
  1345. var menuu = document.getElementById('main');
  1346. menuu.style.position = 'relative';
  1347.  
  1348. var counterss = document.createElement('div');
  1349. counterss.id = 'counters-container2';
  1350. counterss.style.position = 'absolute';
  1351. counterss.style.left = '20.8vw';
  1352. counterss.style.width = '56.6vw';
  1353. counterss.style.display = 'block';
  1354.  
  1355.  
  1356.  
  1357.  
  1358. var column6 = document.createElement('textarea');
  1359. column6.className = 'counters-column6';
  1360. column6.placeholder = 'Click And Paste Your Text Here!';
  1361. column6.style.position = 'relative';
  1362. column6.style.width = 'inherit';
  1363. column6.rows = '2';
  1364. column6.style.marginTop = '10px';
  1365. column6.style.borderRadius = '6px';
  1366. column6.style.background = '#636363';
  1367. column6.style.outline = 'none';
  1368. column6.style.border = 'none';
  1369. column6.style.visibility = 'hidden';
  1370. column6.style.placeholder = '#003da0';
  1371.  
  1372.  
  1373. counterss.appendChild(column6);
  1374. menuu.insertBefore(counterss, menuu.firstElementChild);
  1375.  
  1376. var styleNode = document.createElement("style");
  1377. document.body.appendChild(styleNode);
  1378.  
  1379. //CSS Code//CSS Code//
  1380.  
  1381. //Body
  1382. styleNode.innerHTML = "html { background-color: #636363 !important; }\n";
  1383. styleNode.innerHTML += "body { background-color: #636363 !important; font-family: merriweather, serif !important; outline: none !important; }\n";
  1384. styleNode.innerHTML += "::-webkit-scrollbar { display: none !important; }\n";
  1385.  
  1386. //Lay out Top
  1387. styleNode.innerHTML += ".layout-top { position: fixed !important; z-index: 1 !important; }\n";
  1388. styleNode.innerHTML += "#topmenu1 { background-color: #636363 !important; font-family: merriweather, serif !important; border-style: none !important; }\n";
  1389. styleNode.innerHTML += "#topmenu2 { display: none !important; }\n";
  1390. styleNode.innerHTML += "#counters-container { font-size: 14px; font-weight: bold !important; }\n";
  1391.  
  1392. //Midd Section//
  1393.  
  1394. //Upper Textfield
  1395. styleNode.innerHTML +=
  1396. "::placeholder { text-align: center !important; color: #012359 !important; font-size: 15px !important; font-weight: bold !important; }\n";
  1397. styleNode.innerHTML +=
  1398. "textarea.counters-column6 { top: 100px; font-size: 13px !important; font-weight: bold !important; position: fixed !important; z-index: 5; tab-index: 1 !important; }\n";
  1399.  
  1400. //Upper Textfield On Focus
  1401. styleNode.innerHTML +=
  1402. "textarea.counters-column6:focus { border: 1px solid rgba(81, 203, 238, 1) !important; box-shadow: 0 0 7px rgba(81, 203, 238, 1) !important; background: #919191 !important; }\n";
  1403.  
  1404. //Information On Top of Lower Textfield Hidden Objects
  1405. styleNode.innerHTML += "div.from-to { visibility: hidden !important; }\n";
  1406. styleNode.innerHTML += "div.subject{ display: none !important; }\n";
  1407. styleNode.innerHTML += ".message-subject { display: none !important; }\n";
  1408.  
  1409. //Information On Top of Lower Textfield Non Hidden Objects
  1410. styleNode.innerHTML +=
  1411. ".from-to.start-date { visibility: visible !important; position: absolute !important; left: 35% !important; background: #919191 !important; font-weight: bold !important; font-size: 17px !important; font-family: erriweather, serif !important; border-radius: 7px !important; }\n";
  1412. styleNode.innerHTML += ".green { font-size: 11px !important; font-family: merriweather, serif !important; position: relative !important; margin-right: 5px !important; }\n";
  1413.  
  1414. //Lower Texfield Area
  1415. styleNode.innerHTML += ".conversation-fill { position: fixed !important; margin-left: 5px !important; margin-top: 43px !important; z-index: 0 }\n";
  1416. styleNode.innerHTML += ".message.read { !important; padding: 0 5px !important; font-weight: bold !important; }\n";
  1417. styleNode.innerHTML += "textarea.conversation-message-text, ul.emoji-preset, .message-submit-button, .message-addmedia-button, .message-delmedia-button { top: 36px !important; position: relative !important; }\n";
  1418. styleNode.innerHTML +=
  1419. "textarea.conversation-message-text { width: 56.7vw !important; background-color: #636363 !important; outline: none !important; border-radius: 6px !important; font-size: 15px !important; font-family: merriweather, serif !important; font-weight: bold !important; }\n";
  1420.  
  1421. //Lower Texfield Area On Focus
  1422. styleNode.innerHTML +=
  1423. "textarea.conversation-message-text:focus { border: 1px solid rgba(81, 203, 238, 1) !important; box-shadow: 0 0 7px rgba(81, 203, 238, 1) !important; background: #919191 !important; }\n";
  1424.  
  1425. //Objects Under Lower Textfield Area
  1426. styleNode.innerHTML += ".specialdatepicker, #future, .message-send-direct, .message-text span { display: none !important; }\n";
  1427. styleNode.innerHTML += " span.ui-button-text, span.emoji.emoji-sizer { display: block !important; }\n";
  1428.  
  1429. //Incoming Messages Area
  1430. styleNode.innerHTML += "#conversation-messages { top: 25px !important; height: 400px !important; margin-left: 3px !important; font-weight: bold !important; position: relative !important; overflow-y: auto; }\n";
  1431. styleNode.innerHTML += ".tr .td3 .message-text {!important; font-size: 16px !important; font-weight: bold !important; font-family: robot !important; }\n";
  1432. styleNode.innerHTML += ".tr .td3 .from-to { visibility: visible !important; }\n";
  1433. styleNode.innerHTML += ".label { }\n";
  1434. styleNode.innerHTML += "#showmore { position: relative !important; top: 45px !important; background: #919191 !important; }\n";
  1435. //Side Sections//
  1436. //Hidden Objects
  1437. styleNode.innerHTML += "div.bar-title { display: none !important; }\n";
  1438. styleNode.innerHTML += ".td2 { display: none !important; }\n";
  1439.  
  1440. //Profiles and Notes
  1441. styleNode.innerHTML += ".conversation-left, .conversation-right { background: #636363 !important; font-size: 13px !important; font-family: merriweather, serif !important; }\n";
  1442. styleNode.innerHTML += ".block-content, .player-note { background: #919191 !important; font-size: 13px !important; }\n";
  1443. styleNode.innerHTML += ".player-last-notes, .ui-draggable, .ui-widget-content, .ui-widget-header { font-size: 13px !important; font-weight: bold !important; background: #919191 !important;}\n";
  1444. styleNode.innerHTML += ".note-cnt { border-left: 0px !important; border-top: 1px !important; font-size: 11px !important; font-weight: bold !important; border-color: #000000 padding: 2px !important; }\n";
  1445. styleNode.innerHTML += ".note_title { border-bottom: 1px solid #000000 !important; font-size: 12px !important; font-weight: bold !important; background: #919191 !important; }\n";
  1446. styleNode.innerHTML += "textarea.target-note-content, textarea.player-note-content, .player-note-content.input, .target-note-content.input { outline: none !important; background-color: #919191 !important; border-radius: 6px !important; }\n";
  1447. styleNode.innerHTML += "select.target-note-categories, select.player-note-categories { outline: none !important; background-color: #919191 !important; border-radius: 6px !important; margin-top: 5px !important; }\n";
  1448.  
  1449. //Hide Profilepics
  1450.  
  1451.  
  1452. //Hover Profile Pics
  1453.  
  1454. //Textarea Notes On Focus
  1455. styleNode.innerHTML +=
  1456. "textarea.target-note-content:focus, textarea.player-note-content:focus, .player-note-content.input:focus, .target-note-content.input:focus { border: 1px solid rgba(81, 203, 238, 1) !important; box-shadow: 0 0 7px rgba(81, 203, 238, 1) !important; background: #919191 !important; border-radius: 6px !important; outline: none !important;}\n";
  1457.  
  1458. //Buttons//
  1459. styleNode.innerHTML += "button { background-color: #636363 !important; border: none !important; }\n";
  1460. styleNode.innerHTML += " .ui-state-default { font-weight: bold !important; background: none !important; color: #000000 !important; border: none !important; font-family: merriweather, serif !important; }\n";
  1461. styleNode.innerHTML += "button.navigation span { font-size: 15px !important; letter-spacing: 5px !important; }\n";
  1462. //Buttons Hover//
  1463. styleNode.innerHTML += "button.navigation span:hover { border: 1px solid rgba(81, 203, 238, 1) !important; box-shadow: 0 0 7px rgba(81, 203, 238, 1) !important; background: #919191 !important; border-radius: 6px !important; }\n";
  1464. styleNode.innerHTML +=
  1465. " select.target-note-categories:hover, select.player-note-categories:hover, button:hover { border: 1px solid rgba(81, 203, 238, 1) !important; box-shadow: 0 0 7px rgba(81, 203, 238, 1) !important; background: #919191 !important; border-radius: 6px !important; }\n";
  1466.  
  1467. //Hidden Buttons//
  1468. styleNode.innerHTML += "button[rel='documents/manual.pdf'], button[rel='Announcements'] { display: none !important; }\n";
  1469.  
  1470. //Loading Screen
  1471. styleNode.innerHTML += ".message-message { background-color: #636363 !important; }\n";
  1472. styleNode.innerHTML += ".title { visibility: hidden !important; }\n";
  1473.  
  1474. console.log("\tCounter elements created");
  1475. }
  1476.  
  1477.  
  1478.  
  1479.  
  1480. function calcRate(messages) {
  1481. if(messages >= 1976)
  1482. return 0.19;
  1483. if(messages >= 1576)
  1484. return 0.16;
  1485. if(messages >= 776)
  1486. return 0.14;
  1487. return 0.12;
  1488. }
  1489.  
  1490. function calcEarned(rate, normal, bonus, other) {
  1491. return rate * (normal + bonus) +
  1492. 0.02 * bonus +
  1493. 0.12 * other;
  1494. }
  1495.  
  1496.  
  1497. function getStats() {
  1498. function updateCounters(stats) {
  1499. function statsForDate(date) {
  1500. var normal = parseInt(date.replied_messages_normal) | 0;
  1501. var peakHour = parseInt(date.replied_messages_peakhour) | 0;
  1502. var weekend = parseInt(date.replied_messages_saturday) +
  1503. parseInt(date.replied_messages_sunday) +
  1504. parseInt(date.replied_messages_specialtrigger) | 0;
  1505. var other = parseInt(date.replied_favorites) +
  1506. parseInt(date.replied_flirts) +
  1507. parseInt(date.replied_matches) +
  1508. parseInt(date.replied_proposals) +
  1509. parseInt(date.replied_stopped) | 0;
  1510. return [normal, peakHour + weekend, other];
  1511. }
  1512. console.log("Updating counters");
  1513. var date = new Date().toLocaleString('sv-SE', {
  1514. year: 'numeric',
  1515. month: '2-digit',
  1516. day: '2-digit'
  1517. });
  1518. var sentNormal, sentBonus, other, normalWeek=0, bonusWeek=0, otherWeek=0, rate,
  1519. column1 = document.getElementById('counters-column1'),
  1520. column2 = document.getElementById('counters-column2'),
  1521. column4 = document.getElementById('counters-column4'),
  1522. column5 = document.getElementById('counters-column5');
  1523. column1.children[1].innerHTML = '0';
  1524. column1.children[4].innerHTML = '0';
  1525. for(const s of stats) {
  1526. [sentNormal, sentBonus, other] = statsForDate(s);
  1527. normalWeek += sentNormal;
  1528. bonusWeek += sentBonus;
  1529. otherWeek += other;
  1530. if(s.date == date) {
  1531. rate = calcRate(normalWeek + bonusWeek);
  1532. column1.children[1].innerHTML = sentNormal + sentBonus;
  1533. column1.children[4].innerHTML = (rate * (sentNormal + sentBonus)).toFixed(2);
  1534. console.log("\tCounters for today updated");
  1535. break;
  1536. }
  1537. }
  1538. column2.children[1].innerHTML = normalWeek + bonusWeek;
  1539. column2.children[4].innerHTML = calcEarned(rate, normalWeek, bonusWeek, otherWeek).toFixed(2);
  1540. column2.children[7].innerHTML = rate;
  1541.  
  1542.  
  1543. console.log("\tCounters updated");
  1544. }
  1545. console.log("Getting statistics");
  1546. $.ajax({
  1547. url: '/ajax/stats/action/getStats',
  1548. dataType: 'json',
  1549. type: 'POST',
  1550. data: {
  1551. year: new Date().getFullYear(),
  1552. weekno: $.datepicker.iso8601Week(new Date()),
  1553. pagination: {
  1554. current: 1,
  1555. drawPagination: false,
  1556. perPage: 20,
  1557. total: 1
  1558. },
  1559. type: 'mine'
  1560. },
  1561. success: function (response) {
  1562. console.log("getStats AJAX call success");
  1563. updateCounters(response.data.result);
  1564. },
  1565. complete: function () {}
  1566. });
  1567. console.log("\tStatistics gotten");
  1568. }
  1569.  
  1570.  
  1571.  
  1572. var h1 = document.getElementById('counters-column4'),
  1573. start = document.getElementById('counters-column5'),
  1574. h2 = document.getElementById('counters-column4'),
  1575. seconds = 0, minutes = 0, hours = 0,
  1576. t;
  1577.  
  1578. function add() {
  1579. seconds++;
  1580. if (seconds >= 60) {
  1581. seconds = 0;
  1582. minutes++;
  1583. if (minutes >= 60) {
  1584. minutes = 0;
  1585. hours++;
  1586. }
  1587. }
  1588.  
  1589. h1.children[1].textContent = (minutes ? (minutes > 9 ? minutes : "0" + minutes) : "00") + ":" + (seconds > 9 ? seconds : "0" + seconds);
  1590.  
  1591. timer();
  1592. }
  1593. function timer() {
  1594. t = setTimeout(add, 1000);
  1595. }
  1596. timer();
  1597.  
  1598.  
  1599. /* Start button */
  1600. start.onclick = function() {
  1601.  
  1602. h2.children[4].textContent = leftPad(minutes) + ":" + leftPad(seconds);
  1603. h1.children[1].innerHTML = "00:00";
  1604. seconds = 0; minutes = 0; hours = 0;
  1605. return false;
  1606. }
  1607. return true;
  1608.  
  1609.  
  1610.  
  1611.  
  1612.  
  1613. function leftPad(value) {
  1614. return value < 10 ? ('0' + value) : value;
  1615. }
Add Comment
Please, Sign In to add comment