NEET Lib

NEET Bot Library

目前为 2019-07-21 提交的版本。查看 最新版本

此脚本不应直接安装,它是一个供其他脚本使用的外部库。如果您需要使用该库,请在脚本元属性加入:// @require https://update.cn-greasyfork.org/scripts/383201/718616/NEET%20Lib.js

  1. // ==UserScript==
  2. // @name NEET Lib
  3. // @namespace http://tampermonkey.net/
  4. // @version 5.11
  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. // environment info
  15. const xhr = new XMLHttpRequest(),
  16. server = "http://localhost:2487",
  17. margin = {"top":91,"left":0},
  18. game_url = "http://game.granbluefantasy.jp/";
  19.  
  20. let debug = true,
  21. reload_counter;
  22.  
  23. let my_profile = "Main: ";
  24. let is_host = "false";
  25. let battle;
  26. let battle_status;
  27.  
  28. let quests_id = [], monsters = [], monsters_name = [];
  29.  
  30. // const game variable
  31. const trial_id = "990011",
  32. select_summon_path = "supporter/",
  33. message = {
  34. "raid" : {
  35. "panel" : {
  36. "open" : my_profile+"Opening quest/raid panel",
  37. "pick" : my_profile+"Picking quest/raid difficulties",
  38. },
  39. "select_party" : my_profile+"Selecting party",
  40. "finish" : my_profile+"Raid finished",
  41. "trial" : {
  42. "close_pop_up" : my_profile+"In trial, closing pop up",
  43. "open_menu" : my_profile+ "In trial, click menu",
  44. "retreat" : my_profile+ "In trial, click retreat",
  45. "ok" : my_profile+ "In trial, click ok",
  46. "end" : my_profile+"Retreated from trial, back to main raid",
  47. }
  48. },
  49. "summon" : {
  50. "select" : my_profile+"Selecting summon",
  51. "pick_tab" : my_profile+"Clicking summon element tab",
  52. "not_found" : my_profile+"Support summon not found, going to trial",
  53. },
  54. "replenish" : {
  55. "elixir" : {
  56. "half_elixir" : {
  57. "use" : my_profile+"Not enough AP, using half elixir",
  58. "used" : my_profile+"Half elixir used",
  59. }
  60. },
  61. "soul" : {
  62. "soul_berry" : {
  63. "use" : my_profile+"Not enough EP, using soul berry",
  64. "used" : my_profile+"soul berry used",
  65. }
  66. }
  67. },
  68. "ok" : my_profile+"Clicking ok",
  69. };
  70.  
  71. // path
  72. let path = {
  73. "item":"#item",
  74. "quest":"#quest",
  75. "support":"#quest/supporter/",
  76. "assist":"#quest/assist",
  77. "unclaimed":"#quest/assist/unclaimed",
  78. "trial":"#quest/supporter/"+trial_id+"/17",
  79. };
  80.  
  81. // element dom query selector
  82. let skill_char = "#prt-command-top > div > div > div.lis-character";
  83. let skill_abi = ".btn-command-character > div.prt-ability-state > div.lis-ability-state.ability";
  84. let query = {
  85. "battle_ui": {
  86. "skill": {
  87. "char1": {
  88. "skill1": skill_char + "0" + skill_abi + "1",
  89. "skill2": skill_char + "0" + skill_abi + "2",
  90. "skill3": skill_char + "0" + skill_abi + "3",
  91. "skill4": skill_char + "0" + skill_abi + "4",
  92. },
  93. "char2": {
  94. "skill1": skill_char + "1" + skill_abi + "1",
  95. "skill2": skill_char + "1" + skill_abi + "2",
  96. "skill3": skill_char + "1" + skill_abi + "3",
  97. "skill4": skill_char + "1" + skill_abi + "4",
  98. },
  99. "char3": {
  100. "skill1": skill_char + "2" + skill_abi + "1",
  101. "skill2": skill_char + "2" + skill_abi + "2",
  102. "skill3": skill_char + "2" + skill_abi + "3",
  103. "skill4": skill_char + "2" + skill_abi + "4",
  104. },
  105. "char4": {
  106. "skill1": skill_char + "3" + skill_abi + "1",
  107. "skill2": skill_char + "3" + skill_abi + "2",
  108. "skill3": skill_char + "3" + skill_abi + "3",
  109. "skill4": skill_char + "3" + skill_abi + "4",
  110. },
  111. },
  112. "skill_pop_up": {
  113. "char1": "div.pop-usual.pop-select-member > div.prt-popup-body > div.prt-wrapper > div.prt-character > div.lis-character0.btn-command-character > img",
  114. "char2": "div.pop-usual.pop-select-member > div.prt-popup-body > div.prt-wrapper > div.prt-character > div.lis-character1.btn-command-character > img",
  115. "char3": "div.pop-usual.pop-select-member > div.prt-popup-body > div.prt-wrapper > div.prt-character > div.lis-character2.btn-command-character > img",
  116. "char4": "div.pop-usual.pop-select-member > div.prt-popup-body > div.prt-wrapper > div.prt-character > div.lis-character3.btn-command-character > img",
  117. "char5": "div.pop-usual.pop-select-member > div.prt-popup-body > div.prt-wrapper > div.prt-character > div.lis-character4.btn-command-character > img",
  118. "char6": "div.pop-usual.pop-select-member > div.prt-popup-body > div.prt-wrapper > div.prt-character > div.lis-character5.btn-command-character > img",
  119. },
  120. // "#prt-command-top > div > div > div.lis-character3.btn-command-character > div.prt-ability-state > div.lis-ability-state.ability3",
  121. "ougi": ".btn-lock",
  122. "toggle_ougi": {
  123. true: ".lock0",
  124. false: ".lock1",
  125. },
  126. "char_ico": ".prt-party>.prt-member>.btn-command-character>img.img-chara-command",
  127. "summon_panel": ".prt-summon-list>.prt-list-top.btn-command-summon",
  128. "chat":".btn-chat.comment.display-on",
  129. "chat_pop_up": {
  130. "dialog":".txt-chat-pop",
  131. },
  132. "heal":"#prt-sub-command-group>.btn-temporary",
  133. "heal_pop_up": {
  134. "green": ".lis-item.item-small",
  135. "blue": ".lis-item.item-large",
  136. "use": ".pop-usual.pop-raid-item.pop-show>.prt-popup-footer>.btn-usual-use",
  137. "cancel": ".pop-usual.pop-raid-item.pop-show>.prt-popup-footer>.btn-usual-cancel",
  138. },
  139. "trial_pop_up": {
  140. "close": ".pop-usual.pop-trialbattle-notice.pop-show>.prt-popup-footer>.btn-usual-close"
  141. },
  142. },
  143. "assist_ui": {
  144. "tab_id": "#tab-id",
  145. "tab_multi": "#tab-multi",
  146. "tab_event": "#tab-event",
  147. "unclaimed": ".btn-unclaimed",
  148. },
  149. "poker": {
  150. "canvas": "#canv",
  151. "deal": ".prt-start",
  152. "ok": ".prt-ok",
  153. "yes": ".prt-yes",
  154. "no": ".prt-no",
  155. "low": ".prt-double-select>.prt-low-shine",
  156. "high": ".prt-double-select>.prt-high-shine",
  157. },
  158. "ok":".btn-usual-ok",
  159. };
  160.  
  161. // general item variable
  162. let tracked_item = false;
  163.  
  164. function reloadNow() {
  165. console.log(reloadNow.name);
  166. xhr.open('POST', server);
  167. xhr.send(JSON.stringify([{"cmd":"press","key":"f5"}]));
  168. window.location.reload();
  169. }
  170.  
  171. function reload(mod_value=1) {
  172. clearInterval(reload_counter);
  173. let current_path = window.location.hash;
  174. let count = 1;
  175. reload_counter = setInterval(function() {
  176. if(window.location.hash != current_path){
  177. clearInterval(reload_counter);
  178. }
  179. console.log("reloading in "+(mod_value-count).toString());
  180. if (count%mod_value===0){
  181. clearInterval(reload_counter);
  182. reloadNow();
  183. }
  184. count += 1;
  185. }, 1000);
  186. }
  187.  
  188. function setDebug() {
  189. if(!debug){
  190. console.log("DEBUG is turned OFF");
  191. if(!window.console) window.console = {};
  192. let methods = ["log", "debug", "warn", "info"];
  193. for(let i=0;i<methods.length;i++){
  194. console[methods[i]] = function(){};
  195. }
  196. }
  197. }
  198.  
  199. function readBody(xhr) {
  200. let data;
  201. if (!xhr.responseType || xhr.responseType === "text") {
  202. data = xhr.responseText;
  203. } else if (xhr.responseType === "document") {
  204. data = xhr.responseXML;
  205. } else {
  206. data = xhr.response;
  207. }
  208. return data;
  209. }
  210.  
  211. function gotoHash(key){
  212. let hash_path;
  213. if (path[key] !== undefined) {
  214. hash_path = path[key];
  215. }else{
  216. if (key.indexOf("#")!==0) {
  217. hash_path = "#"+key;
  218. }
  219. }
  220. window.location.href = game_url + hash_path;
  221. }
  222.  
  223. function scrollTo(query,qid=0) {
  224. document.querySelectorAll(query)[qid].scrollIntoViewIfNeeded();
  225. }
  226.  
  227. function checkExist(query,qid=0) {
  228. let el_exist = false;
  229. if (document.querySelectorAll(query).length > qid){
  230. if (document.querySelectorAll(query)[qid].getBoundingClientRect().width > 0 && document.querySelectorAll(query)[qid].getBoundingClientRect().height > 0) {
  231. el_exist = true;
  232. }
  233. }
  234. return el_exist;
  235. }
  236.  
  237. function checkEl(query,qid=0,callback=false) {
  238. let old_top = -1;
  239. let old_left = -1;
  240. let loop_checkEl = setInterval(function() {
  241. console.log(checkEl.name + " " + query + "[" + qid + "]");
  242. if (checkExist(query,qid)) {
  243. if (old_top==document.querySelectorAll(query)[qid].getBoundingClientRect().top && old_left==document.querySelectorAll(query)[qid].getBoundingClientRect().left) {
  244. clearInterval(loop_checkEl);
  245. if (typeof callback == "function") {
  246. callback();
  247. }
  248. }else{
  249. old_top = document.querySelectorAll(query)[qid].getBoundingClientRect().top;
  250. old_left = document.querySelectorAll(query)[qid].getBoundingClientRect().left;
  251. }
  252. }
  253. }, 200);
  254. }
  255.  
  256. function checkEls(queries,callback=false) {
  257. let exist_result;
  258. let loop_checkEls = setInterval(function() {
  259. exist_result = [];
  260. for (let i in queries) {
  261. console.log(checkEls.name + " " + queries[i].query + "[" + queries[i].qid + "]");
  262. exist_result.push(checkExist(queries[i].query,queries[i].qid));
  263. }
  264. if (exist_result.indexOf(false)===-1) {
  265. clearInterval(loop_checkEls);
  266. if (typeof callback == "function") {
  267. callback();
  268. }
  269. }
  270. }, 300);
  271. }
  272.  
  273. function checkError() {
  274. let q_cnt_error = ".cnt-error";
  275. let q_pop_up = ".pop-usual.common-pop-error.pop-show";
  276. let check_error = setInterval(function() {
  277. let func_name = checkError.name;
  278. if (checkExist(q_pop_up,0) || checkExist(q_cnt_error,0)) {
  279. let cmd = [];
  280. console.log("error_found");
  281. let do_reload = false;
  282. let level = "notif";
  283. let msg = "Uncatagorized error found";
  284. // let msg = "Connection error, refreshing disabled"
  285. if (checkExist(q_pop_up+">.prt-popup-header",0)) {
  286. if (document.querySelector(q_pop_up+">.prt-popup-header").innerHTML=="Access Verification") {
  287. clearInterval(reload_counter);
  288. msg = my_profile+"Captcha detected";
  289. console.log("Captcha detected");
  290. }else if (document.querySelector(q_pop_up+">.prt-popup-header").innerHTML=="エラー") {
  291. if (checkExist(q_pop_up+">.prt-popup-body>.txt-popup-body>div",0)) {
  292. if (typeof document.querySelector(q_pop_up+">.prt-popup-body>.txt-popup-body>div").innerHTML == "string") {
  293. if (document.querySelector(q_pop_up+">.prt-popup-body>.txt-popup-body>div").innerHTML.indexOf("Network Error")>=0) {
  294. clearInterval(reload_counter);
  295. console.log("Error connection");
  296. do_reload = true;
  297. msg = my_profile+"Error connection, reloading";
  298. level = "process";
  299. }
  300. }
  301. }
  302. }
  303. }
  304. if (checkExist(q_pop_up+">.prt-popup-body>.txt-popup-body",0)) {
  305. if (document.querySelector(q_pop_up+">.prt-popup-body>.txt-popup-body").innerHTML=="Check your pending battles.") {
  306. console.log("check raid");
  307. level = "process";
  308. msg = my_profile+"Check your pending battle";
  309. clickEl(".prt-popup-footer>.btn-usual-ok",0,my_profile+"Clicking ok pop up pending battles");
  310. }
  311. }
  312. if (do_reload){
  313. cmd.push({"cmd":"press","key":"f5"});
  314. }
  315. cmd.push({"cmd":"log","level":level,"msg":msg});
  316. xhr.open('POST', server);
  317. xhr.send(JSON.stringify(cmd));
  318. if (do_reload){
  319. window.location.reload();
  320. }
  321. }
  322. }, 5000);
  323. }
  324.  
  325. function getCoord(el){
  326. let x, y, output;
  327. el = el.getBoundingClientRect();
  328. if (el.width>0 && el.height>0) {
  329. x = (el.width / 2) + el.left;
  330. y = (el.height / 2) + el.top;
  331. if(el.width>40){
  332. x += Math.floor(Math.random() * 41)-20;
  333. }else if(el.width>20){
  334. x += Math.floor(Math.random() * 21)-10;
  335. }else if(el.width>10){
  336. x += Math.floor(Math.random() * 11)-5;
  337. }
  338. if(el.height>10){
  339. y += Math.floor(Math.random() * 11)-5;
  340. }
  341. output = [x+margin.left,y+margin.top];
  342. }else{
  343. output = 0;
  344. }
  345. return output;
  346. }
  347.  
  348. function getMarginCoord(query,qid){
  349. let el = document.querySelectorAll(query)[qid].getBoundingClientRect();
  350. return {"top":el.top+margin.top,"left":el.left+margin.left};
  351. }
  352.  
  353. function clickNow(query,qid=0,msg=my_profile+"clickNow called",callback=false){
  354. let el = document.querySelectorAll(query)[qid];
  355. let output = false;
  356. if (checkExist(query,qid)) {
  357. output = true;
  358. let cmd = [];
  359. cmd.push({"cmd":"clickIt","param":getCoord(el)});
  360. cmd.push({"cmd":"log","level":"process","msg":msg});
  361. xhr.open("POST", server);
  362. xhr.send(JSON.stringify(cmd));
  363. if (typeof callback == "function") {
  364. callback();
  365. }
  366. }
  367. return output;
  368. }
  369.  
  370. function clickEl(query,qid=0,msg=my_profile+"clickEl called",callback=false){
  371. let init_clickEl = function() {
  372. clickNow(query,qid,msg,callback);
  373. };
  374. checkEl(query,qid,init_clickEl);
  375. }
  376.  
  377. function clickObject(obj){
  378. if (obj == "ok"){
  379. clickEl(".btn-usual-ok",0,message.ok);
  380. }
  381. }
  382.  
  383. function clickAndNegCheck(query,qid=0,msg="clickAndNegCheck called",callback=false,ticks=5){
  384. let old_href = window.location.href;
  385. let old_top = -1;
  386. let old_left = -1;
  387. let match = ticks-1;
  388. let str_clickAndNegCheck = clickAndNegCheck.name + ", el: " + query + "["+(qid.toString())+"] \n- match = ";
  389. let init_clickAndNegCheck = function() {
  390. let loop_clickAndNegCheck = setInterval(function() {
  391. console.log(str_clickAndNegCheck+(match.toString()));
  392. if (!(checkExist(query,qid))) {
  393. clearInterval(loop_clickAndNegCheck);
  394. if (typeof callback == "function") {
  395. callback();
  396. }
  397. }else if (old_href != window.location.href) {
  398. clearInterval(loop_clickAndNegCheck);
  399. }else{
  400. if (checkExist(query,qid)) {
  401. if (old_top==document.querySelectorAll(query)[qid].getBoundingClientRect().top && old_left==document.querySelectorAll(query)[qid].getBoundingClientRect().left) {
  402. if (match % ticks == 0) {
  403. clickNow(query,qid,msg);
  404. }
  405. match += 1;
  406. }else{
  407. old_top = document.querySelectorAll(query)[qid].getBoundingClientRect().top;
  408. old_left = document.querySelectorAll(query)[qid].getBoundingClientRect().left;
  409. }
  410. }
  411. }
  412. }, 100);
  413. };
  414. checkEl(query,qid,init_clickAndNegCheck);
  415. }
  416.  
  417. function clickAndCheck(query1,qid1=0,query2,qid2=0,msg="clickAndCheck called",callback=false,ticks=5){
  418. let old_href = window.location.href;
  419. let old_top = -1;
  420. let old_left = -1;
  421. let match = ticks-1;
  422. let str_clickAndCheck = clickAndCheck.name + ", check: " + query2 + "["+(qid2.toString())+"], click: " + query1 + "["+(qid1.toString())+"] \n- match = ";
  423. let loop_clickAndCheck = setInterval(function() {
  424. console.log(str_clickAndCheck+(match.toString()));
  425. if (checkExist(query2,qid2)) {
  426. clearInterval(loop_clickAndCheck);
  427. if (typeof callback == "function") {
  428. callback();
  429. }
  430. }else if (old_href != window.location.href) {
  431. clearInterval(loop_clickAndCheck);
  432. }else{
  433. if (checkExist(query1,qid1)) {
  434. if (old_top==document.querySelectorAll(query1)[qid1].getBoundingClientRect().top && old_left==document.querySelectorAll(query1)[qid1].getBoundingClientRect().left) {
  435. if (match % ticks == 0) {
  436. clickNow(query1,qid1,msg);
  437. }
  438. match += 1;
  439. }else{
  440. old_top = document.querySelectorAll(query1)[qid1].getBoundingClientRect().top;
  441. old_left = document.querySelectorAll(query1)[qid1].getBoundingClientRect().left;
  442. }
  443. }
  444. }
  445. }, 100);
  446. }
  447.  
  448. function popUpNotEnough(rep) {
  449. const query = ".btn-use-full.index-1",
  450. qid = 0,
  451. msg = message.replenish.elixir.half_elixir.use;
  452. let cmd = [], coordinate, consumable_data;
  453. consumable_data = my_profile+"Consumable Status:";
  454. for (let i = 0; i < rep.length; i++) {
  455. consumable_data += ("\n- "+rep[i].name+": "+rep[i].number);
  456. }
  457. let init_popUpNotEnough = function() {
  458. coordinate = getCoord(document.querySelectorAll(query)[qid]);
  459. if (coordinate!==0){
  460. cmd.push({"cmd":"clickIt","param":coordinate});
  461. cmd.push({"cmd":"log","level":"process","msg":msg});
  462. cmd.push({"cmd":"log","level":"summary","msg":consumable_data,"split":0});
  463. xhr.open('POST', server);
  464. xhr.send(JSON.stringify(cmd));
  465. }
  466. };
  467. checkEl(query,qid,init_popUpNotEnough);
  468.  
  469. }
  470.  
  471. function clickAndCheckSkill(query,qid=0,msg="clickAndCheckSkill called",callback=false,special_case=false){
  472. let old_class = document.querySelectorAll(query)[qid].parentNode.classList[0];
  473. let loop_clickAndCheckSkill = setInterval(function() {
  474. console.log(checkEl.name + " " + query + "[" + qid + "]");
  475. 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){
  476. clearInterval(loop_clickAndCheckSkill);
  477. console.log(clickAndCheckSkill.name + " case normal");
  478. if (typeof callback == "function") {
  479. callback();
  480. }
  481. // Bea skill
  482. }else if(special_case===1 && document.querySelectorAll(query)[qid].parentNode.classList[0] != old_class){
  483. clearInterval(loop_clickAndCheckSkill);
  484. console.log(clickAndCheckSkill.name + " case " + special_case.toString());
  485. if (typeof callback == "function") {
  486. callback();
  487. }
  488. // Out of sight & sage of eternity
  489. }else if(special_case===2){
  490. let do_click = true;
  491. console.log(clickAndCheckSkill.name + " case " + special_case.toString());
  492. let popup_query = "#wrapper > div.contents > div.pop-usual.pop-select-member > div.prt-popup-header";
  493. if (checkExist(popup_query,0)) {
  494. if (document.querySelector("#wrapper > div.contents > div.pop-usual.pop-select-member > div.prt-popup-header").innerHTML == "Use Skill"){
  495. clearInterval(loop_clickAndCheckSkill);
  496. do_click = false;
  497. if (typeof callback == "function") {
  498. callback();
  499. }
  500. }
  501. }
  502. if (do_click) {
  503. if (checkExist(query,qid)) {
  504. clickNow(query,qid,msg);
  505. }
  506. }
  507. }else{
  508. if (checkExist(query,qid)) {
  509. clickNow(query,qid,msg);
  510. }
  511. }
  512.  
  513. }, 500);
  514. }
  515.  
  516. function getCharStr(char_id){
  517. let char;
  518. if (char_id==1){
  519. char = "MC";
  520. }else{
  521. char = "NPC"+((char_id-1).toString());
  522. }
  523. return char;
  524. }
  525.  
  526. function useSkill(char_id,abi_id,callback=false,special_case=false){
  527. console.log(useSkill.name + ", char: "+char_id+", ability: " + (abi_id.toString()) + ", case: "+special_case);
  528. let char = getCharStr(char_id);
  529. abi_id = parseInt(abi_id)-1;
  530. // console.log("lol");
  531. console.log(".prt-command-chara.chara"+(char_id.toString())+">div>div.lis-ability");
  532. 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){
  533. 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()),callback,special_case);
  534. }else{
  535. if (typeof callback == "function") {
  536. callback();
  537. }
  538. }
  539. }
  540.  
  541. function clickBack(callback=false){
  542. clickAndCheck(".btn-command-back.display-on",0,"div.prt-member",0,my_profile+"Clicking back",callback,10);
  543. }
  544.  
  545. function clickSummonPanel(callback=false){
  546. let query1 = ".prt-list-top.btn-command-summon.summon-on";
  547. let query2 = ".prt-summon-list.opened";
  548. let query3 = ".prt-list-top.btn-command-summon.summon-off";
  549. let qid1 = 0, qid2 = 0, qid3 = 0;
  550. let msg = my_profile+"Clicking summon panel";
  551. let old_top = -1;
  552. let old_left = -1;
  553. let loop_clickAndCheck = setInterval(function() {
  554. console.log(clickAndCheck.name + ", check: " + query2 + "["+(qid2.toString())+"], click: " + query1 + "["+(qid1.toString())+"]");
  555. if (checkExist(query2,qid2) || checkExist(query3,qid3)) {
  556. clearInterval(loop_clickAndCheck);
  557. if (typeof callback == "function") {
  558. callback();
  559. }
  560. }else{
  561. if (checkExist(query1,qid1)) {
  562. if (old_top==document.querySelectorAll(query1)[qid1].getBoundingClientRect().top && old_left==document.querySelectorAll(query1)[qid1].getBoundingClientRect().left) {
  563. clickNow(query1,qid1,msg);
  564. }else{
  565. old_top = document.querySelectorAll(query1)[qid1].getBoundingClientRect().top;
  566. old_left = document.querySelectorAll(query1)[qid1].getBoundingClientRect().left;
  567. }
  568. }
  569. }
  570. }, 200);
  571. // clickAndCheck(,0,,0,);
  572. }
  573.  
  574. function clickSummon(summon_id,callback1=false,callback2=false){
  575. summon_id = summon_id-1;
  576. if (Array.from(document.querySelectorAll(".lis-summon")[summon_id].classList).indexOf("btn-summon-available")>=0){
  577. let loop_clickSummon = setInterval(function() {
  578. if (document.querySelectorAll(".lis-summon>img")[summon_id].getBoundingClientRect().x=== 72 + (summon_id * 51)){
  579. clearInterval(loop_clickSummon);
  580. 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);
  581. }
  582. }, 300);
  583. }else{
  584. if (typeof callback2 == "function") {
  585. callback2();
  586. }
  587. }
  588. }
  589.  
  590. function clickOkSummon(callback=false){
  591. let el_ok = ".pop-usual.pop-summon-detail>div>.btn-usual-ok.btn-summon-use";
  592. if (document.querySelector(el_ok) !== null){
  593. clickAndCheck(el_ok,0,"div.prt-member",0,my_profile+"Clicking summon ok",callback);
  594. }else{
  595. if (typeof callback == "function") {
  596. callback();
  597. }
  598. }
  599. }
  600. function clickOkSummon2(summon_id,callback=false){
  601. let el_ok = ".pop-usual.pop-summon-detail>div>.btn-usual-ok.btn-summon-use";
  602. let summon_el = '.lis-summon[pos="'+(summon_id.toString())+'"]';
  603. if (document.querySelector(el_ok) !== null){
  604. let loop_clickOkSummon2 = setInterval(function() {
  605. console.log(clickOkSummon2.name + ", click: " + el_ok + "[0]");
  606. if (Array.from(document.querySelector(summon_el).classList).indexOf("tmp-mask")>=0 || Array.from(document.querySelector(summon_el).classList).indexOf("btn-summon-unavailable")>=0) {
  607. clearInterval(loop_clickOkSummon2);
  608. if (typeof callback == "function") {
  609. callback();
  610. }
  611. }else{
  612. if (checkExist(el_ok,0)) {
  613. clickNow(el_ok,0,my_profile+"Clicking summon ok2");
  614. }
  615. }
  616. }, 1000);
  617. }else{
  618. if (typeof callback == "function") {
  619. callback();
  620. }
  621. }
  622. }
  623.  
  624. function selectSummon(preferred_summon,is_trial=false){
  625. reload(20);
  626.  
  627. let init_selectSummon = function() {
  628. console.log(init_selectSummon.name);
  629. reload(10);
  630. const attrib_list = [6,0,1,2,3,4,5];
  631. let query_summon_list = ".btn-supporter.lis-supporter";
  632. let el_summon_list = document.querySelectorAll(query_summon_list);
  633. let preferred_summon_id = false;
  634. let picked_attrib_id = false;
  635. let picked_summon_id = false;
  636. let picked_is_friend = false;
  637. let is_friend;
  638. let picked_summon_stars = false;
  639. let picked_summon_level = false;
  640. let picked_summon_plus = false;
  641. let msg;
  642. let cmd = [], summon_list = {};
  643. 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){
  644. msg = my_profile+"Verify not appear, summon list length is "+(el_summon_list.length.toString());
  645. console.log(msg);
  646.  
  647. // check if raid is trial
  648. if (!is_trial){
  649. console.log("not trial");
  650. for (let i = 0; i < el_summon_list.length; i++) {
  651. let match_preferred = false, replace = false;
  652. let temp_var, summon_detail, summon_name, summon_level, summon_stars, summon_plus;
  653. temp_var = el_summon_list[i].querySelector(".prt-supporter-summon");
  654. summon_detail = temp_var.innerHTML.trim();
  655. temp_var = el_summon_list[i].querySelector(".prt-supporter-summon");
  656. summon_detail = temp_var.innerHTML.trim();
  657. summon_name = summon_detail.substring(summon_detail.indexOf("</span>")+8,summon_detail.length);
  658. summon_level = parseInt(temp_var.children[0].innerHTML.replace("Lvl ",""));
  659. temp_var = Array.from(el_summon_list[i].querySelector(".prt-summon-skill").classList);
  660. if (temp_var.indexOf("bless-rank3-style")>=0){
  661. summon_stars = 5;
  662. }else if (temp_var.indexOf("bless-rank2-style")>=0){
  663. summon_stars = 4;
  664. }else if (temp_var.indexOf("bless-rank1-style")>=0){
  665. summon_stars = 3;
  666. }else{
  667. summon_stars = 0;
  668. }
  669. temp_var = el_summon_list[i].querySelector(".prt-summon-quality");
  670. if (temp_var !== null){
  671. summon_plus = parseInt(temp_var.innerHTML.replace("+",""));
  672. }else{
  673. summon_plus = 0;
  674. }
  675. temp_var = false;
  676. is_friend = Array.from(el_summon_list[i].querySelector(".prt-supporter-name").classList).indexOf("ico-friend")>=0;
  677.  
  678. // console.log([summon_name,summon_level,summon_stars,summon_plus,is_friend]);
  679.  
  680. // loop preferred summon list (specified in parameter)
  681. for (let j = 0; j < preferred_summon.length; j++) {
  682. if (preferred_summon[j][0]==summon_name && preferred_summon[j][1]<=summon_stars){
  683. match_preferred = true;
  684. temp_var = j;
  685. }
  686. }
  687.  
  688.  
  689. if (match_preferred){
  690. if (picked_attrib_id===false && picked_summon_id===false){
  691. replace = true;
  692. }else{
  693. if (preferred_summon_id>temp_var){
  694. replace = true;
  695. }else if(preferred_summon_id==temp_var){
  696. if (summon_stars>picked_summon_stars){
  697. replace = true;
  698. }else if(summon_stars==picked_summon_stars){
  699. if (!picked_is_friend && is_friend){
  700. replace = true;
  701. }else if(picked_is_friend && is_friend){
  702. if (summon_level>picked_summon_level){
  703. replace = true;
  704. }else if(summon_level==picked_summon_level){
  705. if (summon_plus>picked_summon_plus){
  706. replace = true;
  707. }
  708. }
  709. }
  710. }
  711. }
  712. }
  713. }
  714. if (replace){
  715. picked_attrib_id = Array.from(document.querySelectorAll(".prt-supporter-attribute")).indexOf(el_summon_list[i].parentElement);
  716. picked_summon_id = i;
  717. preferred_summon_id = temp_var;
  718. picked_summon_stars = summon_stars;
  719. picked_is_friend = is_friend;
  720. picked_summon_level = summon_level;
  721. picked_summon_plus = summon_plus;
  722. }
  723. }
  724. console.log([picked_attrib_id,picked_summon_id,preferred_summon_id]);
  725. if (picked_summon_id===false){
  726. console.log("go to trial");
  727. cmd.push({"cmd":"log","level":"process","msg":message.summon.not_found});
  728. xhr.open("POST", server);
  729. xhr.send(JSON.stringify(cmd));
  730. gotoHash("trial");
  731. }else{
  732. console.log("summon_found");
  733. let pickSummon = function() {
  734. scrollTo(query_summon_list,picked_summon_id);
  735. clickEl(query_summon_list,picked_summon_id,message.summon.select);
  736. };
  737. let clickAndCheckSummon = function(callback=false){
  738. let el_tab_ele_ico = ".prt-type-text";
  739. let el_summon_container = ".prt-supporter-attribute";
  740. let loop_clickAndCheckSummon = setInterval(function() {
  741. console.log(clickAndCheckSummon.name + ", check: " + el_summon_container + "[" + picked_attrib_id + "], click: " + el_tab_ele_ico + "["+(attrib_list[picked_attrib_id].toString())+"]");
  742. if (Array.from(document.querySelectorAll(el_summon_container)[picked_attrib_id].classList).indexOf("disableView") == -1) {
  743. clearInterval(loop_clickAndCheckSummon);
  744. if (typeof callback == "function") {
  745. callback();
  746. }
  747. }else{
  748. if (checkExist(el_tab_ele_ico, attrib_list[picked_attrib_id])) {
  749. clickNow(el_tab_ele_ico, attrib_list[picked_attrib_id], message.summon.pick_tab);
  750. }
  751. }
  752. }, 300);
  753. };
  754. clickAndCheckSummon(pickSummon);
  755. }
  756. }else{
  757. console.log("is trial");
  758. query_summon_list = ".prt-supporter-attribute:not(.disableView)>.btn-supporter.lis-supporter";
  759. // clearInterval(reload_counter);
  760. el_summon_list = document.querySelectorAll(query_summon_list);
  761. // console.log(el_summon_list);
  762. for (let i = 0; i < el_summon_list.length; i++) {
  763. is_friend = Array.from(el_summon_list[i].querySelector(".prt-supporter-name").classList).indexOf("ico-friend")>=0;
  764. if (!is_friend){
  765. if (picked_summon_id===false){
  766. picked_summon_id = i;
  767. }
  768. }
  769. }
  770. // console.log(picked_summon_id);
  771. if (picked_summon_id!==false){
  772. scrollTo(".prt-supporter-attribute:not(.disableView)>.btn-supporter.lis-supporter",picked_summon_id);
  773. clickEl(".prt-supporter-attribute:not(.disableView)>.btn-supporter.lis-supporter",picked_summon_id,message.summon.select);
  774. }
  775. }
  776. }else{
  777. msg = my_profile+"Verify might appear, summon list length is "+(el_summon_list.length.toString());
  778. clearInterval(reload_counter);
  779. console.log(msg);
  780. cmd.push({"cmd":"log","level":"process","msg":msg});
  781. cmd.push({"cmd":"log","level":"notif","msg":msg});
  782. xhr.open("POST", server);
  783. xhr.send(JSON.stringify(cmd));
  784. }
  785. };
  786. checkEl(".prt-supporter-title",0,init_selectSummon);
  787. }
  788.  
  789. function doChat(callback=false) {
  790. console.log(doChat.name);
  791. let clickDialog = function() {
  792. console.log(clickDialog.name);
  793. clickAndNegCheck(query.battle_ui.chat_pop_up.dialog,0,my_profile+"Clicking chat dialog",callback);
  794. };
  795. let clickChat = function() {
  796. console.log(clickChat.name);
  797. if (checkExist(query.battle_ui.chat+">.ico-attention",0)) {
  798. clickAndCheck(query.battle_ui.chat,0,query.battle_ui.chat_pop_up.dialog,0,my_profile+"Clicking chat pop up",clickDialog,20);
  799. }else{
  800. if (typeof callback == "function") {
  801. callback();
  802. }
  803. }
  804. };
  805. checkEl(query.battle_ui.chat,0,clickChat);
  806. }
  807.  
  808. function backFromTrial(){
  809. let cmd = [];
  810. cmd.push({"cmd":"log","level":"process","msg":message.raid.trial.end});
  811. xhr.open("POST", server);
  812. xhr.send(JSON.stringify(cmd));
  813. gotoHash("main");
  814. }
  815.  
  816. function gotoResult() {
  817. console.log(gotoResult.name);
  818. console.log(is_host);
  819. if (is_host || window.location.hash.indexOf("#raid/")>=0) {
  820. gotoHash("quest");
  821. }else if (window.location.hash.indexOf("#raid_multi")>=0) {
  822. reloadNow();
  823. }
  824. }
  825.  
  826. function attack(rep){
  827. console.log(attack.name);
  828. let cmd = [];
  829. let reps = rep.scenario;
  830. let win = false;
  831. let is_last_raid = false;
  832. let ougi = 0;
  833. let msg = "";
  834. let pos_player = ["MC","NPC1","NPC2","NPC3","NPC4","NPC5"];
  835. for (let i = 0; i < reps.length; i++) {
  836. if (reps[i].cmd =="win"){
  837. if (reps[i].is_last_raid){is_last_raid=true;}
  838. win=true;
  839. }else if (reps[i].cmd=="special" || reps[i].cmd=="special_npc"){
  840. msg += my_profile+pos_player[reps[i].pos]+" used ougi \""+reps[i].name+"\".\n";
  841. if (reps[i].total){msg += my_profile+pos_player[reps[i].pos]+" dealt "+reps[i].total[0].split.join("")+" damage.\n";}
  842. ougi++;
  843. }else if (reps[i].cmd=="attack" && reps[i].from=="player"){
  844. if (reps[i].damage.length==3){
  845. msg += my_profile+pos_player[reps[i].pos]+" made a triple attack.\n";
  846. }else if (reps[i].damage.length==2){
  847. msg += my_profile+pos_player[reps[i].pos]+" made a double attack.\n";
  848. }
  849. msg += my_profile+pos_player[reps[i].pos]+ " dealt ";
  850. for (let ii=0; ii<reps[i].damage.length; ii++){
  851. msg += reps[i].damage[ii][0].value.toString();
  852. if (ii<reps[i].damage.length-1){
  853. msg += ", ";
  854. }else{
  855. msg += " damage.\n";
  856. }
  857. }
  858. }
  859. }
  860.  
  861. if(win){
  862. cmd.push({"cmd":"log","level":"process","msg":msg+my_profile+"Foe defeated."});
  863. }else{
  864. cmd.push({"cmd":"log","level":"process","msg":msg+my_profile+"Foe is still alive."});
  865. cmd.push({"cmd":"press","key":"f5"});
  866. }
  867. xhr.open('POST', server);
  868. xhr.send(JSON.stringify(cmd));
  869. if(win && is_last_raid){
  870. gotoResult();
  871. }else if(win){
  872. clickEl(".btn-result",0,my_profile+"Go to next round");
  873. }
  874. }
  875.  
  876. function skillUsed(rep){
  877. console.log(skillUsed.name);
  878. let do_reload = false;
  879. let reps = rep.scenario;
  880. let win = false, is_last_raid = false;
  881. // win = false;
  882. // is_last_raid = false;
  883. console.log(reps);
  884. for (let i = 0; i < reps.length; i++) {
  885. const scenario = reps[i];
  886. if (scenario.cmd =="ability"){
  887. if (scenario.name == "Thunder Raid") {
  888. do_reload = true;
  889. }
  890. }else if (scenario.cmd =="damage") {
  891. if (scenario.to == "player") {
  892. for (let j = 0; j < scenario.list.length; j++) {
  893. const element = scenario.list[j];
  894. if (element.hp !== undefined && element.pos !== undefined) {
  895. battle_status.player.param[element.pos].hp = element.hp;
  896. }
  897. }
  898. }
  899. }else if (scenario.cmd =="finished"){
  900. win=true;
  901. is_last_raid=true;
  902. }else if (scenario.cmd == "win"){
  903. if (scenario.is_last_raid){is_last_raid=true;}
  904. win=true;
  905. }
  906. }
  907.  
  908. if(win && is_last_raid){
  909. gotoResult();
  910. }else if(do_reload){
  911. reloadNow();
  912. }
  913. }
  914.  
  915. function potUsed(rep) {
  916. console.log(potUsed.name);
  917. let reps = rep.scenario;
  918. for (let i = 0; i < reps.length; i++) {
  919. const scenario = reps[i];
  920. if (scenario.cmd == "heal") {
  921. for (let j = 0; j < scenario.list.length; j++) {
  922. const element = scenario.list[j];
  923. if (element.hp !== undefined && element.pos !== undefined) {
  924. battle_status.player.param[element.pos].hp = element.hp;
  925. }
  926. }
  927. }
  928. }
  929. }
  930.  
  931. function clickAttack(callback=false) {
  932. let hp = ((parseInt(battle.boss.param[0].hp) / parseInt(battle.boss.param[0].hpmax)) * 100).toString();
  933. if (hp.indexOf(".")>=0){
  934. hp = hp.substring(0,hp.indexOf("."));
  935. }
  936. console.log(hp);
  937. let attack_msg = my_profile+"Foe hp is "+hp+"% left, commencing attack";
  938. clickAndCheck(".btn-attack-start.display-on",0,".btn-attack-cancel.btn-cancel.display-on",0,attack_msg,callback,20);
  939. }
  940.  
  941. function startRaid(rep){
  942. reload(15);
  943. battle = rep;
  944. is_host = rep.is_host;
  945. player_status = rep.player.param;
  946. let toggleOugi = function(ougi,callback=false){
  947. let init_toggleOugi = function() {
  948. let current_ougi = "."+document.querySelector(query.battle_ui.ougi).classList[1];
  949. if (query.battle_ui.toggle_ougi[ougi] != current_ougi){
  950. 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);
  951. }else{
  952. if (typeof callback == "function") {
  953. callback();
  954. }
  955. }
  956. };
  957. checkEl(query.battle_ui.ougi,0,init_toggleOugi);
  958. };
  959. let usePot = function(pot_type,char_id=false,callback=false) {
  960. console.log(usePot.name);
  961. let is_front_healable = [];
  962. let is_player_reviveable = [];
  963. let is_player_healable = [];
  964. for (const i in player_status) {
  965. if (player_status.hasOwnProperty(i)) {
  966. if (player_status[i].alive === 1) {
  967. is_player_reviveable.push(false);
  968. is_player_healable.push(player_status[i].hpmax - player_status[i].hp !== 0);
  969. }else{
  970. is_player_reviveable.push(true);
  971. is_player_healable.push(false);
  972. }
  973. }
  974. }
  975. for (const i in rep.formation) {
  976. if (rep.formation.hasOwnProperty(i)) {
  977. const alive_id = parseInt(rep.formation[i]);
  978. is_front_healable.push(player_status[alive_id].hpmax - player_status[alive_id].hp !== 0);
  979. }
  980. }
  981. let query_qty = ">.txt-having>.having-num";
  982. let clickUse = function() {
  983. clickAndNegCheck(query.battle_ui.heal_pop_up.use,0,my_profile+"Clicking use from pot pop up",callback);
  984. };
  985. let clickFront = function() {
  986. 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);
  987. };
  988. let clickCancel = function() {
  989. clickAndNegCheck(query.battle_ui.heal_pop_up.cancel,0,my_profile+"Clicking cancel from pot pop up",callback);
  990. };
  991. let clickPot = function() {
  992. console.log(clickPot.name);
  993. if (checkExist(query.battle_ui.heal_pop_up[pot_type]+query_qty)) {
  994. if ( parseInt(document.querySelector(query.battle_ui.heal_pop_up[pot_type]+query_qty).innerHTML) > 0 ) {
  995. if (pot_type == "blue") {
  996. clickAndNegCheck(query.battle_ui.heal_pop_up[pot_type]+">img",0,my_profile+"Clicking "+ pot_type +" pot",clickUse);
  997. }else if (pot_type == "green") {
  998. clickAndNegCheck(query.battle_ui.heal_pop_up[pot_type]+">img",0,my_profile+"Clicking "+ pot_type +" pot",clickFront);
  999. }else{
  1000. console.log("pot_type unknown");
  1001. clickCancel();
  1002. }
  1003. }else{
  1004. console.log("pot qty not > 0");
  1005. clickCancel();
  1006. }
  1007. }else{
  1008. console.log("element not exist");
  1009. clickCancel();
  1010. }
  1011. };
  1012. let clickHeal = function() {
  1013. console.log(clickHeal.name);
  1014. clickAndCheck(query.battle_ui.heal,0,query.battle_ui.heal_pop_up[pot_type]+">img",0,my_profile+"Clicking heal pop up",clickPot,20);
  1015. };
  1016. let do_heal = false;
  1017. if (pot_type=="blue" && is_front_healable.indexOf(true)>=0) {
  1018. do_heal = true;
  1019. }else if (pot_type=="green" && is_player_healable[char_id]) {
  1020. do_heal = true;
  1021. }else{
  1022. if (typeof callback == "function") {
  1023. callback();
  1024. }
  1025. }
  1026. if (do_heal) {
  1027. checkEl(query.battle_ui.heal,0,clickHeal);
  1028. }
  1029. };
  1030.  
  1031. let check_exist = setInterval(function() {
  1032. console.log("querying enemy name to appear");
  1033. 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){
  1034. console.log("check width enemy name");
  1035. 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){
  1036. console.log("found enemy name");
  1037. clearInterval(check_exist);
  1038. let is_quest_id_valid = false;
  1039. let is_twitter_valid = false;
  1040. try{
  1041. console.log(rep.quest_id);
  1042. if (rep.quest_id!==undefined) {
  1043. is_quest_id_valid = true;
  1044. }
  1045. }
  1046. catch(err){
  1047. console.log(err.message);
  1048. }
  1049. console.log("is_quest_id_valid:" +(is_quest_id_valid).toString());
  1050. try{
  1051. console.log(rep.twitter.monster);
  1052. if (rep.twitter.monster!==undefined) {
  1053. is_twitter_valid = true;
  1054. }
  1055. }
  1056. catch(err){
  1057. console.log(err.message);
  1058. }
  1059. console.log("is_twitter_valid:" +(is_twitter_valid).toString());
  1060. let case_battle = false;
  1061. if (is_quest_id_valid){
  1062. if(rep.quest_id == trial_id){
  1063. case_battle = 99;
  1064. }else{
  1065. for (let i in quests_id) {
  1066. if (rep.quest_id == quests_id[i] && case_battle === false) {
  1067. case_battle = parseInt(i)+1;
  1068. }
  1069. }
  1070. }
  1071. }
  1072. if (case_battle === false && is_twitter_valid){
  1073. for (let i in monsters_name) {
  1074. if (rep.twitter.monster==monsters_name[i] && case_battle === false) {
  1075. case_battle = parseInt(i)+1;
  1076. }
  1077. }
  1078. }
  1079. console.log("case_battle:" + case_battle.toString());
  1080. let chara_id;
  1081. let clickChar = function(param,callback=false){
  1082. chara_id = param;
  1083. // click_n_check("div.prt-member>div.lis-character"+(param-1)+".btn-command-character:not(.invisible)>img.img-chara-command",0,"div.prt-member>div.lis-character"+(param-1)+".btn-command-character.invisible>img.img-chara-command",0,"clicking "+get_chara_str(param),callback)
  1084. clickAndCheck("div.prt-member>div.btn-command-character>img.img-chara-command",param-1,".prt-command-chara.chara"+(param.toString()),0,my_profile+"Clicking "+getCharStr(param),callback);
  1085. };
  1086. let hp = ((parseInt(rep.boss.param[0].hp) / parseInt(rep.boss.param[0].hpmax)) * 100).toString();
  1087. if (hp.indexOf(".")>=0){
  1088. hp = hp.substring(0,hp.indexOf("."));
  1089. }
  1090. // console.log(hp);
  1091. // let attack_msg = my_profile+"Foe hp is "+hp+"% left, commencing attack";
  1092. // let clickAttack = function(callback=false){
  1093. // // let init_recheckClickAttack = function(){
  1094. // // };
  1095. // clickAndCheck(".btn-attack-start.display-on",0,".btn-attack-cancel.btn-cancel.display-on",0,attack_msg,false,20);
  1096. // // clickEl(".btn-attack-start.display-on",0,attack_msg,init_recheckClickAttack);
  1097. // };
  1098.  
  1099. battleLogic(case_battle);
  1100.  
  1101. // if (case_battle === 99){
  1102. // if (rep.turn===1) {
  1103. // reload(20);
  1104. // let doit3 = function(){clickEl(".btn-usual-ok",0,message.raid.trial.ok);};
  1105. // let doit2 = function(){clickEl(".btn-withdrow.btn-red-m",0,message.raid.trial.retreat,doit3);};
  1106. // let doit1 = function(){clickEl(".btn-raid-menu.menu",0,message.raid.trial.open_menu,doit2);};
  1107. // clickAndNegCheck(query.battle_ui.trial_pop_up.close,0,message.raid.trial.close_pop_up,doit1);
  1108. // }
  1109. // }else{
  1110. // reload(30);
  1111.  
  1112. // // console.log(rep.quest_id==quests_id[2] || rep.twitter.monster==monsters_name[2]);
  1113. // if (case_battle === 1){
  1114. // if (rep.turn===1){
  1115. // reload(40);
  1116. // let char3_1;
  1117. // let auto_ougi = function(){toggleOugi(true,clickAttack);};
  1118. // let char2_b = function(){clickBack(auto_ougi);};
  1119. // let char2_2 = function(){useSkill(chara_id,2,char2_b);};
  1120. // let char2 = function(){clickChar(2,char2_2);};
  1121. // let char1_b = function(){clickBack(char2);};
  1122. // let char1_3 = function(){useSkill(chara_id,3,char1_b);};
  1123. // let char1_2 = function(){useSkill(chara_id,2,char1_3);};
  1124. // let char1 = function(){clickChar(1,char1_2);};
  1125. // let char3_b = function(){clickBack(char1);};
  1126. // let char3_2 = function(){useSkill(chara_id,2,char3_b);};
  1127. // let char3_3 = function(){useSkill(chara_id,3,char3_2);};
  1128. // if (rep.player.param[2].recast>=90) {
  1129. // char3_1 = function(){useSkill(chara_id,1,char3_2);};
  1130. // } else {
  1131. // char3_1 = function(){useSkill(chara_id,1,char3_3);};
  1132. // }
  1133. // let char3 = function(){clickChar(3,char3_1);};
  1134. // char3();
  1135. // }else{
  1136. // reload(15);
  1137. // clickAttack();
  1138. // }
  1139. // }else if (case_battle === 2) {
  1140. // if (rep.turn===1){
  1141. // reload(35);
  1142. // let char1_4;
  1143. // let char1_2;
  1144. // let auto_ougi = function(){toggleOugi(true,clickAttack);};
  1145. // // let char2_b = function(){clickBack(auto_ougi);};
  1146. // // let char2_1 = function(){useSkill(chara_id,1,char2_b);};
  1147. // // let char2 = function(){clickChar(2,char2_1);};
  1148. // let char1_b = function(){clickBack(auto_ougi);};
  1149. // let char1_3 = function(){useSkill(chara_id,3,char1_b);};
  1150. // // if (parseInt(ougi_bars[0].innerHTML)>=100){
  1151. // // char1_4 = function(){useSkill(chara_id,4,char1_b);};
  1152. // // }else{
  1153. // // char1_4 = function(){useSkill(chara_id,4,char1_3);};
  1154. // // }
  1155. // char1_4 = function(){useSkill(chara_id,4,char1_3);};
  1156. // char1_2 = function(){useSkill(chara_id,2,char1_4);};
  1157. // let char1 = function(){clickChar(1,char1_2);};
  1158. // let summon5_ok = function(){clickOkSummon(char1);};
  1159. // let summon5 = function(){clickSummon(5,summon5_ok,char1);};
  1160. // let summon5_p = function(){clickSummonPanel(summon5);};
  1161. // summon5_p();
  1162. // }else if (rep.turn===2) {
  1163. // reload(35);
  1164. // let auto_ougi = function(){toggleOugi(true,clickAttack);};
  1165. // let char3_b = function(){clickBack(auto_ougi);};
  1166. // let char3_1 = function(){useSkill(chara_id,1,char3_b);};
  1167. // let char3_2 = function(){useSkill(chara_id,2,char3_1);};
  1168. // let char3 = function(){clickChar(3,char3_2);};
  1169. // let char4_b = function(){clickBack(char3);};
  1170. // let char4_3 = function(){useSkill(chara_id,3,char4_b);};
  1171. // let char4_1 = function(){useSkill(chara_id,1,char4_3);};
  1172. // let char4 = function(){clickChar(4,char4_1);};
  1173. // let summon6_ok = function(){clickOkSummon(char4);};
  1174. // let summon6 = function(){clickSummon(6,summon6_ok,char4);};
  1175. // let summon6_p = function(){clickSummonPanel(summon6);};
  1176. // summon6_p();
  1177. // }else{
  1178. // reload(15);
  1179. // clickAttack();
  1180. // }
  1181. // }else if (case_battle === 3) {
  1182. // if (rep.turn===1) {
  1183. // reload(60);
  1184. // let auto_ougi = function(){toggleOugi(true,clickAttack);};
  1185. // let healSarasa2 = function(){usePot("green",1,auto_ougi);};
  1186. // let char4_b = function(){clickBack(healSarasa2);};
  1187. // let char4_3 = function(){useSkill(chara_id,3,char4_b);};
  1188. // let char4_1 = function(){useSkill(chara_id,1,char4_3);};
  1189. // let char4 = function(){clickChar(4,char4_1);};
  1190. // let char2_b = function(){clickBack(char4);};
  1191. // let char2_1 = function(){useSkill(chara_id,1,char2_b);};
  1192. // let char2_2 = function(){useSkill(chara_id,2,char2_1);};
  1193. // let char2 = function(){clickChar(2,char2_2);};
  1194. // let char3_b = function(){clickBack(char2);};
  1195. // let char3_3 = function(){useSkill(chara_id,3,char3_b);};
  1196. // let char3 = function(){clickChar(3,char3_3);};
  1197. // let healSarasa = function(){usePot("green",1,char3);};
  1198. // let char1_b = function(){clickBack(healSarasa);};
  1199. // let char1_4 = function(){useSkill(chara_id,4,char1_b);};
  1200. // let char1_3 = function(){useSkill(chara_id,3,char1_4);};
  1201. // let char1_1 = function(){useSkill(chara_id,1,char1_3);};
  1202. // let char1_2 = function(){useSkill(chara_id,2,char1_1);};
  1203. // let char1 = function(){clickChar(1,char1_2);};
  1204. // let char2a_b = function(){clickBack(char1);};
  1205. // let char2a_3 = function(){useSkill(chara_id,3,char2a_b);};
  1206. // let char2a = function(){clickChar(2,char2a_3);};
  1207. // let getBluePot = function(){doChat(char2a);};
  1208. // let summon1_ok = function(){clickOkSummon(getBluePot);};
  1209. // let summon1 = function(){clickSummon(1,summon1_ok,getBluePot);};
  1210. // let summon1_p = function(){clickSummonPanel(summon1);};
  1211. // summon1_p();
  1212. // // reload(60);
  1213. // // let auto_ougi = function(){toggleOugi(true,clickAttack);};
  1214. // // let char4_b = function(){clickBack(auto_ougi);};
  1215. // // let char4_3 = function(){useSkill(chara_id,3,char4_b);};
  1216. // // let char4_1 = function(){useSkill(chara_id,1,char4_3);};
  1217. // // let char4 = function(){clickChar(4,char4_1);};
  1218. // // let char2_b = function(){clickBack(char4);};
  1219. // // let char2_1 = function(){useSkill(chara_id,1,char2_b);};
  1220. // // let char2_2 = function(){useSkill(chara_id,2,char2_1);};
  1221. // // let char2 = function(){clickChar(2,char2_2);};
  1222. // // let char3_b = function(){clickBack(char2);};
  1223. // // let char3_3 = function(){useSkill(chara_id,3,char3_b);};
  1224. // // let char3 = function(){clickChar(3,char3_3);};
  1225. // // let char1_b = function(){clickBack(char3);};
  1226. // // let char1_4 = function(){useSkill(chara_id,4,char1_b);};
  1227. // // let char1_3 = function(){useSkill(chara_id,3,char1_4);};
  1228. // // let char1_1 = function(){useSkill(chara_id,1,char1_3);};
  1229. // // let char1_2 = function(){useSkill(chara_id,2,char1_1);};
  1230. // // let char1 = function(){clickChar(1,char1_2);};
  1231. // // let summon1_ok = function(){clickOkSummon(char1);};
  1232. // // let summon1 = function(){clickSummon(1,summon1_ok,char1);};
  1233. // // let summon1_p = function(){clickSummonPanel(summon1);};
  1234. // // doChat(summon1_p);
  1235. // }else if (rep.turn===2) {
  1236. // reload(20);
  1237. // let auto_ougi = function(){toggleOugi(false,clickAttack);};
  1238. // let summon5_ok = function(){clickOkSummon(auto_ougi);};
  1239. // let summon5 = function(){clickSummon(5,summon5_ok,auto_ougi);};
  1240. // let summon5_p = function(){clickSummonPanel(summon5);};
  1241. // summon5_p();
  1242. // }else if (rep.turn===3) {
  1243. // reload(20);
  1244. // let auto_ougi = function(){toggleOugi(true,clickAttack);};
  1245. // let char3_b = function(){clickBack(auto_ougi);};
  1246. // let char3_1 = function(){useSkill(chara_id,1,char3_b);};
  1247. // let char3 = function(){clickChar(3,char3_1);};
  1248. // char3();
  1249. // }else if (rep.turn===4) {
  1250. // reload(20);
  1251. // let auto_ougi = function(){toggleOugi(true,clickAttack);};
  1252. // let summon6_ok = function(){clickOkSummon(auto_ougi);};
  1253. // let summon6 = function(){clickSummon(6,summon6_ok,auto_ougi);};
  1254. // let summon6_p = function(){clickSummonPanel(summon6);};
  1255. // summon6_p();
  1256. // }else if (rep.turn===5) {
  1257. // reload(30);
  1258. // let auto_ougi = function(){toggleOugi(false,clickAttack);};
  1259. // let char2_b = function(){clickBack(auto_ougi);};
  1260. // let char2_1 = function(){useSkill(chara_id,1,char2_b);};
  1261. // let char2 = function(){clickChar(2,char2_1);};
  1262. // let summon4_ok = function(){clickOkSummon(char2);};
  1263. // let summon4 = function(){clickSummon(4,summon4_ok,char2);};
  1264. // let summon4_p = function(){clickSummonPanel(summon4);};
  1265. // summon4_p();
  1266. // }else if (rep.turn===6) {
  1267. // reload(35);
  1268. // let char1,char1_1,char1_2;
  1269. // let auto_ougi = function(){toggleOugi(true,clickAttack);};
  1270. // let char4_b = function(){clickBack(auto_ougi);};
  1271. // let char4_3 = function(){useSkill(chara_id,3,char4_b);};
  1272. // let char4_1 = function(){useSkill(chara_id,1,char4_3);};
  1273. // let char4 = function(){clickChar(4,char4_1);};
  1274. // let char3_b = function(){clickBack(char4);};
  1275. // let char3_2 = function(){useSkill(chara_id,2,char3_b);};
  1276. // let char3 = function(){clickChar(3,char3_2);};
  1277. // let char1_b = function(){clickBack(char3);};
  1278. // let char1_4 = function(){useSkill(chara_id,4,char1_b);};
  1279. // let char1_3 = function(){useSkill(chara_id,3,char1_4);};
  1280. // if (player_status[0].recast>=30) {
  1281. // char1_1 = function(){useSkill(chara_id,1,char1_3);};
  1282. // char1_2 = function(){useSkill(chara_id,2,char1_1);};
  1283. // char1 = function(){clickChar(1,char1_2);};
  1284. // }else{
  1285. // char1_2 = function(){useSkill(chara_id,2,char1_3);};
  1286. // char1_1 = function(){useSkill(chara_id,1,char1_2);};
  1287. // char1 = function(){clickChar(1,char1_1);};
  1288. // }
  1289. // char1();
  1290. // }else if (rep.turn===7) {
  1291. // reload(30);
  1292. // let auto_ougi = function(){toggleOugi(false,clickAttack);};
  1293. // let summon3_ok = function(){clickOkSummon(auto_ougi);};
  1294. // let summon3 = function(){clickSummon(3,summon3_ok,auto_ougi);};
  1295. // let summon3_p = function(){clickSummonPanel(summon3);};
  1296. // let useBluePot = function(){(usePot("blue",false,summon3_p));};
  1297. // useBluePot();
  1298. // }else if (rep.turn===8) {
  1299. // reload(20);
  1300. // let auto_ougi = function(){toggleOugi(false,clickAttack);};
  1301. // let char2_b = function(){clickBack(auto_ougi);};
  1302. // let char2_2 = function(){useSkill(chara_id,2,char2_b);};
  1303. // let char2 = function(){clickChar(2,char2_2);};
  1304. // let char3_b = function(){clickBack(char2);};
  1305. // let char3_3 = function(){useSkill(chara_id,3,char3_b);};
  1306. // let char3 = function(){clickChar(3,char3_3);};
  1307. // char3();
  1308. // }else if (rep.turn===9) {
  1309. // reload(20);
  1310. // let auto_ougi = function(){toggleOugi(true,clickAttack);};
  1311. // let char2_b = function(){clickBack(auto_ougi);};
  1312. // let char2_1 = function(){useSkill(chara_id,1,char2_b);};
  1313. // let char2 = function(){clickChar(2,char2_1);};
  1314. // let char3_b = function(){clickBack(char2);};
  1315. // let char3_1 = function(){useSkill(chara_id,1,char3_b);};
  1316. // let char3 = function(){clickChar(3,char3_1);};
  1317. // char3();
  1318. // }else if (rep.turn===10) {
  1319. // reload(20);
  1320. // let auto_ougi = function(){toggleOugi(true,clickAttack);};
  1321. // let summon2_ok = function(){clickOkSummon(auto_ougi);};
  1322. // let summon2 = function(){clickSummon(2,summon2_ok,auto_ougi);};
  1323. // let summon2_p = function(){clickSummonPanel(summon2);};
  1324. // summon2_p();
  1325. // }else if (rep.turn===11) {
  1326. // reload(40);
  1327. // let char1,char1_1,char1_2;
  1328. // let auto_ougi = function(){toggleOugi(true,clickAttack);};
  1329. // let char4_b = function(){clickBack(auto_ougi);};
  1330. // let char4_4 = function(){useSkill(chara_id,4,char4_b);};
  1331. // let char4_3 = function(){useSkill(chara_id,3,char4_4);};
  1332. // let char4_1 = function(){useSkill(chara_id,1,char4_3);};
  1333. // let char4 = function(){clickChar(4,char4_1);};
  1334. // let char2_b = function(){clickBack(char4);};
  1335. // let char2_4 = function(){useSkill(chara_id,4,char2_b);};
  1336. // let char2 = function(){clickChar(2,char2_4);};
  1337. // let char1_b = function(){clickBack(char2);};
  1338. // let char1_4 = function(){useSkill(chara_id,4,char1_b);};
  1339. // let char1_3 = function(){useSkill(chara_id,3,char1_4);};
  1340. // if (player_status[0].recast>=30) {
  1341. // char1_1 = function(){useSkill(chara_id,1,char1_3);};
  1342. // char1_2 = function(){useSkill(chara_id,2,char1_1);};
  1343. // char1 = function(){clickChar(1,char1_2);};
  1344. // }else{
  1345. // char1_2 = function(){useSkill(chara_id,2,char1_3);};
  1346. // char1_1 = function(){useSkill(chara_id,1,char1_2);};
  1347. // char1 = function(){clickChar(1,char1_1);};
  1348. // }
  1349. // let summon1_ok = function(){clickOkSummon(char1);};
  1350. // let summon1 = function(){clickSummon(1,summon1_ok,char1);};
  1351. // let summon1_p = function(){clickSummonPanel(summon1);};
  1352. // summon1_p();
  1353. // }else{
  1354. // reload(15);
  1355. // clickAttack();
  1356. // }
  1357. // }else if (case_battle === 5) {
  1358. // // let char1 = function(){clickChar(1);};
  1359. // // usePot("green",3,char1);
  1360. // }
  1361. // }
  1362. }
  1363. }
  1364. }, 300);
  1365.  
  1366. }
  1367.  
  1368. function raidFinish(rep){
  1369. console.log(raidFinish.name);
  1370. reload(10);
  1371. let cmd = [];
  1372. let check_timer = true;
  1373. cmd.push({"cmd":"log","level":"process","msg":message.raid.finish});
  1374. let reward_list = {};
  1375. let loop_list = [1,2,3,4,11];
  1376.  
  1377. for (let l in loop_list){
  1378. if (Object.keys(rep.rewards.reward_list[loop_list[l]]).length){
  1379. let keys = [];
  1380. for(let k in rep.rewards.reward_list[loop_list[l]]) keys.push(k);
  1381. for(let i in keys){
  1382. if(reward_list[rep.rewards.reward_list[loop_list[l]][keys[i]].name]){
  1383. reward_list[rep.rewards.reward_list[loop_list[l]][keys[i]].name] += parseInt(rep.rewards.reward_list[loop_list[l]][keys[i]].count);
  1384. }else{
  1385. reward_list[rep.rewards.reward_list[loop_list[l]][keys[i]].name] = parseInt(rep.rewards.reward_list[loop_list[l]][keys[i]].count);
  1386. }
  1387. }
  1388. }
  1389. }
  1390. if (tracked_item !== false){
  1391. let track_item = my_profile+"Current Status:";
  1392. let temp_str;
  1393. for (let item in tracked_item){
  1394. if (tracked_item.hasOwnProperty(item)) {
  1395. temp_str = "\n- "+tracked_item[item].name+": "+(tracked_item[item].number).toString();
  1396. track_item += temp_str;
  1397. }
  1398. }
  1399. cmd.push({"cmd":"log","level":"summary","msg":track_item,"split":0});
  1400. }
  1401. cmd.push({"cmd":"reward","payload":reward_list});
  1402. if (check_timer){
  1403. cmd.push({"cmd":"check_timer"});
  1404. }
  1405. xhr.open('POST', server);
  1406. xhr.send(JSON.stringify(cmd));
  1407. let gotoMain = function() {gotoHash("main");};
  1408. checkEl(".mask",0,gotoMain);
  1409. }