NEET Lib

NEET Bot Library

当前为 2019-10-01 提交的版本,查看 最新版本

此脚本不应直接安装。它是供其他脚本使用的外部库,要使用该库请加入元指令 // @require https://update.cn-greasyfork.org/scripts/383201/737544/NEET%20Lib.js

  1. // ==UserScript==
  2. // @name NEET Lib
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.4.0
  5. // @description NEET Bot Library
  6. // @author eterNEETy
  7. // @match http://game.granbluefantasy.jp/
  8. // @grant none
  9. // @namespace https://greasyfork.org/users/292830
  10. // ==/UserScript==
  11. // jshint esversion: 6
  12. // jshint -W138
  13.  
  14. /*
  15.  
  16. changelog:
  17.  
  18. 1.1.0:
  19. - added init()
  20. - changed `let main_path` to `path.main`
  21.  
  22. 1.2.0:
  23. - changed charMoveSet cid
  24.  
  25. 1.3.0:
  26. - added discord_mention
  27. 1.3.2:
  28. - missionComplete(cmd=[]);
  29. */
  30.  
  31.  
  32. // environment info
  33. const xhr = new XMLHttpRequest(),
  34. server = "http://localhost:2487",
  35. margin = {"top":91,"left":0},
  36. game_url = "http://game.granbluefantasy.jp/";
  37.  
  38. let debug = true,
  39. reload_counter;
  40.  
  41. let zoom = 1;
  42.  
  43. let my_profile = "Main: ";
  44. let is_host = "false";
  45. let battle;
  46. let is_wiped = true;
  47. let discord_mention = '';
  48. let abi_special_case = false;
  49.  
  50. let quests_id = [], monsters = [], monsters_name = [];
  51. const recovery_items = ['Elixir','Half Elixir','Soul Balm','Soul Berry'];
  52. let reloadable_skill = ["Four-Sky's Sorrow", "Thunder Raid"];
  53. let tracker_reward_weapons = [];
  54. let tracker_reward_summons = [];
  55. let tracker_reward_items = [recovery_items[0], recovery_items[1], recovery_items[2], recovery_items[3],'Gold Brick','Damascus Grain','Silver Centrum'];
  56.  
  57.  
  58. const kaguya = {"name":"Kaguya", "star":0},
  59. white_rabbit = {"name":"White Rabbit", "star":3},
  60. black_rabbit = {"name":"Black Rabbit", "star":3},
  61. huanglong = {"name":"Huanglong", "star":3},
  62. shiva = {"name":"Shiva", "star":3},
  63. shiva0 = {"name":"Shiva", "star":0},
  64. varuna = {"name":"Varuna", "star":3},
  65. bonito = {"name":"Bonito", "star":4},
  66. yggdrasil = {"name":"Yggdrasil Omega", "star":4},
  67. uriel = {"name":"Uriel", "star":0},
  68. tiamat = {"name":"Tiamat Omega", "star":4},
  69. bahamut = {"name":"Bahamut", "star":5},
  70. lucifer = {"name":"Lucifer", "star":5};
  71. const leech_summons = [kaguya,white_rabbit,black_rabbit];
  72.  
  73. // const game variable
  74. // const trials_id = ["990011","990021","990031","990041","990051","990061","990071"],
  75. // select_summon_path = "supporter/";
  76. const trial_id = "990011",
  77. select_summon_path = "supporter/";
  78.  
  79. // path
  80. let path = {
  81. 'main': '',
  82. "item":"#item",
  83. "quest":"#quest",
  84. "support":"#quest/supporter/",
  85. "assist":"#quest/assist",
  86. "unclaimed":"#quest/assist/unclaimed",
  87. "trial":"#quest/supporter/"+trial_id+"/17",
  88. };
  89.  
  90. // element dom query selector
  91. let skill_char = "#prt-command-top > div > div > div.lis-character";
  92. let skill_abi = ".btn-command-character > div.prt-ability-state > div.lis-ability-state.ability";
  93. let query = {
  94. "battle_ui": {
  95. "skill": {
  96. "char1": {
  97. "skill1": skill_char + "0" + skill_abi + "1",
  98. "skill2": skill_char + "0" + skill_abi + "2",
  99. "skill3": skill_char + "0" + skill_abi + "3",
  100. "skill4": skill_char + "0" + skill_abi + "4",
  101. },
  102. "char2": {
  103. "skill1": skill_char + "1" + skill_abi + "1",
  104. "skill2": skill_char + "1" + skill_abi + "2",
  105. "skill3": skill_char + "1" + skill_abi + "3",
  106. "skill4": skill_char + "1" + skill_abi + "4",
  107. },
  108. "char3": {
  109. "skill1": skill_char + "2" + skill_abi + "1",
  110. "skill2": skill_char + "2" + skill_abi + "2",
  111. "skill3": skill_char + "2" + skill_abi + "3",
  112. "skill4": skill_char + "2" + skill_abi + "4",
  113. },
  114. "char4": {
  115. "skill1": skill_char + "3" + skill_abi + "1",
  116. "skill2": skill_char + "3" + skill_abi + "2",
  117. "skill3": skill_char + "3" + skill_abi + "3",
  118. "skill4": skill_char + "3" + skill_abi + "4",
  119. },
  120. },
  121. "skill_pop_up": {
  122. "char1": "div.pop-usual.pop-select-member > div.prt-popup-body > div.prt-wrapper > div.prt-character > div.lis-character0.btn-command-character > img",
  123. "char2": "div.pop-usual.pop-select-member > div.prt-popup-body > div.prt-wrapper > div.prt-character > div.lis-character1.btn-command-character > img",
  124. "char3": "div.pop-usual.pop-select-member > div.prt-popup-body > div.prt-wrapper > div.prt-character > div.lis-character2.btn-command-character > img",
  125. "char4": "div.pop-usual.pop-select-member > div.prt-popup-body > div.prt-wrapper > div.prt-character > div.lis-character3.btn-command-character > img",
  126. "char5": "div.pop-usual.pop-select-member > div.prt-popup-body > div.prt-wrapper > div.prt-character > div.lis-character4.btn-command-character > img",
  127. "char6": "div.pop-usual.pop-select-member > div.prt-popup-body > div.prt-wrapper > div.prt-character > div.lis-character5.btn-command-character > img",
  128. },
  129. "ougi": ".btn-lock",
  130. "toggle_ougi": {
  131. true: ".lock0",
  132. false: ".lock1",
  133. },
  134. "char_ico": ".prt-party>.prt-member>.btn-command-character>img.img-chara-command",
  135. "summon_panel": ".prt-summon-list>.prt-list-top.btn-command-summon",
  136. "chat":".btn-chat.comment.display-on",
  137. "chat_pop_up": {
  138. "dialog":".txt-chat-pop",
  139. },
  140. "heal":"#prt-sub-command-group>.btn-temporary",
  141. "heal_pop_up": {
  142. "green": ".lis-item.item-small",
  143. "blue": ".lis-item.item-large",
  144. 'Green Potion': '.lis-item.item-small',
  145. 'Blue Potion': '.lis-item.item-large',
  146. 'Support Potion': '.lis-item.btn-event-item[item-id="1"]',
  147. 'Clarity Herb': '.lis-item.btn-event-item[item-id="2"]',
  148. 'Revival Potion': '.lis-item.btn-event-item[item-id="3"]',
  149. "use": ".pop-usual.pop-raid-item.pop-show>.prt-popup-footer>.btn-usual-use",
  150. "cancel": ".pop-usual.pop-raid-item.pop-show>.prt-popup-footer>.btn-usual-cancel",
  151. },
  152. "trial_pop_up": {
  153. "close": ".pop-usual.pop-trialbattle-notice.pop-show>.prt-popup-footer>.btn-usual-close",
  154. },
  155. "backup_pop_up": {
  156. "request": ".pop-usual.pop-start-assist.pop-show>.prt-popup-footer>.btn-usual-text",
  157. "cancel": ".pop-usual.pop-start-assist.pop-show>.prt-popup-footer>.btn-usual-cancel",
  158. },
  159. "button": {
  160. "assist": ".prt-multi-buttons>.btn-assist",
  161. },
  162. },
  163. "assist_ui": {
  164. "tab_id": "#tab-id",
  165. "tab_multi": "#tab-multi",
  166. "tab_event": "#tab-event",
  167. "unclaimed": ".btn-unclaimed",
  168. },
  169. "poker": {
  170. "canvas": "#canv",
  171. "deal": ".prt-start",
  172. "ok": ".prt-ok",
  173. "yes": ".prt-yes",
  174. "no": ".prt-no",
  175. "low": ".prt-double-select>.prt-low-shine",
  176. "high": ".prt-double-select>.prt-high-shine",
  177. },
  178. "ok":".btn-usual-ok",
  179. };
  180.  
  181. // general item variable
  182. let tracked_item = false;
  183.  
  184. function getMessage(pilot) {
  185. const message = {
  186. "raid" : {
  187. "panel" : {
  188. "open" : pilot+"Opening quest/raid panel",
  189. "pick" : pilot+"Picking quest/raid difficulties",
  190. },
  191. "select_party" : pilot+"Selecting party",
  192. "finish" : pilot+"Raid finished",
  193. "trial" : {
  194. "close_pop_up" : pilot+"In trial, closing pop up",
  195. "open_menu" : pilot+ "In trial, click menu",
  196. "retreat" : pilot+ "In trial, click retreat",
  197. "ok" : pilot+ "In trial, click ok",
  198. "end" : pilot+"Retreated from trial, back to main raid",
  199. }
  200. },
  201. "summon" : {
  202. "select" : pilot+"Selecting summon",
  203. "pick_tab" : pilot+"Clicking summon element tab",
  204. "not_found" : pilot+"Support summon not found, going to trial",
  205. },
  206. "replenish" : {
  207. "elixir" : {
  208. "half_elixir" : {
  209. "use" : pilot+"Not enough AP, using half elixir",
  210. "used" : pilot+"Half elixir used",
  211. }
  212. },
  213. "soul" : {
  214. "soul_berry" : {
  215. "use" : pilot+"Not enough EP, using soul berry",
  216. "used" : pilot+"soul berry used",
  217. }
  218. }
  219. },
  220. "ok" : pilot+"Clicking ok",
  221. };
  222. return message;
  223. }
  224.  
  225. function reloadNow() {
  226. console.log(reloadNow.name);
  227. xhr.open('POST', server);
  228. xhr.send(JSON.stringify([{"cmd":"press","key":"f5"}]));
  229. window.location.reload();
  230. }
  231.  
  232. function reload(mod_value=1) {
  233. clearInterval(reload_counter);
  234. let current_path = window.location.hash;
  235. let count = 1;
  236. reload_counter = setInterval(function() {
  237. if(window.location.hash != current_path){
  238. clearInterval(reload_counter);
  239. }
  240. console.log("reloading in "+(mod_value-count).toString());
  241. if (count%mod_value===0){
  242. clearInterval(reload_counter);
  243. reloadNow();
  244. }
  245. count += 1;
  246. }, 1000);
  247. }
  248.  
  249. function setDebug() {
  250. if(!debug){
  251. console.log("DEBUG is turned OFF");
  252. if(!window.console) window.console = {};
  253. let methods = ["log", "debug", "warn", "info"];
  254. for(let i=0;i<methods.length;i++){
  255. console[methods[i]] = function(){};
  256. }
  257. }
  258. }
  259.  
  260. function readBody(xhr) {
  261. let data;
  262. if (!xhr.responseType || xhr.responseType === "text") {
  263. data = xhr.responseText;
  264. } else if (xhr.responseType === "document") {
  265. data = xhr.responseXML;
  266. } else {
  267. data = xhr.response;
  268. }
  269. return data;
  270. }
  271.  
  272. function gotoHash(key){
  273. let hash_path;
  274. if (path[key] !== undefined) {
  275. hash_path = path[key];
  276. }else{
  277. if (key.indexOf("#")!==0) {
  278. hash_path = "#"+key;
  279. }
  280. }
  281. window.location.href = game_url + hash_path;
  282. }
  283.  
  284. function scrollTo(query,qid=0) {
  285. document.querySelectorAll(query)[qid].scrollIntoViewIfNeeded();
  286. }
  287.  
  288. function checkExist(query,qid=0) {
  289. let el_exist = false;
  290. if (document.querySelectorAll(query).length > qid){
  291. if (document.querySelectorAll(query)[qid].getBoundingClientRect().width > 0 && document.querySelectorAll(query)[qid].getBoundingClientRect().height > 0) {
  292. el_exist = true;
  293. }
  294. }
  295. return el_exist;
  296. }
  297.  
  298. function checkEl(query,qid=0,callback=false) {
  299. let old_top = -1;
  300. let old_left = -1;
  301. let loop_checkEl = setInterval(function() {
  302. console.log(checkEl.name + " " + query + "[" + qid + "]");
  303. if (checkExist(query,qid)) {
  304. if (old_top==document.querySelectorAll(query)[qid].getBoundingClientRect().top && old_left==document.querySelectorAll(query)[qid].getBoundingClientRect().left) {
  305. clearInterval(loop_checkEl);
  306. if (typeof callback == "function") {
  307. callback();
  308. }
  309. }else{
  310. old_top = document.querySelectorAll(query)[qid].getBoundingClientRect().top;
  311. old_left = document.querySelectorAll(query)[qid].getBoundingClientRect().left;
  312. }
  313. }
  314. }, 200);
  315. }
  316.  
  317. function checkEls(queries,callback=false) {
  318. let exist_result;
  319. let loop_checkEls = setInterval(function() {
  320. exist_result = [];
  321. for (let i in queries) {
  322. console.log(checkEls.name + " " + queries[i].query + "[" + queries[i].qid + "]");
  323. exist_result.push(checkExist(queries[i].query,queries[i].qid));
  324. }
  325. if (exist_result.indexOf(false)===-1) {
  326. clearInterval(loop_checkEls);
  327. if (typeof callback == "function") {
  328. callback();
  329. }
  330. }
  331. }, 300);
  332. }
  333.  
  334. function checkElsOR(queries,callback=false) {
  335. let exist_result;
  336. let loop_checkEls = setInterval(function() {
  337. exist_result = [];
  338. for (let i in queries) {
  339. console.log(checkElsOR.name + " " + queries[i].query + "[" + queries[i].qid + "]");
  340. exist_result.push(checkExist(queries[i].query,queries[i].qid));
  341. }
  342. if (exist_result.indexOf(true)>=0) {
  343. clearInterval(loop_checkEls);
  344. if (typeof callback == "function") {
  345. callback();
  346. }
  347. }
  348. }, 300);
  349. }
  350.  
  351. function checkError() {
  352. let q_cnt_error = ".cnt-error";
  353. let q_pop_up = ".pop-usual.common-pop-error.pop-show";
  354. let q_abi_pop_up = ".pop-usual.pop-raid-ability-error.pop-show";
  355. let check_error = setInterval(function() {
  356. console.log(checkError.name);
  357. if (checkExist(q_pop_up,0) || checkExist(q_cnt_error,0) || checkExist(q_abi_pop_up,0)) {
  358. let cmd = [];
  359. console.log("error_found");
  360. let do_reload = false;
  361. let level = "notif";
  362. let msg = "Uncatagorized error found";
  363. // let msg = "Connection error, refreshing disabled"
  364. if (checkExist(q_abi_pop_up,0)) {
  365. do_reload = true;
  366. msg = my_profile + document.querySelector(q_abi_pop_up+">.prt-popup-body>.txt-popup-body").innerHTML;
  367. level = "process";
  368. } else {
  369. if (checkExist(q_pop_up+">.prt-popup-header",0)) {
  370. if (document.querySelector(q_pop_up+">.prt-popup-header").innerHTML=="Access Verification") {
  371. clearInterval(reload_counter);
  372. clearInterval(check_error);
  373. msg = my_profile+"Captcha detected. " + discord_mention;
  374. console.log("Captcha detected");
  375. }else if (document.querySelector(q_pop_up+">.prt-popup-header").innerHTML=="エラー") {
  376. if (checkExist(q_pop_up+">.prt-popup-body>.txt-popup-body>div",0)) {
  377. if (typeof document.querySelector(q_pop_up+">.prt-popup-body>.txt-popup-body>div").innerHTML == "string") {
  378. if (document.querySelector(q_pop_up+">.prt-popup-body>.txt-popup-body>div").innerHTML.indexOf("Network Error")>=0) {
  379. clearInterval(reload_counter);
  380. console.log("Error connection");
  381. do_reload = true;
  382. msg = my_profile+"Error connection, reloading";
  383. level = "process";
  384. }
  385. }
  386. }
  387. }
  388. }
  389. if (checkExist(q_pop_up+">.prt-popup-body>.txt-popup-body",0)) {
  390. if (document.querySelector(q_pop_up+">.prt-popup-body>.txt-popup-body").innerHTML=="Check your pending battles.") {
  391. console.log("check raid");
  392. level = "process";
  393. msg = my_profile+"Check your pending battle";
  394. clickEl(".prt-popup-footer>.btn-usual-ok",0,my_profile+"Clicking ok pop up pending battles");
  395. }
  396. }
  397. }
  398. if (do_reload){
  399. cmd.push({"cmd":"press","key":"f5"});
  400. }
  401. cmd.push({"cmd":"log","level":level,"msg":msg});
  402. xhr.open('POST', server);
  403. xhr.send(JSON.stringify(cmd));
  404. if (do_reload){
  405. window.location.reload();
  406. }
  407. }
  408. }, 5000);
  409. }
  410.  
  411. function getCoord(el){
  412. zoom = parseInt(document.getElementById("mobage-game-container").style.zoom);
  413. let x, y, output;
  414. el = el.getBoundingClientRect();
  415. if (el.width>0 && el.height>0) {
  416. x = (el.width / 2) + el.left;
  417. y = (el.height / 2) + el.top;
  418. if(el.width>40){
  419. x += Math.floor(Math.random() * 41)-20;
  420. }else if(el.width>20){
  421. x += Math.floor(Math.random() * 21)-10;
  422. }else if(el.width>10){
  423. x += Math.floor(Math.random() * 11)-5;
  424. }
  425. if(el.height>10){
  426. y += Math.floor(Math.random() * 11)-5;
  427. }
  428. output = [(x*zoom)+margin.left,(y*zoom)+margin.top];
  429. }else{
  430. output = 0;
  431. }
  432. return output;
  433. }
  434.  
  435. function getMarginCoord(query,qid){
  436. let el = document.querySelectorAll(query)[qid].getBoundingClientRect();
  437. return {"top":el.top+margin.top,"left":el.left+margin.left};
  438. }
  439.  
  440. function clickNow(query,qid=0,msg=my_profile+"clickNow called",callback=false){
  441. let el = document.querySelectorAll(query)[qid];
  442. let output = false;
  443. if (checkExist(query,qid)) {
  444. output = true;
  445. let cmd = [];
  446. cmd.push({"cmd":"clickIt","param":getCoord(el)});
  447. cmd.push({"cmd":"log","level":"process","msg":msg});
  448. xhr.open("POST", server);
  449. xhr.send(JSON.stringify(cmd));
  450. if (typeof callback == "function") {
  451. callback();
  452. }
  453. }
  454. return output;
  455. }
  456.  
  457. function clickEl(query,qid=0,msg=my_profile+"clickEl called",callback=false){
  458. let init_clickEl = function() {
  459. clickNow(query,qid,msg,callback);
  460. };
  461. checkEl(query,qid,init_clickEl);
  462. }
  463.  
  464. function clickObject(obj){
  465. if (obj == "ok"){
  466. clickEl(".btn-usual-ok",0,message.ok);
  467. }
  468. }
  469.  
  470. function clickAndNegCheck(query,qid=0,msg="clickAndNegCheck called",callback=false,ticks=5){
  471. let old_href = window.location.href;
  472. let old_top = -1;
  473. let old_left = -1;
  474. let match = ticks-1;
  475. let str_clickAndNegCheck = clickAndNegCheck.name + ", el: " + query + "["+(qid.toString())+"] \n- match = ";
  476. let init_clickAndNegCheck = function() {
  477. let loop_clickAndNegCheck = setInterval(function() {
  478. console.log(str_clickAndNegCheck+(match.toString()));
  479. if (!(checkExist(query,qid))) {
  480. clearInterval(loop_clickAndNegCheck);
  481. if (typeof callback == "function") {
  482. callback();
  483. }
  484. }else if (old_href != window.location.href) {
  485. clearInterval(loop_clickAndNegCheck);
  486. }else{
  487. if (checkExist(query,qid)) {
  488. if (old_top==document.querySelectorAll(query)[qid].getBoundingClientRect().top && old_left==document.querySelectorAll(query)[qid].getBoundingClientRect().left) {
  489. if (match % ticks == 0) {
  490. clickNow(query,qid,msg);
  491. }
  492. match += 1;
  493. }else{
  494. old_top = document.querySelectorAll(query)[qid].getBoundingClientRect().top;
  495. old_left = document.querySelectorAll(query)[qid].getBoundingClientRect().left;
  496. }
  497. }
  498. }
  499. }, 100);
  500. };
  501. checkEl(query,qid,init_clickAndNegCheck);
  502. }
  503.  
  504. function clickAndCheck(query1,qid1=0,query2,qid2=0,msg="clickAndCheck called",callback=false,ticks=5){
  505. let old_href = window.location.href;
  506. let old_top = -1;
  507. let old_left = -1;
  508. let match = ticks-1;
  509. let str_clickAndCheck = clickAndCheck.name + ", check: " + query2 + "["+(qid2.toString())+"], click: " + query1 + "["+(qid1.toString())+"] \n- match = ";
  510. let loop_clickAndCheck = setInterval(function() {
  511. console.log(str_clickAndCheck+(match.toString()));
  512. if (checkExist(query2,qid2)) {
  513. clearInterval(loop_clickAndCheck);
  514. if (typeof callback == "function") {
  515. callback();
  516. }
  517. }else if (old_href != window.location.href) {
  518. clearInterval(loop_clickAndCheck);
  519. }else{
  520. if (checkExist(query1,qid1)) {
  521. if (old_top==document.querySelectorAll(query1)[qid1].getBoundingClientRect().top && old_left==document.querySelectorAll(query1)[qid1].getBoundingClientRect().left) {
  522. if (match % ticks == 0) {
  523. clickNow(query1,qid1,msg);
  524. }
  525. match += 1;
  526. }else{
  527. old_top = document.querySelectorAll(query1)[qid1].getBoundingClientRect().top;
  528. old_left = document.querySelectorAll(query1)[qid1].getBoundingClientRect().left;
  529. }
  530. }
  531. }
  532. }, 100);
  533. }
  534.  
  535. function popUpNotEnough(rep) {
  536. const query = ".btn-use-full.index-1",
  537. qid = 0,
  538. msg = message.replenish.elixir.half_elixir.use;
  539. let cmd = [], coordinate, consumable_data;
  540. consumable_data = my_profile+"Consumable Status:";
  541. for (let i = 0; i < rep.length; i++) {
  542. consumable_data += ("\n- "+rep[i].name+": "+rep[i].number);
  543. }
  544. let init_popUpNotEnough = function() {
  545. coordinate = getCoord(document.querySelectorAll(query)[qid]);
  546. if (coordinate!==0){
  547. cmd.push({"cmd":"clickIt","param":coordinate});
  548. cmd.push({"cmd":"log","level":"process","msg":msg});
  549. cmd.push({"cmd":"log","level":"summary","msg":consumable_data,"split":0});
  550. xhr.open('POST', server);
  551. xhr.send(JSON.stringify(cmd));
  552. }
  553. };
  554. checkEl(query,qid,init_popUpNotEnough);
  555.  
  556. }
  557.  
  558.  
  559. // function clickAndCheckSkill(query,qid=0,msg="clickAndCheckSkill called",callback=false,special_case=false){
  560. // console.log(clickAndCheckSkill.name);
  561. // console.log(callback);
  562. // console.log(query);
  563. // console.log(qid);
  564. // let old_class = document.querySelectorAll(query)[qid].parentNode.classList[0];
  565. // console.log(old_class);
  566. // let loop_clickAndCheckSkill = setInterval(function() {
  567. // console.log(loop_clickAndCheckSkill.name + " " + query + "[" + qid + "]");
  568. // if (Array.from(document.querySelectorAll(query)[qid].parentNode.parentNode.classList).indexOf("tmp-mask")>=0 || Array.from(document.querySelectorAll(query)[qid].parentNode.parentNode.classList).indexOf("btn-ability-unavailable")>=0){
  569. // clearInterval(loop_clickAndCheckSkill);
  570. // console.log(clickAndCheckSkill.name + " case normal");
  571. // if (typeof callback == "function") {
  572. // callback();
  573. // }
  574. // // Bea skill
  575. // }else if(special_case===1 && document.querySelectorAll(query)[qid].parentNode.classList[0] != old_class){
  576. // clearInterval(loop_clickAndCheckSkill);
  577. // console.log(clickAndCheckSkill.name + " case " + special_case.toString());
  578. // if (typeof callback == "function") {
  579. // callback();
  580. // }
  581. // // Out of sight & sage of eternity
  582. // }else if(special_case===2){
  583. // let do_click = true;
  584. // console.log(clickAndCheckSkill.name + " case " + special_case.toString());
  585. // let popup_query = "#wrapper > div.contents > div.pop-usual.pop-select-member > div.prt-popup-header";
  586. // if (checkExist(popup_query,0)) {
  587. // if (document.querySelector("#wrapper > div.contents > div.pop-usual.pop-select-member > div.prt-popup-header").innerHTML == "Use Skill"){
  588. // clearInterval(loop_clickAndCheckSkill);
  589. // do_click = false;
  590. // if (typeof callback == "function") {
  591. // callback();
  592. // }
  593. // }
  594. // }
  595. // if (do_click) {
  596. // if (checkExist(query,qid)) {
  597. // clickNow(query,qid,msg);
  598. // }
  599. // }
  600. // }else{
  601. // if (checkExist(query,qid)) {
  602. // clickNow(query,qid,msg);
  603. // }
  604. // }
  605.  
  606. // }, 500);
  607. // }
  608.  
  609. function clickSkill(cid,abi_id,callback=false){
  610. console.log(clickSkill.name+', cid: '+cid.toString()+', ability: '+abi_id.toString());
  611. let query = ".prt-command-chara.chara"+((cid+1).toString())+">div>div>div>.img-ability-icon";
  612. let qid = abi_id;
  613. let char = battle.player.param[cid].name;
  614. let msg = my_profile+"Clicking "+char+" skill"+((abi_id+1).toString());
  615. let old_class = document.querySelectorAll(query)[qid].parentNode.classList[0];
  616. let abi_obj = Object.values(battle.ability).find(x => x.pos === cid);
  617. let abi_name = abi_obj.list[abi_id+1][0]['ability-name'];
  618. let loop_clickSkill = setInterval(function() {
  619. console.log("loop_clickSkill " + query + "[" + qid + "]");
  620. if (Array.from(document.querySelectorAll(query)[qid].parentNode.parentNode.classList).indexOf("tmp-mask")>=0 || Array.from(document.querySelectorAll(query)[qid].parentNode.parentNode.classList).indexOf("btn-ability-unavailable")>=0){
  621. clearInterval(loop_clickSkill);
  622. console.log('case normal');
  623. if (typeof callback == "function") {
  624. callback();
  625. }
  626. } else if (abi_name === 'Runeweaving') {
  627. console.log('case Runeweaving');
  628. let do_click = true;
  629. let popup_query = '#wrapper > div.contents > div.pop-usual.pop-ability-mark > div.prt-popup-header';
  630. if (checkExist(popup_query,0)) {
  631. if (document.querySelector(popup_query).innerHTML == 'Use Skill'){
  632. clearInterval(loop_clickSkill);
  633. do_click = false;
  634. let error_special_case = true;
  635. let error_msg = 'Error skill: ';
  636. let q_invoke = '.lis-ability-mark';
  637. let q_rune = '>.lis-ability-frame';
  638.  
  639. const invoke = {'fire':'.mark1', 'water':'.mark2', 'earth':'.mark3', 'wind':'.mark4'};
  640.  
  641. if (abi_special_case === false){
  642. error_msg = 'abi_special_case is false.';
  643. } else {
  644. if (typeof abi_special_case === 'object') {
  645. if (abi_special_case.hasOwnProperty('invoke')) {
  646. if (typeof abi_special_case.invoke === 'object') {
  647. if (abi_special_case.invoke.length === 2) {
  648. if (invoke.hasOwnProperty(abi_special_case.invoke[0]) && invoke.hasOwnProperty(abi_special_case.invoke[1])) {
  649. error_special_case = false;
  650. } else {
  651. error_msg = 'abi_special_case.invoke value is invalid.';
  652. }
  653. } else {
  654. error_msg = 'abi_special_case.invoke length is invalid.';
  655. }
  656. } else {
  657. error_msg = 'abi_special_case.invoke type is invalid.';
  658. }
  659. }
  660. } else {
  661. error_msg = 'abi_special_case object \'invoke\' not found.';
  662. }
  663. }
  664. console.log('error_special_case: '+error_special_case);
  665. console.log(error_msg);
  666. if (error_special_case) {
  667. let cmd = [];
  668. cmd.push({"cmd":"log","level":"notif","msg":my_profile+error_msg+discord_mention});
  669. xhr.open('POST', server);
  670. xhr.send(JSON.stringify(cmd));
  671. } else {
  672. let q_next_rune;
  673. if (abi_special_case.invoke[0] === abi_special_case.invoke[1]) {
  674. q_next_rune = '.first.second';
  675. } else {
  676. q_next_rune = '.second:not(.first)';
  677. }
  678. let q_cast = '#wrapper > div.contents > div.pop-usual.pop-ability-mark > div.prt-popup-footer > div.btn-usual-text';
  679. let click_cast = function () {clickAndNegCheck(q_cast,0,my_profile+'Clicking cast',callback);};
  680. let next_rune = function () {clickAndCheck(q_invoke+invoke[abi_special_case.invoke[1]]+q_rune,0,q_invoke+invoke[abi_special_case.invoke[1]]+q_next_rune,0,my_profile+'Clicking second rune: '+abi_special_case.invoke[1],click_cast);};
  681. clickAndCheck(q_invoke+invoke[abi_special_case.invoke[0]]+q_rune,0,q_invoke+invoke[abi_special_case.invoke[0]]+'.first:not(.second)',0,my_profile+'Clicking first rune: '+abi_special_case.invoke[0],next_rune);
  682. }
  683.  
  684. // if (typeof callback == "function") {
  685. // callback();
  686. // }
  687. }
  688. }
  689. if (do_click) {
  690. if (checkExist(query,qid)) {
  691. clickNow(query,qid,msg);
  692. }
  693. }
  694. // // Bea skill
  695. // }else if(special_case===1 && document.querySelectorAll(query)[qid].parentNode.classList[0] != old_class){
  696. // clearInterval(loop_clickAndCheckSkill);
  697. // console.log(clickAndCheckSkill.name + " case " + special_case.toString());
  698. // if (typeof callback == "function") {
  699. // callback();
  700. // }
  701.  
  702. // // Out of sight & sage of eternity
  703. // }else if(special_case===2){
  704. // let do_click = true;
  705. // console.log(clickAndCheckSkill.name + " case " + special_case.toString());
  706. // let popup_query = "#wrapper > div.contents > div.pop-usual.pop-select-member > div.prt-popup-header";
  707. // if (checkExist(popup_query,0)) {
  708. // if (document.querySelector("#wrapper > div.contents > div.pop-usual.pop-select-member > div.prt-popup-header").innerHTML == "Use Skill"){
  709. // clearInterval(loop_clickAndCheckSkill);
  710. // do_click = false;
  711. // if (typeof callback == "function") {
  712. // callback();
  713. // }
  714. // }
  715. // }
  716. // if (do_click) {
  717. // if (checkExist(query,qid)) {
  718. // clickNow(query,qid,msg);
  719. // }
  720. // }
  721. } else {
  722. console.log('case normal');
  723. if (checkExist(query,qid)) {
  724. clickNow(query,qid,msg);
  725. }
  726. }
  727.  
  728. }, 500);
  729. }
  730.  
  731.  
  732.  
  733. function useSkills(cid, skill_list, callback=false) {
  734. let char_id = cid+1;
  735. console.log(useSkills.name);
  736. if (skill_list.length>0) {
  737. console.log(useSkills.name + ", cid: "+cid+", ability: " + (skill_list[0].toString()));
  738. let new_skill_list = Object.values(skill_list);
  739. new_skill_list.splice(0,1);
  740. let abi_id = parseInt(skill_list[0])-1;
  741. let next_skill = function(){useSkills(cid, new_skill_list, callback);};
  742. if (Array.from(document.querySelectorAll(".prt-command-chara.chara"+(char_id.toString())+">div>div.lis-ability")[abi_id].classList).indexOf("btn-ability-available")>=0 && document.querySelectorAll(".prt-command-chara.chara"+(char_id.toString())+">div>div.lis-ability")[abi_id].getBoundingClientRect().width>0){
  743. // clickAndCheckSkill(".prt-command-chara.chara"+(char_id.toString())+">div>div>div>.img-ability-icon",abi_id,my_profile+"Clicking "+char+" skill"+((abi_id+1).toString()),next_skill);
  744. clickSkill(cid,abi_id,next_skill);
  745. }else{
  746. if (typeof callback == "function") {
  747. next_skill();
  748. }
  749. }
  750. } else {
  751. if (typeof callback == "function") {
  752. callback();
  753. }
  754. }
  755. }
  756.  
  757. function usePot(pot_type, cid=false, callback=false) {
  758. console.log(usePot.name);
  759. console.log(cid);
  760. let do_click_heal = false;
  761. let front_cid = false;
  762. let player_stats = {
  763. 'need_heal': [],
  764. 'front_need_heal': [],
  765. 'need_clear': [],
  766. 'need_revive': [],
  767. };
  768. for (const i in battle.player.param) {
  769. if (battle.player.param.hasOwnProperty(i)) {
  770. const player_obj = battle.player.param[i];
  771. player_stats.need_revive.push(player_obj.alive === 1);
  772. let player_need_clear = false;
  773. if (player_obj.alive === 1) {
  774. player_stats.need_heal.push(player_obj.hpmax - player_obj.hp !== 0);
  775. if (player_obj.hasOwnProperty('condition')) {
  776. if (player_obj.condition.hasOwnProperty('debuff')) {
  777. if (player_obj.condition.debuff.length > 0) {
  778. player_need_clear = true;
  779. }
  780. }
  781. }
  782. } else {
  783. player_stats.need_heal.push(false);
  784. }
  785. player_stats.need_clear.push(player_need_clear);
  786. }
  787. }
  788.  
  789. for (const i in battle.formation) {
  790. if (battle.formation.hasOwnProperty(i)) {
  791. const front_id = parseInt(battle.formation[i]);
  792. if (cid===front_id) {
  793. front_cid = i;
  794. }
  795. player_stats.front_need_heal.push(battle.player.param[front_id].hpmax - battle.player.param[front_id].hp !== 0);
  796. }
  797. }
  798. console.log('front_cid: '+front_cid);
  799. console.log('player_stats: ');
  800. console.log(player_stats);
  801. if (pot_type==='Clarity Herb') {
  802. if (battle.hasOwnProperty('event')) {
  803. let item_obj = Object.values(battle.event.item).find(x => x.name === pot_type);
  804. if (item_obj !== undefined) {
  805. if (item_obj.number > 0 && front_cid !== false && player_stats.front_need_heal[front_cid]) {
  806. do_click_heal = true;
  807. }
  808. }
  809. }
  810. } else if (pot_type==='Green Potion') {
  811. if (battle.hasOwnProperty('temporary')) {
  812. if (battle.temporary.hasOwnProperty('small')) {
  813. let item_obj = parseInt(battle.temporary.small);
  814. console.log('item_obj');
  815. console.log(item_obj);
  816. if (item_obj !== undefined) {
  817. if (item_obj > 0 && front_cid !== false && player_stats.front_need_heal[front_cid]) {
  818. do_click_heal = true;
  819. }
  820. }
  821. }
  822. }
  823. } else if (pot_type==='Blue Potion') {
  824. if (battle.hasOwnProperty('temporary')) {
  825. if (battle.temporary.hasOwnProperty('large')) {
  826. let item_obj = parseInt(battle.temporary.large);
  827. console.log('item_obj');
  828. console.log(item_obj);
  829. if (item_obj !== undefined) {
  830. if (item_obj > 0 && player_stats.front_need_heal.indexOf(true)>=0) {
  831. do_click_heal = true;
  832. }
  833. }
  834. }
  835. }
  836. }
  837. console.log('do_click_heal:');
  838. console.log(do_click_heal);
  839.  
  840. let clickCancel = function() {
  841. clickAndNegCheck(query.battle_ui.heal_pop_up.cancel,0,my_profile+"Clicking cancel from pot pop up",callback);
  842. };
  843.  
  844. let clickUse = function() {
  845. clickAndNegCheck(query.battle_ui.heal_pop_up.use,0,my_profile+"Clicking use from pot pop up",callback);
  846. };
  847. let clickFront = function() {
  848. clickAndCheck(query.battle_ui.char_ico,front_cid,query.battle_ui.summon_panel+":not(.mask-black)",0,my_profile+"Clicking char_ico from pot pop up",callback);
  849. };
  850.  
  851. let clickPot = function() {
  852. console.log(clickPot.name);
  853. let query_qty = ">.txt-having>.having-num";
  854. let pot_available = false;
  855. let init_clickPot = function () {
  856. if (checkExist(query.battle_ui.heal_pop_up[pot_type]+query_qty)) {
  857. if ( parseInt(document.querySelector(query.battle_ui.heal_pop_up[pot_type]+query_qty).innerHTML) > 0 ) {
  858. pot_available = true;
  859. if (pot_type == 'Blue Potion') {
  860. clickAndNegCheck(query.battle_ui.heal_pop_up[pot_type]+">img",0,my_profile+"Clicking "+ pot_type +" pot",clickUse);
  861. }else if (pot_type == 'Green Potion') {
  862. clickAndNegCheck(query.battle_ui.heal_pop_up[pot_type]+">img",0,my_profile+"Clicking "+ pot_type +" pot",clickFront);
  863. }else if (pot_type == 'Clarity Herb') {
  864. clickAndNegCheck(query.battle_ui.heal_pop_up[pot_type]+">img",0,my_profile+"Clicking "+ pot_type +" pot",clickFront);
  865. }else{
  866. console.log("pot_type unknown");
  867. clickCancel();
  868. }
  869. }
  870. // console.log("pot qty not > 0");
  871. // clickCancel();
  872. // }
  873. // }else{
  874. // console.log("element not exist");
  875. // clickCancel();
  876. }
  877. if (!pot_available) {
  878. clickCancel();
  879. }
  880. };
  881. checkEl(query.battle_ui.heal_pop_up[pot_type]+">img",0,init_clickPot);
  882. };
  883. if (do_click_heal) {
  884. clickAndCheck(query.battle_ui.heal,0,query.battle_ui.heal_pop_up[pot_type]+">img",0,my_profile+"Clicking heal pop up",clickPot);
  885. } else {
  886. if (typeof callback == "function") {
  887. callback();
  888. }
  889. }
  890.  
  891. }
  892.  
  893. function usePots(pot_type,list_cid=[],callback=false) {
  894. console.log('usePots');
  895. console.log('pot_type');
  896. console.log(pot_type);
  897. console.log('list_cid');
  898. console.log(list_cid);
  899. if (list_cid > 0) {
  900. let new_list_cid = Object.values(list_cid);
  901. new_list_cid.splice(0,1);
  902. let next_clear = function(){usePots(pot_type,new_list_cid, callback);};
  903. usePot(pot_type,parseInt(list_cid[0]),next_clear);
  904. } else {
  905. if (typeof callback == "function") {
  906. callback();
  907. }
  908. }
  909. }
  910.  
  911. // function usePot (pot_type,char_id=false,callback=false) {
  912. // // console.log(usePot.name);
  913. // let is_front_healable = [];
  914. // let is_player_reviveable = [];
  915. // let is_player_healable = [];
  916. // for (const i in battle.player.param) {
  917. // if (battle.player.param.hasOwnProperty(i)) {
  918. // if (battle.player.param[i].alive === 1) {
  919. // is_player_reviveable.push(false);
  920. // is_player_healable.push(battle.player.param[i].hpmax - battle.player.param[i].hp !== 0);
  921. // }else{
  922. // is_player_reviveable.push(true);
  923. // is_player_healable.push(false);
  924. // }
  925. // }
  926. // }
  927. // for (const i in rep.formation) {
  928. // if (rep.formation.hasOwnProperty(i)) {
  929. // const alive_id = parseInt(rep.formation[i]);
  930. // is_front_healable.push(battle.player.param[alive_id].hpmax - battle.player.param[alive_id].hp !== 0);
  931. // }
  932. // }
  933. // let query_qty = ">.txt-having>.having-num";
  934. // let clickUse = function() {
  935. // clickAndNegCheck(query.battle_ui.heal_pop_up.use,0,my_profile+"Clicking use from pot pop up",callback);
  936. // };
  937. // let clickFront = function() {
  938. // clickAndCheck(query.battle_ui.char_ico,char_id,query.battle_ui.summon_panel+":not(.mask-black)",0,my_profile+"Clicking char_ico from pot pop up",callback);
  939. // };
  940. // let clickCancel = function() {
  941. // clickAndNegCheck(query.battle_ui.heal_pop_up.cancel,0,my_profile+"Clicking cancel from pot pop up",callback);
  942. // };
  943. // let clickPot = function() {
  944. // console.log(clickPot.name);
  945. // if (checkExist(query.battle_ui.heal_pop_up[pot_type]+query_qty)) {
  946. // if ( parseInt(document.querySelector(query.battle_ui.heal_pop_up[pot_type]+query_qty).innerHTML) > 0 ) {
  947. // if (pot_type == "blue") {
  948. // clickAndNegCheck(query.battle_ui.heal_pop_up[pot_type]+">img",0,my_profile+"Clicking "+ pot_type +" pot",clickUse);
  949. // }else if (pot_type == "green") {
  950. // clickAndNegCheck(query.battle_ui.heal_pop_up[pot_type]+">img",0,my_profile+"Clicking "+ pot_type +" pot",clickFront);
  951. // }else{
  952. // console.log("pot_type unknown");
  953. // clickCancel();
  954. // }
  955. // }else{
  956. // console.log("pot qty not > 0");
  957. // clickCancel();
  958. // }
  959. // }else{
  960. // console.log("element not exist");
  961. // clickCancel();
  962. // }
  963. // };
  964. // let clickHeal = function() {
  965. // console.log(clickHeal.name);
  966. // clickAndCheck(query.battle_ui.heal,0,query.battle_ui.heal_pop_up[pot_type]+">img",0,my_profile+"Clicking heal pop up",clickPot,20);
  967. // };
  968. // let do_heal = false;
  969. // if (pot_type=="blue" && is_front_healable.indexOf(true)>=0) {
  970. // do_heal = true;
  971. // }else if (pot_type=="green" && is_player_healable[char_id]) {
  972. // do_heal = true;
  973. // }else{
  974. // if (typeof callback == "function") {
  975. // callback();
  976. // }
  977. // }
  978. // if (do_heal) {
  979. // checkEl(query.battle_ui.heal,0,clickHeal);
  980. // }
  981. // }
  982.  
  983. function clickBackup(callback=false) {
  984. let check_backup = function() {
  985. let el_btn, backup_msg;
  986. if (Array.from(document.querySelector(query.battle_ui.backup_pop_up.request).classList).indexOf("disable") >= 0) {
  987. el_btn = query.battle_ui.backup_pop_up.cancel;
  988. backup_msg = "cancel";
  989. } else {
  990. el_btn = query.battle_ui.backup_pop_up.request;
  991. backup_msg = "request";
  992. }
  993. clickAndNegCheck(el_btn,0,my_profile+"Clicking "+backup_msg,callback,10);
  994. };
  995. clickAndCheck(query.battle_ui.button.assist,0,query.battle_ui.backup_pop_up.request,0,my_profile+"Clicking backup",check_backup,10);
  996. }
  997.  
  998. function clickBack(callback=false){
  999. clickAndCheck(".btn-command-back.display-on",0,"div.prt-member",0,my_profile+"Clicking back",callback,10);
  1000. }
  1001.  
  1002. function clickSummonPanel(callback=false){
  1003. console.log(clickSummonPanel.name);
  1004. let query1 = ".prt-list-top.btn-command-summon.summon-on";
  1005. let query2 = ".prt-summon-list.opened";
  1006. let query3 = ".prt-list-top.btn-command-summon.summon-off";
  1007. let qid1 = 0, qid2 = 0, qid3 = 0;
  1008. let msg = my_profile+"Clicking summon panel";
  1009. let old_top = -1;
  1010. let old_left = -1;
  1011. let loop_clickAndCheck = setInterval(function() {
  1012. console.log(clickAndCheck.name + ", check: " + query2 + "["+(qid2.toString())+"], click: " + query1 + "["+(qid1.toString())+"]");
  1013. if (checkExist(query2,qid2) || checkExist(query3,qid3)) {
  1014. clearInterval(loop_clickAndCheck);
  1015. if (typeof callback == "function") {
  1016. callback();
  1017. }
  1018. }else{
  1019. if (checkExist(query1,qid1)) {
  1020. if (old_top==document.querySelectorAll(query1)[qid1].getBoundingClientRect().top && old_left==document.querySelectorAll(query1)[qid1].getBoundingClientRect().left) {
  1021. clickNow(query1,qid1,msg);
  1022. }else{
  1023. old_top = document.querySelectorAll(query1)[qid1].getBoundingClientRect().top;
  1024. old_left = document.querySelectorAll(query1)[qid1].getBoundingClientRect().left;
  1025. }
  1026. }
  1027. }
  1028. }, 200);
  1029. }
  1030.  
  1031. function clickSummon(summon_id,callback1=false,callback2=false){
  1032. console.log(clickSummon.name);
  1033. summon_id = summon_id-1;
  1034. if (Array.from(document.querySelectorAll(".lis-summon")[summon_id].classList).indexOf("btn-summon-available")>=0){
  1035. let loop_clickSummon = setInterval(function() {
  1036. if (document.querySelectorAll(".lis-summon>img")[summon_id].getBoundingClientRect().x === document.querySelectorAll(".lis-summon>img")[0].getBoundingClientRect().x + (summon_id * (document.querySelectorAll(".lis-summon>img")[0].getBoundingClientRect().width+2))){
  1037. clearInterval(loop_clickSummon);
  1038. clickAndCheck(".lis-summon>img",summon_id,".pop-usual.pop-summon-detail>div>.btn-usual-ok.btn-summon-use",0,my_profile+"Clicking summon "+((summon_id+1).toString()),callback1);
  1039. }
  1040. }, 300);
  1041. }else{
  1042. if (typeof callback2 == "function") {
  1043. callback2();
  1044. }
  1045. }
  1046. }
  1047.  
  1048. function clickOkSummon(callback=false){
  1049. console.log(clickOkSummon.name);
  1050. let el_ok = ".pop-usual.pop-summon-detail>div>.btn-usual-ok.btn-summon-use";
  1051. if (document.querySelector(el_ok) !== null){
  1052. clickAndCheck(el_ok,0,"div.prt-member",0,my_profile+"Clicking summon ok",callback);
  1053. }else{
  1054. if (typeof callback == "function") {
  1055. callback();
  1056. }
  1057. }
  1058. }
  1059. function clickOkSummon2(summon_id,callback=false){
  1060. let el_ok = ".pop-usual.pop-summon-detail>div>.btn-usual-ok.btn-summon-use";
  1061. let summon_el = '.lis-summon[pos="'+(summon_id.toString())+'"]';
  1062. if (document.querySelector(el_ok) !== null){
  1063. let loop_clickOkSummon2 = setInterval(function() {
  1064. console.log(clickOkSummon2.name + ", click: " + el_ok + "[0]");
  1065. if (Array.from(document.querySelector(summon_el).classList).indexOf("tmp-mask")>=0 || Array.from(document.querySelector(summon_el).classList).indexOf("btn-summon-unavailable")>=0) {
  1066. clearInterval(loop_clickOkSummon2);
  1067. if (typeof callback == "function") {
  1068. callback();
  1069. }
  1070. }else{
  1071. if (checkExist(el_ok,0)) {
  1072. clickNow(el_ok,0,my_profile+"Clicking summon ok2");
  1073. }
  1074. }
  1075. }, 1000);
  1076. }else{
  1077. if (typeof callback == "function") {
  1078. callback();
  1079. }
  1080. }
  1081. }
  1082.  
  1083. function selectSummon(preferred_summon,is_trial=false){
  1084. reload(20);
  1085.  
  1086. let init_selectSummon = function() {
  1087. console.log(init_selectSummon.name);
  1088. reload(10);
  1089. const attrib_list = [6,0,1,2,3,4,5];
  1090. let query_summon_list = ".btn-supporter.lis-supporter";
  1091. let el_summon_list = document.querySelectorAll(query_summon_list);
  1092. let preferred_summon_id = false;
  1093. let picked_attrib_id = false;
  1094. let picked_summon_id = false;
  1095. let picked_is_friend = false;
  1096. let is_friend;
  1097. let picked_summon_stars = false;
  1098. let picked_summon_level = false;
  1099. let picked_summon_plus = false;
  1100. let msg;
  1101. let cmd = [], summon_list = {};
  1102. if (el_summon_list.length>50 && document.querySelector(".prt-supporter-battle-announce")===null && document.querySelector(".txt-confirm-comment")===null && document.querySelector(".prt-check-auth")===null && document.querySelector(".btn-check-auth")===null){
  1103. msg = my_profile+"Verify not appear, summon list length is "+(el_summon_list.length.toString());
  1104. console.log(msg);
  1105.  
  1106. // check if raid is trial
  1107. if (!is_trial){
  1108. console.log("not trial");
  1109. for (let i = 0; i < el_summon_list.length; i++) {
  1110. let match_preferred = false, replace = false;
  1111. let temp_var, summon_detail, summon_name, summon_level, summon_stars, summon_plus;
  1112. temp_var = el_summon_list[i].querySelector(".prt-supporter-summon");
  1113. summon_detail = temp_var.innerHTML.trim();
  1114. temp_var = el_summon_list[i].querySelector(".prt-supporter-summon");
  1115. summon_detail = temp_var.innerHTML.trim();
  1116. summon_name = summon_detail.substring(summon_detail.indexOf("</span>")+8,summon_detail.length);
  1117. summon_level = parseInt(temp_var.children[0].innerHTML.replace("Lvl ",""));
  1118. temp_var = Array.from(el_summon_list[i].querySelector(".prt-summon-skill").classList);
  1119. if (temp_var.indexOf("bless-rank3-style")>=0){
  1120. summon_stars = 5;
  1121. }else if (temp_var.indexOf("bless-rank2-style")>=0){
  1122. summon_stars = 4;
  1123. }else if (temp_var.indexOf("bless-rank1-style")>=0){
  1124. summon_stars = 3;
  1125. }else{
  1126. summon_stars = 0;
  1127. }
  1128. temp_var = el_summon_list[i].querySelector(".prt-summon-quality");
  1129. if (temp_var !== null){
  1130. summon_plus = parseInt(temp_var.innerHTML.replace("+",""));
  1131. }else{
  1132. summon_plus = 0;
  1133. }
  1134. temp_var = false;
  1135. is_friend = Array.from(el_summon_list[i].querySelector(".prt-supporter-name").classList).indexOf("ico-friend")>=0;
  1136.  
  1137. // loop preferred summon list (specified in parameter)
  1138. for (let j = 0; j < preferred_summon.length; j++) {
  1139. if (preferred_summon[j].name==summon_name && preferred_summon[j].star<=summon_stars){
  1140. match_preferred = true;
  1141. temp_var = j;
  1142. }
  1143. }
  1144.  
  1145.  
  1146. if (match_preferred){
  1147. if (picked_attrib_id===false && picked_summon_id===false){
  1148. replace = true;
  1149. }else{
  1150. if (preferred_summon_id>temp_var){
  1151. replace = true;
  1152. }else if(preferred_summon_id==temp_var){
  1153. if (summon_stars>picked_summon_stars){
  1154. replace = true;
  1155. }else if(summon_stars==picked_summon_stars){
  1156. if (!picked_is_friend && is_friend){
  1157. replace = true;
  1158. }else if(picked_is_friend && is_friend){
  1159. if (summon_level>picked_summon_level){
  1160. replace = true;
  1161. }else if(summon_level==picked_summon_level){
  1162. if (summon_plus>picked_summon_plus){
  1163. replace = true;
  1164. }
  1165. }
  1166. }
  1167. }
  1168. }
  1169. }
  1170. }
  1171. if (replace){
  1172. picked_attrib_id = Array.from(document.querySelectorAll(".prt-supporter-attribute")).indexOf(el_summon_list[i].parentElement);
  1173. picked_summon_id = i;
  1174. preferred_summon_id = temp_var;
  1175. picked_summon_stars = summon_stars;
  1176. picked_is_friend = is_friend;
  1177. picked_summon_level = summon_level;
  1178. picked_summon_plus = summon_plus;
  1179. }
  1180. }
  1181. console.log([picked_attrib_id,picked_summon_id,preferred_summon_id]);
  1182. if (picked_summon_id===false){
  1183. console.log("go to trial");
  1184. cmd.push({"cmd":"log","level":"process","msg":message.summon.not_found});
  1185. xhr.open("POST", server);
  1186. xhr.send(JSON.stringify(cmd));
  1187. gotoHash("trial");
  1188. }else{
  1189. console.log("summon_found");
  1190. let pickSummon = function() {
  1191. scrollTo(query_summon_list,picked_summon_id);
  1192. clickEl(query_summon_list,picked_summon_id,message.summon.select);
  1193. };
  1194. let clickAndCheckSummon = function(callback=false){
  1195. let el_tab_ele_ico = ".prt-type-text";
  1196. let el_summon_container = ".prt-supporter-attribute";
  1197. let loop_clickAndCheckSummon = setInterval(function() {
  1198. console.log(clickAndCheckSummon.name + ", check: " + el_summon_container + "[" + picked_attrib_id + "], click: " + el_tab_ele_ico + "["+(attrib_list[picked_attrib_id].toString())+"]");
  1199. if (Array.from(document.querySelectorAll(el_summon_container)[picked_attrib_id].classList).indexOf("disableView") == -1) {
  1200. clearInterval(loop_clickAndCheckSummon);
  1201. if (typeof callback == "function") {
  1202. callback();
  1203. }
  1204. }else{
  1205. if (checkExist(el_tab_ele_ico, attrib_list[picked_attrib_id])) {
  1206. clickNow(el_tab_ele_ico, attrib_list[picked_attrib_id], message.summon.pick_tab);
  1207. }
  1208. }
  1209. }, 300);
  1210. };
  1211. clickAndCheckSummon(pickSummon);
  1212. }
  1213. }else{
  1214. console.log("is trial");
  1215. query_summon_list = ".prt-supporter-attribute:not(.disableView)>.btn-supporter.lis-supporter";
  1216. el_summon_list = document.querySelectorAll(query_summon_list);
  1217. for (let i = 0; i < el_summon_list.length; i++) {
  1218. is_friend = Array.from(el_summon_list[i].querySelector(".prt-supporter-name").classList).indexOf("ico-friend")>=0;
  1219. if (!is_friend){
  1220. if (picked_summon_id===false){
  1221. picked_summon_id = i;
  1222. }
  1223. }
  1224. }
  1225. if (picked_summon_id!==false){
  1226. scrollTo(".prt-supporter-attribute:not(.disableView)>.btn-supporter.lis-supporter",picked_summon_id);
  1227. clickEl(".prt-supporter-attribute:not(.disableView)>.btn-supporter.lis-supporter",picked_summon_id,message.summon.select);
  1228. }
  1229. }
  1230. }else{
  1231. msg = my_profile+"Verify might appear, summon list length is "+(el_summon_list.length.toString());
  1232. clearInterval(reload_counter);
  1233. console.log(msg);
  1234. cmd.push({"cmd":"log","level":"process","msg":msg});
  1235. cmd.push({"cmd":"log","level":"notif","msg":msg});
  1236. xhr.open("POST", server);
  1237. xhr.send(JSON.stringify(cmd));
  1238. }
  1239. };
  1240. checkEl(".prt-supporter-title",0,init_selectSummon);
  1241. }
  1242.  
  1243. function doChat(callback=false) {
  1244. console.log(doChat.name);
  1245. let clickDialog = function() {
  1246. console.log(clickDialog.name);
  1247. clickAndNegCheck(query.battle_ui.chat_pop_up.dialog,0,my_profile+"Clicking chat dialog",callback);
  1248. };
  1249. let clickChat = function() {
  1250. console.log(clickChat.name);
  1251. if (checkExist(query.battle_ui.chat+">.ico-attention",0)) {
  1252. clickAndCheck(query.battle_ui.chat,0,query.battle_ui.chat_pop_up.dialog,0,my_profile+"Clicking chat pop up",clickDialog,20);
  1253. }else{
  1254. if (typeof callback == "function") {
  1255. callback();
  1256. }
  1257. }
  1258. };
  1259. checkEl(query.battle_ui.chat,0,clickChat);
  1260. }
  1261.  
  1262. function backFromTrial(){
  1263. let cmd = [];
  1264. cmd.push({"cmd":"log","level":"process","msg":message.raid.trial.end});
  1265. xhr.open("POST", server);
  1266. xhr.send(JSON.stringify(cmd));
  1267. gotoHash("main");
  1268. }
  1269.  
  1270. function gotoResult() {
  1271. console.log(gotoResult.name);
  1272. console.log(is_host);
  1273. if (is_host || window.location.hash.indexOf("#raid/")>=0) {
  1274. gotoHash("quest");
  1275. }else if (window.location.hash.indexOf("#raid_multi")>=0) {
  1276. reloadNow();
  1277. }
  1278. }
  1279.  
  1280. function attack(rep){
  1281. console.log(attack.name);
  1282. let cmd = [];
  1283. let reps = rep.scenario;
  1284. let win = false;
  1285. let is_last_raid = false;
  1286. let ougi = 0;
  1287. let msg = "";
  1288. for (let i = 0; i < reps.length; i++) {
  1289. if (reps[i].cmd =="win"){
  1290. if (reps[i].is_last_raid){is_last_raid=true;}
  1291. win=true;
  1292. }else if (reps[i].cmd=="special" || reps[i].cmd=="special_npc"){
  1293. const char_name = battle.player.param[parseInt(battle.formation[reps[i].pos])].name;
  1294. msg += my_profile+char_name+" used ougi \""+reps[i].name+"\".\n";
  1295. if (reps[i].total){msg += my_profile+char_name+" dealt "+reps[i].total[0].split.join("")+" damage.\n";}
  1296. ougi++;
  1297. }else if (reps[i].cmd=="attack" && reps[i].from=="player"){
  1298. const char_name = battle.player.param[parseInt(battle.formation[reps[i].pos])].name;
  1299. if (reps[i].damage.length==3){
  1300. msg += my_profile+char_name+" made a triple attack.\n";
  1301. }else if (reps[i].damage.length==2){
  1302. msg += my_profile+char_name+" made a double attack.\n";
  1303. }
  1304. msg += my_profile+char_name+ " dealt ";
  1305. for (let ii=0; ii<reps[i].damage.length; ii++){
  1306. msg += reps[i].damage[ii][0].value.toString();
  1307. if (ii<reps[i].damage.length-1){
  1308. msg += ", ";
  1309. }else{
  1310. msg += " damage.\n";
  1311. }
  1312. }
  1313. }
  1314. }
  1315.  
  1316. if(win){
  1317. cmd.push({"cmd":"log","level":"process","msg":msg+my_profile+"Foe defeated."});
  1318. }else{
  1319. cmd.push({"cmd":"log","level":"process","msg":msg+my_profile+"Foe is still alive."});
  1320. cmd.push({"cmd":"press","key":"f5"});
  1321. }
  1322. xhr.open('POST', server);
  1323. xhr.send(JSON.stringify(cmd));
  1324. if(win && is_last_raid){
  1325. gotoResult();
  1326. }else if(win){
  1327. clickEl(".btn-result",0,my_profile+"Go to next round");
  1328. }
  1329. }
  1330.  
  1331. function skillUsed(rep){
  1332. console.log(skillUsed.name);
  1333. let do_reload = false;
  1334. let reps = rep.scenario;
  1335. let win = false, is_last_raid = false;
  1336. console.log(reps);
  1337. for (let i = 0; i < reps.length; i++) {
  1338. const scenario = reps[i];
  1339. if (scenario.cmd =="ability"){
  1340. if (reloadable_skill.indexOf(scenario.name)>= 0) {
  1341. do_reload = true;
  1342. }
  1343. }else if (scenario.cmd =="damage") {
  1344. if (scenario.to == "player") {
  1345. for (let j = 0; j < scenario.list.length; j++) {
  1346. const s = scenario.list[j];
  1347. if (s.hp !== undefined && s.pos !== undefined) {
  1348. battle.player.param[s.pos].hp = s.hp;
  1349. }
  1350. }
  1351. }
  1352. }else if (scenario.cmd =="finished"){
  1353. win=true;
  1354. is_last_raid=true;
  1355. }else if (scenario.cmd == "win"){
  1356. if (scenario.is_last_raid) {
  1357. is_last_raid=true;
  1358. }
  1359. win=true;
  1360. }
  1361. }
  1362. if(win && is_last_raid){
  1363. gotoResult();
  1364. }else if (win && !is_last_raid) {
  1365. clickEl(".btn-result",0,my_profile+"Go to next round");
  1366. }else if(do_reload){
  1367. reloadNow();
  1368. }
  1369. }
  1370.  
  1371. function summonUsed(rep){
  1372. console.log(summonUsed.name);
  1373. let do_reload = false;
  1374. let reps = rep.scenario;
  1375. let win = false,
  1376. is_last_raid = false;
  1377. for (let i = 0; i < reps.length; i++) {
  1378. const scenario = reps[i];
  1379. if (scenario.cmd == "finished"){
  1380. win=true;
  1381. is_last_raid=true;
  1382. }else if (scenario.cmd == "win"){
  1383. if (scenario.is_last_raid){
  1384. is_last_raid=true;
  1385. }
  1386. win=true;
  1387. }
  1388. }
  1389. if (battle.lyria_pos >= 0) {
  1390. do_reload = true;
  1391. }
  1392. if(win && is_last_raid){
  1393. gotoResult();
  1394. }else if(do_reload){
  1395. reloadNow();
  1396. }
  1397. }
  1398.  
  1399. function potUsed(rep) {
  1400. console.log(potUsed.name);
  1401. let reps = rep.scenario;
  1402. for (let i = 0; i < reps.length; i++) {
  1403. const scenario = reps[i];
  1404. if (scenario.cmd == "heal") {
  1405. for (let j = 0; j < scenario.list.length; j++) {
  1406. const s = scenario.list[j];
  1407. if (s.hp !== undefined && s.pos !== undefined) {
  1408. battle.player.param[s.pos].hp = s.hp;
  1409. }
  1410. }
  1411. }
  1412. }
  1413. }
  1414.  
  1415.  
  1416. function clickAttack(callback=false) {
  1417. let hp = ((parseInt(battle.boss.param[0].hp) / parseInt(battle.boss.param[0].hpmax)) * 100).toString();
  1418. if (hp.indexOf(".")>=0){
  1419. hp = hp.substring(0,hp.indexOf("."));
  1420. }
  1421. console.log(hp);
  1422. let attack_msg = my_profile+"Foe hp is "+hp+"% left, commencing attack";
  1423. clickAndCheck(".btn-attack-start.display-on",0,".btn-attack-cancel.btn-cancel.display-on",0,attack_msg,callback,20);
  1424. }
  1425.  
  1426. function charMoveSet(cid,skill_list,callback) {
  1427. if (!(Number.isInteger(cid))) {
  1428. cid = battle.player.param.findIndex(x => x.name === cid);
  1429. }
  1430. console.log(charMoveSet.name + ': ' + cid);
  1431. let char = battle.player.param[cid];
  1432. console.log(char.name);
  1433. if (char !== undefined) {
  1434. let can_use_skill = true;
  1435. if (skill_list.length>0) {
  1436. let new_skill_list = Object.values(skill_list);
  1437. for (let i = 0; i < skill_list.length; i++) {
  1438. const skill = skill_list[i];
  1439. if (document.querySelector(query.battle_ui.skill['char'+(cid+1).toString()]['skill'+(skill.toString())]).attributes.state.value != "2") {
  1440. new_skill_list.splice(new_skill_list.indexOf(skill),1);
  1441. }
  1442. }
  1443. skill_list = new_skill_list;
  1444. if ("debuff" in char.condition) {
  1445. for (let i = 0; i < char.condition.debuff.length; i++) {
  1446. const debuff = char.condition.debuff[i];
  1447. if (debuff.status == "1111" || debuff.status == "1102") {
  1448. can_use_skill = false;
  1449. }
  1450. // 1102
  1451. }
  1452. }
  1453. }
  1454. if (char.alive===1 && skill_list.length>0 && can_use_skill) {
  1455. let click_back = function(){clickBack(callback);};
  1456. let use_skills = function(){useSkills(cid,skill_list,click_back);};
  1457. let click_char = function(){clickChar(cid+1,use_skills);};
  1458. click_char();
  1459. } else {
  1460. if (typeof callback == "function") {
  1461. callback();
  1462. }
  1463. }
  1464. } else {
  1465. if (typeof callback == "function") {
  1466. callback();
  1467. }
  1468. }
  1469. }
  1470.  
  1471.  
  1472. function toggleOugi(ougi, callback=false) {
  1473. let init_toggleOugi = function() {
  1474. let current_ougi = "."+document.querySelector(query.battle_ui.ougi).classList[1];
  1475. if (query.battle_ui.toggle_ougi[ougi] != current_ougi){
  1476. clickAndCheck(query.battle_ui.ougi + current_ougi, 0, query.battle_ui.ougi + query.battle_ui.toggle_ougi[ougi], 0, my_profile+"Set toggle ougi to "+(ougi.toString()), callback);
  1477. }else{
  1478. if (typeof callback == "function") {
  1479. callback();
  1480. }
  1481. }
  1482. };
  1483. checkEl(query.battle_ui.ougi,0,init_toggleOugi);
  1484. }
  1485.  
  1486. function summoning(summon_id,callback=false) {
  1487. console.log(summoning.name);
  1488. let summon_cd;
  1489. console.log('test 1');
  1490. if (summon_id === 5) {
  1491. console.log('test 2');
  1492. summon_cd = battle.supporter.recast;
  1493. console.log('test 3');
  1494. } else if (battle.summon[summon_id] !== undefined) {
  1495. console.log('test 4');
  1496. summon_cd = battle.summon[summon_id].recast;
  1497. console.log('test 5');
  1498. }
  1499. console.log('test 6');
  1500. if (summon_cd === "0") {
  1501. console.log('test 7');
  1502. let summon_ok = function(){clickOkSummon(callback);};
  1503. let summon = function(){clickSummon(summon_id+1,summon_ok,callback);};
  1504. let summon_p = function(){clickSummonPanel(summon);};
  1505. summon_p();
  1506. } else {
  1507. console.log('test 8');
  1508. if (typeof callback == "function") {
  1509. callback();
  1510. }
  1511. }
  1512. }
  1513.  
  1514. function pickUnclaimedRaid(rep) {
  1515. if (rep.count > 0) {
  1516. let el_raid = ".prt-raid-info";
  1517. let init_pickUnlaimedRaid = function() {
  1518. gotoHash(rep.list[0].href);
  1519. };
  1520. checkEl(el_raid,0,init_pickUnlaimedRaid);
  1521. }else{
  1522. gotoHash('main');
  1523. }
  1524. }
  1525.  
  1526. function startRaid(rep){
  1527. reload(15);
  1528. battle = rep;
  1529. is_host = rep.is_host;
  1530. for (let i = 0; i < battle.player.param.length; i++) {
  1531. const c = battle.player.param[i];
  1532. if (c.alive === 1) {
  1533. is_wiped = false;
  1534. }
  1535. }
  1536.  
  1537. let check_exist = setInterval(function() {
  1538. console.log("querying enemy name to appear");
  1539. if (document.querySelector("a.btn-targeting.enemy-1:not(.invisible)") !== null || document.querySelector("a.btn-targeting.enemy-2:not(.invisible)") !== null || document.querySelector("a.btn-targeting.enemy-3:not(.invisible)") !== null){
  1540. console.log("check width enemy name");
  1541. if (document.querySelector("a.btn-targeting.enemy-1:not(.invisible)").getBoundingClientRect().width>0 || document.querySelector("a.btn-targeting.enemy-2:not(.invisible)").getBoundingClientRect().width>0 || document.querySelector("a.btn-targeting.enemy-3:not(.invisible)").getBoundingClientRect().width>0){
  1542. console.log("found enemy name");
  1543. clearInterval(check_exist);
  1544. let is_quest_id_valid = false;
  1545. let is_twitter_valid = false;
  1546. try{
  1547. console.log(rep.quest_id);
  1548. if (rep.quest_id!==undefined) {
  1549. is_quest_id_valid = true;
  1550. }
  1551. }
  1552. catch(err){
  1553. console.log(err.message);
  1554. }
  1555. console.log("is_quest_id_valid:" +(is_quest_id_valid).toString());
  1556. try{
  1557. console.log(rep.twitter.monster);
  1558. if (rep.twitter.monster!==undefined) {
  1559. is_twitter_valid = true;
  1560. }
  1561. }
  1562. catch(err){
  1563. console.log(err.message);
  1564. }
  1565. console.log("is_twitter_valid:" +(is_twitter_valid).toString());
  1566. let case_battle = false;
  1567. if (is_quest_id_valid){
  1568. if (battle.is_trialbattle) {
  1569. case_battle = 99;
  1570. }else{
  1571. for (let i in quests_id) {
  1572. if (rep.quest_id == quests_id[i] && case_battle === false) {
  1573. case_battle = parseInt(i)+1;
  1574. }
  1575. }
  1576. }
  1577. }
  1578. if (case_battle === false && is_twitter_valid){
  1579. for (let i in monsters_name) {
  1580. if (rep.twitter.monster==monsters_name[i] && case_battle === false) {
  1581. case_battle = parseInt(i)+1;
  1582. }
  1583. }
  1584. }
  1585. console.log("case_battle:" + case_battle.toString());
  1586. let hp = ((parseInt(rep.boss.param[0].hp) / parseInt(rep.boss.param[0].hpmax)) * 100).toString();
  1587. if (hp.indexOf(".")>=0){
  1588. hp = hp.substring(0,hp.indexOf("."));
  1589. }
  1590. battleLogic(case_battle);
  1591. }
  1592. }
  1593. }, 300);
  1594. }
  1595.  
  1596. function clickChar(param,callback=false) {
  1597. clickAndCheck("div.prt-member>div.btn-command-character>img.img-chara-command",param-1,".prt-command-chara.chara"+(param.toString()),0,my_profile+"Clicking "+battle.player.param[param-1].name,callback);
  1598. }
  1599.  
  1600. function clickBoss(boss_id,callback=false) {
  1601. const boss_id_str = (boss_id+1).toString();
  1602. if (battle.boss.param[boss_id] !== undefined || battle.boss.param[boss_id].alive === 1) {
  1603. clickAndCheck('.enemy-info>.name',boss_id,'.btn-targeting.enemy-'+boss_id_str+'.lock-on',0,my_profile+'Clicking Boss '+boss_id_str,callback);
  1604. } else {
  1605. if (typeof callback == "function") {
  1606. callback();
  1607. }
  1608. }
  1609. }
  1610.  
  1611. function raidFinish(rep,send_all_loot=false){
  1612. console.log(raidFinish.name);
  1613. reload(10);
  1614. let cmd = [];
  1615. let tracked_loot = [];
  1616. let check_timer = true;
  1617. cmd.push({"cmd":"log","level":"process","msg":message.raid.finish});
  1618.  
  1619. let all_loot = {};
  1620. let important_loot = {};
  1621. for (const i in rep.rewards.reward_list) {
  1622. if (rep.rewards.reward_list.hasOwnProperty(i)) {
  1623. const loots = rep.rewards.reward_list[i];
  1624. for (const j in loots) {
  1625. if (loots.hasOwnProperty(j)) {
  1626. const loot = loots[j];
  1627. if ( ( ['weapon','summon'].indexOf(loot.type) >= 0 ) && loot.rarity=='4') {
  1628. if (tracked_loot.indexOf(loot.name)===-1) {
  1629. tracked_loot.push(loot.name);
  1630. }
  1631. } else if (tracker_reward_weapons.indexOf(loot.name) >= 0 || tracker_reward_summons.indexOf(loot.name) >= 0 || tracker_reward_items.indexOf(loot.name) >= 0) {
  1632. if (tracked_loot.indexOf(loot.name)===-1) {
  1633. tracked_loot.push(loot.name);
  1634. }
  1635. }
  1636. if (all_loot[loot.name]===undefined) {
  1637. all_loot[loot.name] = parseInt(loot.count);
  1638. } else {
  1639. all_loot[loot.name] += parseInt(loot.count);
  1640. }
  1641. }
  1642. }
  1643. }
  1644. }
  1645. if (send_all_loot) {
  1646. important_loot = all_loot;
  1647. } else {
  1648. for (const loot in all_loot) {
  1649. if (all_loot.hasOwnProperty(loot)) {
  1650. const qty = all_loot[loot];
  1651. if (tracked_loot.indexOf(loot)>=0) {
  1652. important_loot[loot] = qty;
  1653. }
  1654. }
  1655. }
  1656. }
  1657. console.log(important_loot);
  1658. if (Object.keys(important_loot).length > 0) {
  1659. cmd.push({"cmd":"reward","payload":important_loot});
  1660. cmd.push({"cmd":"log","level":"summary","msg":Object.keys(important_loot).length});
  1661. }
  1662.  
  1663. if (tracked_item !== false){
  1664. let data_track = my_profile+"Current Status:";
  1665. let temp_str;
  1666. for (let item in tracked_item){
  1667. if (tracked_item.hasOwnProperty(item)) {
  1668. let item_qty = parseInt(tracked_item[item].number);
  1669. let drop_qty = 0;
  1670. if (all_loot[tracked_item[item].name] !== undefined) {
  1671. drop_qty = all_loot[tracked_item[item].name];
  1672. }
  1673. temp_str = "\n- "+tracked_item[item].name+": "+(item_qty + drop_qty).toString();
  1674. if (all_loot[tracked_item[item].name] !== undefined) {
  1675. temp_str += ' ( +'+(drop_qty).toString()+' )';
  1676. }
  1677. data_track += temp_str;
  1678. }
  1679. }
  1680. cmd.push({"cmd":"log","level":"summary","msg":data_track,"split":0});
  1681. }
  1682. if (check_timer){
  1683. cmd.push({"cmd":"check_timer"});
  1684. }
  1685. xhr.open('POST', server);
  1686. xhr.send(JSON.stringify(cmd));
  1687. let gotoMain = function() {gotoHash("main");};
  1688. checkEl(".mask",0,gotoMain);
  1689. }
  1690.  
  1691. function quitTrial(){
  1692. let doit3 = function(){clickEl(".btn-usual-ok",0,message.raid.trial.ok);};
  1693. let doit2 = function(){clickEl(".btn-withdrow.btn-red-m",0,message.raid.trial.retreat,doit3);};
  1694. let doit1 = function(){clickEl(".btn-raid-menu.menu",0,message.raid.trial.open_menu,doit2);};
  1695. clickAndNegCheck(query.battle_ui.trial_pop_up.close,0,message.raid.trial.close_pop_up,doit1);
  1696. }
  1697.  
  1698. function missionComplete(cmd=[]) {
  1699. clearInterval(reload_counter);
  1700. // let cmd = [];
  1701. cmd.push({"cmd":"log","level":"notif","msg":my_profile+"Objective cleared. Mission complete. "+discord_mention});
  1702. cmd.push({"cmd":"log","level":"summary","msg":my_profile+"Objective cleared. Mission complete."});
  1703. cmd.push({"cmd":"hotkey","keys":["ctrl","w"]});
  1704. xhr.open('POST', server);
  1705. xhr.send(JSON.stringify(cmd));
  1706. }
  1707.  
  1708. function init() {
  1709. "use strict";
  1710. console.log(init.name);
  1711. reload(5);
  1712. setDebug();
  1713. listenNetwork();
  1714. let checkBody = setInterval(function() {
  1715. console.log(checkBody.name);
  1716. if(document.body !== null){
  1717. clearInterval(checkBody);
  1718. if(document.body.children[0].tagName == "DIV"){
  1719. // reload(30);
  1720. checkError();
  1721. }else{
  1722. console.log("DOM Error");
  1723. reloadNow();
  1724. }
  1725. }
  1726. }, 300);
  1727. }