🏠 Home 

咕咕镇数据采集

咕咕镇数据采集,目前采集已关闭,兼作助手

  1. // ==UserScript==
  2. // @name 咕咕镇数据采集
  3. // @namespace https://greasyfork.org/users/448113
  4. // @version 1.3.9
  5. // @description 咕咕镇数据采集,目前采集已关闭,兼作助手
  6. // @author paraii
  7. // @include https://www.guguzhen.com/*
  8. // @grant GM_xmlhttpRequest
  9. // @connect notes.orga.cat
  10. // @connect www.guguzhen.com
  11. // @require https://cdn.jsdelivr.net/npm/jquery@3.2.1/dist/jquery.min.js
  12. // @require https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/js/tooltip.js
  13. // @require https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/js/popover.js
  14. // @run-at document-body
  15. // @license MIT License
  16. // ==/UserScript==
  17. (function() {
  18. 'use strict'
  19. var headersPOST = { 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8', 'Cookie': document.cookie };
  20. function submitData() {
  21. if (localStorage.length > 4 && localStorage.getItem('over') == '1') {
  22. var meURL = `https://notes.orga.cat/${encodeURI(localStorage.getItem('title')).replace(/%/g, '').replace(/~/g, '7E')}`;
  23. console.log(meURL);
  24. GM_xmlhttpRequest({
  25. method: 'GET',
  26. url: meURL,
  27. timeout: 30000,
  28. headers: { 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8' },
  29. onload: response => {
  30. let text = response.responseText.match(/content">([\s\S]*)<\/text/)[1];
  31. if (text.length == 0) {
  32. text = '{"1-50":{"MU":[0],"ZHU":[0],"DENG":[0],"SHOU":[0]},"51-100":{"MU":[0],"ZHU":[0],"DENG":[0],"SHOU":[0]},"101-":{"MU":[0],"ZHU":[0],"DENG":[0],"SHOU":[0]}}'
  33. } else {
  34. text = text.replace(/&quot;/g, '"');
  35. }
  36. let json = JSON.parse(text);
  37. let pk_i = 0;
  38. while (localStorage.getItem(`pk${pk_i}`) != null) {
  39. let a = localStorage.getItem(`pk${pk_i}`).split(',');
  40. let n = a.shift();
  41. for (let j = 1; j < a.length; j++) {
  42. a[j] = +a[j];
  43. }
  44. if (a[3] < 51) {
  45. json['1-50'][n].push(a);
  46. } else if (a[3] < 101 && a[3] > 50) {
  47. json['51-100'][n].push(a);
  48. } else {
  49. json['101-'][n].push(a);
  50. }
  51. pk_i++;
  52. }
  53. text = JSON.stringify(json);
  54. GM_xmlhttpRequest({
  55. method: 'POST',
  56. url: meURL,
  57. timeout: 30000,
  58. headers: headersPOST,
  59. data: `text=${text}`,
  60. onload: response => {
  61. let atrr = localStorage.getItem('attribute');
  62. let na = localStorage.getItem('cardName');
  63. let ti = localStorage.getItem('title');
  64. localStorage.clear();
  65. localStorage.setItem('attribute', atrr);
  66. localStorage.setItem('cardName', na);
  67. localStorage.setItem('title', ti);
  68. }
  69. });
  70. }
  71. });
  72. return 1;
  73. } else {
  74. return 0;
  75. }
  76. }
  77. function eqToAbbr(name) {
  78. let abbr = 0;
  79. switch (name[name.length - 1]) {
  80. case '杖':
  81. switch (name[name.length - 2]) {
  82. case '短':
  83. abbr = 'STAFF';
  84. break;
  85. case '法':
  86. abbr = 'WAND';
  87. break;
  88. }
  89. break;
  90. case '剑':
  91. switch (name[name.length - 2]) {
  92. case '之':
  93. abbr = 'SWORD';
  94. break;
  95. case '重':
  96. abbr = 'CLAYMORE';
  97. break;
  98. }
  99. break;
  100. case '刃':
  101. abbr = 'BLADE';
  102. break;
  103. case '首':
  104. abbr = 'DAGGER';
  105. break;
  106. case '盾':
  107. abbr = 'SHIELD';
  108. break;
  109. case '套':
  110. switch (name[name.length - 3]) {
  111. case '者':
  112. abbr = 'GLOVES';
  113. break;
  114. case '鹫':
  115. abbr = 'VULTURE';
  116. break;
  117. }
  118. break;
  119. case '环':
  120. abbr = 'BRACELET';
  121. break;
  122. case '袍':
  123. abbr = 'CLOAK';
  124. break;
  125. case '巾':
  126. abbr = 'SCARF';
  127. break;
  128. case '饰':
  129. abbr = 'TIARA';
  130. break;
  131. case '带':
  132. abbr = 'RIBBON';
  133. break;
  134. default:
  135. switch (name[name.length - 2]) {
  136. case '短':
  137. abbr = 'BOW';
  138. break;
  139. case '杀':
  140. abbr = 'ASSBOW';
  141. break;
  142. case '布':
  143. abbr = 'CLOTH';
  144. break;
  145. case '皮':
  146. abbr = 'LEATHER';
  147. break;
  148. case '铁':
  149. abbr = 'PLATE';
  150. break;
  151. case '重':
  152. abbr = 'THORN';
  153. break;
  154. }
  155. }
  156. return abbr;
  157. }
  158. function readEquipmentDOM(responseText) {
  159. let div0 = document.createElement('div');
  160. div0.innerHTML = `${responseText}</div>`;
  161. div0.innerHTML = `${div0.children[0].children[1].innerHTML}${div0.children[1].children[1].innerHTML}`;
  162. return div0;
  163. }
  164. function getEquipmentInfo(nodes) {
  165. let data = new Array();
  166. if (nodes.length > 0) {
  167. for (let i = 0; i < nodes.length; i++) {
  168. if (nodes[i].className.split(' ').length != 3 || nodes[i].innerText.indexOf('+') != -1) {
  169. continue;
  170. }
  171. let atrr = nodes[i].getAttribute('data-content').match(/>[0-9]+%</g);
  172. let title = 0;
  173. title = nodes[i].getAttribute('data-original-title');
  174. if (title == null) {
  175. title = nodes[i].getAttribute('title');
  176. }
  177. let lv = title.match(/>[0-9]+</g)[0];
  178. let name = title.substr(title.lastIndexOf('>') + 1);
  179. let mys = nodes[i].getAttribute('data-content').match(/\[神秘属性\]/);
  180. if (mys != null) {
  181. mys = 1;
  182. } else {
  183. mys = 0;
  184. }
  185. let id = nodes[i].getAttribute('onclick');
  186. if (id != null) {
  187. id = id.match(/[0-9]+/)[0];
  188. }
  189. name = eqToAbbr(name);
  190. data.push(new Array(name, lv.replace('<', '').replace('>', ''), atrr[0].replace('%', '').replace('<', '').replace('>', ''), atrr[1].replace('%', '').replace('<', '').replace('>', ''), atrr[2].replace('%', '').replace('<', '').replace('>', ''), atrr[3].replace('%', '').replace('<', '').replace('>', ''), mys, id));
  191. }
  192. }
  193. return data;
  194. }
  195. var equKey = new Array('BLADE', 'ASSBOW', 'WAND', 'STAFF', 'DAGGER', 'CLAYMORE', 'SHIELD', 'BOW', 'SWORD', 'BOUND_0',
  196. 'GLOVES', 'BRACELET', 'VULTURE', 'BOUND_1', 'CLOAK', 'THORN', 'PLATE', 'LEATHER', 'CLOTH', 'BOUND_2', 'SCARF', 'TIARA', 'RIBBON');
  197. var fullName = new Array('狂信者的荣誉之刃', '反叛者的刺杀弓', '光辉法杖', '探险者短杖', '幽梦匕首', '陨铁重剑', '荆棘剑盾', '探险者短弓', '探险者之剑', 'BOUND_0',
  198. '探险者手套', '命师的传承手环', '秃鹫手套', 'BOUND_1', '旅法师的灵光袍', '战线支撑者的荆棘重甲', '铁甲', '皮甲', '布甲', 'BOUND_2', '探险者头巾', '占星师的发饰', '天使缎带');
  199. var sortdict = new Array();
  200. var fullNameOf = new Array();
  201. for (let i = 0; i < equKey.length; i++) {
  202. sortdict[equKey[i]] = i;
  203. fullNameOf[equKey[i]] = fullName[i];
  204. }
  205. function sortEqByName(e1, e2) {
  206. try {
  207. let title1 = e1.getAttribute('data-original-title');
  208. if (title1 == null) {
  209. title1 = e1.getAttribute('title');
  210. }
  211. let name1 = eqToAbbr(title1.substr(title1.lastIndexOf('>') + 1));
  212. e1.setAttribute('data-abbr', sortdict[name1]);
  213. let title2 = e2.getAttribute('data-original-title');
  214. if (title2 == null) {
  215. title2 = e2.getAttribute('title');
  216. }
  217. let name2 = eqToAbbr(title2.substr(title2.lastIndexOf('>') + 1));
  218. e2.setAttribute('data-abbr', sortdict[name2]);
  219. return sortdict[name1] - sortdict[name2];
  220. } catch {
  221. console.log(e1);
  222. }
  223. }
  224. function getPostData(p1, p2) {
  225. let data = -1;
  226. let sc = document.getElementsByTagName('script');
  227. //console.log(sc);
  228. for (let i = 0; i < sc.length; i++) {
  229. let func = sc[i].innerText.match(p1);
  230. if (func != null) {
  231. data = func[0].match(p2)[0];
  232. break;
  233. }
  234. }
  235. return data;
  236. }
  237. var user = document.getElementsByClassName('icon-user')[0].parentNode.innerText.split(' ')[1];
  238. console.log(user)
  239. if (localStorage.getItem(user) == null) {
  240. localStorage.setItem(user, '{"dataIndex":{"battleInfoNow":"0","battleInfoBefore":"0","battleInfoBack":"0"},"dataBind":{"0":"0"},"dataBeachSift":{"0":"0"}}');
  241. }
  242. function getUserData() {
  243. return JSON.parse(localStorage.getItem(user));
  244. }
  245. function setUserData(json) {
  246. localStorage.setItem(user, JSON.stringify(json));
  247. }
  248. function wishExpireTip() {
  249. GM_xmlhttpRequest({
  250. method: 'POST',
  251. url: `https://www.guguzhen.com/fyg_read.php`,
  252. headers: headersPOST,
  253. data: `f=19`,
  254. onload: response => {
  255. let cost = response.responseText.split('#')[0];
  256. //console.log(cost);
  257. if (parseInt(cost) < 200) {
  258. let h = document.getElementsByClassName('panel-heading')[0];
  259. h.innerHTML += '<span style="text-align:center;display:block;background-color:red">※许愿池已过期</span>';
  260. }
  261. }
  262. });
  263. }
  264. //GM_addStyle(GM_getResourceText('bootstrapcss'));
  265. if (localStorage.getItem('attribute') == null && localStorage.getItem('cardName') == null) {
  266. localStorage.setItem('attribute', 0);
  267. localStorage.setItem('cardName', 0);
  268. }
  269. // if(localStorage.getItem('pk99')!=null&&localStorage.getItem('title')!=null){ //超过100条战斗自动提交
  270. // localStorage.setItem('over', 1);
  271. // try{
  272. // //submitData();
  273. // }catch(err){
  274. // console.log(err);
  275. // }
  276. // localStorage.setItem('over', 0);
  277. // let nameURL = `https://notes.orga.cat/gugudataname`;
  278. // GM_xmlhttpRequest({
  279. // method: 'GET',
  280. // url: nameURL,
  281. // timeout: 30000,
  282. // headers: {'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'},
  283. // onload: response => {
  284. // let text = response.responseText.match(/content">([\s\S]*)<\/text/)[1];
  285. // let list = text.split(',');
  286. // if(list.indexOf(localStorage.getItem('title'))==-1){
  287. // list.push(localStorage.getItem('title'));
  288. // text = list.join(',');
  289. // GM_xmlhttpRequest({
  290. // method: 'POST',
  291. // url: nameURL,
  292. // timeout: 30000,
  293. // headers: {'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'},
  294. // data: `text=${text}`,
  295. // onload: response => {
  296. // let atrr = localStorage.getItem('attribute');
  297. // let na = localStorage.getItem('cardName');
  298. // let ti = localStorage.getItem('title');
  299. // localStorage.clear();
  300. // localStorage.setItem('attribute',atrr);
  301. // localStorage.setItem('cardName',na);
  302. // localStorage.setItem('title',ti);
  303. // }
  304. // });
  305. // }
  306. // }
  307. // });
  308. // }
  309. var attribute = new Array();
  310. if (window.location.pathname == '/fyg_index.php') {
  311. let userData = getUserData();
  312. let dataIndex = userData.dataIndex;
  313. let waitForCol = setInterval(() => {
  314. if (document.getElementsByClassName('col-md-4') != null) {
  315. clearInterval(waitForCol);
  316. dataIndex.battleInfoNow = document.getElementsByClassName('col-md-4')[0].children[4].children[0].innerText;
  317. let p0 = document.createElement('p');
  318. if (dataIndex.battleInfoNow == dataIndex.battleInfoBefore) {
  319. p0.innerText = `对玩家战斗(上次查看):${dataIndex.battleInfoBack}`;
  320. } else {
  321. p0.innerText = `对玩家战斗(上次查看):${dataIndex.battleInfoBefore}`;
  322. dataIndex.battleInfoBack = dataIndex.battleInfoBefore;
  323. dataIndex.battleInfoBefore = dataIndex.battleInfoNow
  324. }
  325. setUserData(userData);
  326. document.getElementsByClassName('col-md-4')[0].appendChild(p0);
  327. }
  328. }, 1000);
  329. } else if (window.location.pathname == '/fyg_equip.php') {
  330. let btnc1 = document.createElement('button');
  331. let timeoutWaitForCard = 0;
  332. btnc1.innerText = '导出计算器';
  333. btnc1.onclick = () => {
  334. try {
  335. d.innerHTML = '<div class="pop_main">\n<div class="pop_con">\n<div class="pop_text">0</div>\n<div class="pop_text">0</div>\n<a href="#">×</a>\n</div>\n<div class="mask"></div>\n</div>';
  336. $('.pop_con a').click(() => {
  337. $('.pop_con').animate({ 'top': 0, 'opacity': 0 }, () => {
  338. $('.pop_main').hide()
  339. })
  340. })
  341. $('.pop_main').show()
  342. $('.pop_con').css({ 'top': 0, 'opacity': 0 })
  343. $('.pop_con').animate({ 'top': '50%', 'opacity': 1 })
  344. let text = $('.pop_text');
  345. let cardName = document.querySelector("#backpacks > div:nth-child(1) > div.col-md-4 > div > div.row > div.col-xs-2.fyg_f18.fyg_tr").innerText;
  346. let cardInfo = document.querySelector("#backpacks > div:nth-child(1) > div.col-md-4 > div > div.fyg_tl").innerText.match(/[0-9]+/g);
  347. text[1].innerText = `${document.getElementById('sjll').getAttribute('value')} ${document.getElementById('sjmj').getAttribute('value')} ${document.getElementById('sjzl').getAttribute('value')} ${document.getElementById('sjtp').getAttribute('value')} ${document.getElementById('sjjs').getAttribute('value')} ${document.getElementById('sjyz').getAttribute('value')}`;
  348. switch (cardName) {
  349. case '琳':
  350. text[0].innerText = `LIN ${cardInfo[0]} ${cardInfo[1]} ${cardInfo[2]}`;
  351. break;
  352. case '艾':
  353. text[0].innerText = `AI ${cardInfo[0]} ${cardInfo[1]} ${cardInfo[2]}`;
  354. break;
  355. case '默':
  356. text[0].innerText = `MO ${cardInfo[0]} ${cardInfo[1]} ${cardInfo[2]}`;
  357. break;
  358. case '梦':
  359. text[0].innerText = `MENG ${cardInfo[0]} ${cardInfo[1]} ${cardInfo[2]}`;
  360. break;
  361. case '薇':
  362. text[0].innerText = `WEI ${cardInfo[0]} ${cardInfo[1]} ${cardInfo[2]}`;
  363. break;
  364. case '伊':
  365. text[0].innerText = `YI ${cardInfo[0]} ${cardInfo[1]} ${cardInfo[2]}`;
  366. break;
  367. }
  368. } catch (err) { console.log(err); }
  369. }
  370. let waitForBackpacks = setInterval(() => {
  371. if (document.getElementById('backpacks') != null && document.getElementsByClassName('fyg_tc')[3] != null) {
  372. clearInterval(waitForBackpacks);
  373. wishExpireTip();
  374. let div00 = document.createElement('div');
  375. div00.innerHTML = `<p></p><p><button type="button" class="btn btn-block collapsed" data-toggle="collapse" data-target="#eq0"><i class="icon icon-caret-down"></i></button></p>
  376. <div class="in" id="eq0"></div>
  377. <p><button type="button" class="btn btn-block collapsed" data-toggle="collapse" data-target="#eq1"><i class="icon icon-caret-down"></i></button></p>
  378. <div class="in" id="eq1"></div>
  379. <p><button type="button" class="btn btn-block collapsed" data-toggle="collapse" data-target="#eq2"><i class="icon icon-caret-down"></i></button></p>
  380. <div class="in" id="eq2"></div>
  381. <p><button type="button" class="btn btn-block collapsed" data-toggle="collapse" data-target="#eq3"><i class="icon icon-caret-down"></i></button></p>
  382. <div class="in" id="eq3"></div>
  383. <p><button type="button" class="btn btn-block collapsed" data-toggle="collapse" data-target="#eq4"><i class="icon icon-caret-down"></i>护符</button></p>
  384. <div class="in" id="eq4"></div>`;
  385. let eqbtns = null;
  386. function addCollapse() {
  387. let waitForBtn = setInterval(() => {
  388. if (document.getElementsByClassName('fyg_tc')[3] != null) {
  389. eqbtns = [].slice.call(document.getElementsByClassName('fyg_tc')[3].children);
  390. if (document.getElementById('backpacks').innerText.indexOf('读取中') == -1 &&
  391. eqbtns.length > 0 && eqbtns[0].className.split(' ')[2] == 'fyg_mp3' &&
  392. document.getElementById('carding').innerText.indexOf('读取中') == -1) {
  393. clearInterval(waitForBtn);
  394. let eqstore = document.getElementById('backpacks').children[1].children[1].children;
  395. for (let i = 0; i < eqstore.length; i++) {
  396. if (eqstore[i].className.split(' ').length == 3) {
  397. eqstore[i].dataset.instore = 1;
  398. }
  399. }
  400. eqbtns = [].slice.call(document.getElementsByClassName('fyg_tc')[3].children)
  401. .concat([].slice.call(document.getElementById('backpacks').children[0].children[1].children))
  402. .concat([].slice.call(document.getElementById('backpacks').children[1].children[1].children));
  403. for (let i = eqbtns.length - 1; i >= 0; i--) {
  404. if (eqbtns[i].className.split(' ').length != 3) {
  405. eqbtns.splice(i, 1);
  406. }
  407. }
  408. // if (eqbtns[eqbtns.length - 1].className.split(' ')[2] != 'fyg_mp3') {
  409. // eqbtns = eqbtns.slice(0, -2);
  410. // }
  411. //console.log(eqbtns);
  412. if (document.getElementsByClassName('collapsed').length == 0) {
  413. document.getElementById('backpacks').insertBefore(div00, document.getElementById('backpacks').lastChild);
  414. }
  415. for (let i = eqbtns.length - 1; i >= 0; i--) {
  416. if (eqbtns[i].className.split(' ')[0] == 'popover') {
  417. eqbtns.splice(i, 1);
  418. break;
  419. }
  420. }
  421. eqbtns.sort(sortEqByName);
  422. document.getElementById('eq0').innerHTML = '';
  423. document.getElementById('eq1').innerHTML = '';
  424. document.getElementById('eq2').innerHTML = '';
  425. document.getElementById('eq3').innerHTML = '';
  426. document.getElementById('eq4').innerHTML = '';
  427. let ineq = document.getElementById('eq0');
  428. for (let i = 0; i < eqbtns.length; i++) {
  429. if (eqbtns[i].innerText == '空') {
  430. continue;
  431. }
  432. let btn0 = document.createElement('button');
  433. btn0.setAttribute('class', 'btn btn-light');
  434. btn0.setAttribute('onclick', eqbtns[i].getAttribute('onclick'));
  435. let storeText = '';
  436. if (eqbtns[i].dataset.instore == 1) {
  437. storeText = '【仓】';
  438. }
  439. btn0.innerHTML = `<h3 class="popover-title" style="color:white;background-color: ${getComputedStyle(eqbtns[i]).getPropertyValue("background-color")}">${storeText}${eqbtns[i].dataset.originalTitle}</h3><div class="popover-content-show">${eqbtns[i].dataset.content}</div>`;
  440. if (btn0.children[1].lastChild.nodeType == 3) { //清除背景介绍文本
  441. btn0.children[1].lastChild.remove();
  442. }
  443. if (eqbtns[i].innerText.indexOf('+') != -1) {
  444. ineq = document.getElementById('eq4');
  445. //console.log(btn0);
  446. } else {
  447. let a = parseInt(eqbtns[i].dataset.abbr);
  448. if (a >= sortdict.BOUND_0 && a < sortdict.BOUND_1) {
  449. ineq = document.getElementById('eq1');
  450. } else if (a >= sortdict.BOUND_1 && a < sortdict.BOUND_2) {
  451. ineq = document.getElementById('eq2');
  452. } else if (a >= sortdict.BOUND_2) {
  453. ineq = document.getElementById('eq3');
  454. } else {
  455. ineq = document.getElementById('eq0');
  456. }
  457. }
  458. ineq.appendChild(btn0);
  459. }
  460. let collapseStore = document.createElement('button');
  461. collapseStore.innerText = '折叠';
  462. collapseStore.style.float = 'right';
  463. collapseStore.onclick = () => {
  464. if ($('#backpacks > div.alert.alert-success.with-icon > div').css('display') == 'none') {
  465. $('#backpacks > div.alert.alert-success.with-icon > div').show();
  466. collapseStore.innerText = '折叠';
  467. } else {
  468. $('#backpacks > div.alert.alert-success.with-icon > div').hide();
  469. collapseStore.innerText = '展开';
  470. }
  471. }
  472. if (document.getElementById('backpacks').children[1].children.length == 2) {
  473. document.getElementById('backpacks').children[1].appendChild(collapseStore);
  474. }
  475. $('.popover-content-show').css({
  476. 'padding': '10px 10px 0px 10px'
  477. });
  478. $('.btn-light').css({
  479. 'padding': 0,
  480. 'text-align': 'left',
  481. 'box-shadow': 'none',
  482. 'background-color': 'none',
  483. 'line-height': '90%'
  484. });
  485. $('.bg-danger').css({
  486. 'padding': '5px 5px 5px 5px',
  487. 'max-width': '200px',
  488. 'white-space': 'pre-line',
  489. 'word-break': 'break-all',
  490. 'line-height': '110%'
  491. });
  492. }
  493. }
  494. }, 500);
  495. }
  496. if (document.getElementsByClassName('nav nav-secondary nav-justified')[0].children[0].className == 'active') { addCollapse(); }
  497. let cardPagePop = document.createElement('div');
  498. cardPagePop.setAttribute('id', 'cardpage_pop');
  499. let initHTML = `<div class="popup-content">
  500. <div class="topline">
  501. <p></p>
  502. <div class="equipment_selector"></div>
  503. </div>
  504. <div class="topline">
  505. <p></p>
  506. <div class="equipment_selector"></div>
  507. </div>
  508. <div class="topline">
  509. <p></p>
  510. <div class="equipment_selector"></div>
  511. </div>
  512. <div class="topline">
  513. <p></p>
  514. <div class="equipment_selector"></div>
  515. </div>
  516. <p></p>
  517. <div class="halo_selector"></div>
  518. <p id="load_tip">读取中...</p>
  519. <button type="button" id="bind">绑定</button>
  520. <button type="button" onclick="unbind()">解除绑定</button>
  521. <button type="button" onclick="quit()">取消</button>
  522. </div>`;
  523. cardPagePop.innerHTML = `<style>
  524. .popup {
  525. width: 100vw;
  526. height: 100vh;
  527. background-color: rgba(0, 0, 0, .5);
  528. position: fixed;
  529. left: 0;
  530. top: 0;
  531. bottom: 0;
  532. right: 0;
  533. z-index: 9999;
  534. display: none;
  535. justify-content: center;
  536. align-items: center;
  537. }
  538. .popup-content {
  539. width: 400px;
  540. height: 200px;
  541. background-color: #fff;
  542. box-sizing: border-box;
  543. padding: 10px 30px;
  544. color: black;
  545. }
  546. .topline {
  547. width: 100%;
  548. border-bottom: 1px solid black;
  549. }
  550. </style>
  551. <div class="popup" id="popup">
  552. ${initHTML}
  553. </div>`;
  554. unsafeWindow.equipOnekey = function(t) {
  555. $('.popup-content').height(100);
  556. $('.popup-content').width(100);
  557. document.getElementById("popup").innerHTML = `<div class="popup-content">
  558. <div class="topline">
  559. <p></p>
  560. <div>装备×</div>
  561. <div>光环×</div>
  562. </div>
  563. <div>更换中..</div>
  564. <button type="button" onclick="quit()">取消</button>
  565. </div>`;
  566. let role = t.parentNode.parentNode.parentNode.parentNode.children[0].children[0];
  567. let roleId = role.getAttribute('onclick').match(/[0-9]+/)[0];
  568. role = role.children[0].innerText.replace(/\s+/g, '').split('级')[1] + role.children[1].innerText.replace(/\s+/g, '');
  569. console.log(`equipOnekey: ${roleId} ${role}`);
  570. let bind_info = null;
  571. let ud = getUserData();
  572. if (ud.dataBind[roleId] != null) {
  573. bind_info = ud.dataBind[roleId];
  574. }
  575. // else{
  576. // bind_info = localStorage.getItem(`${role}`);
  577. // ud.dataBind[role] = bind_info; //数据兼容转移
  578. // setUserData(ud);
  579. // localStorage.removeItem(`${role}`);
  580. // }
  581. console.log(`bind_info of role:${bind_info}`);
  582. console.log(`ID of role:${roleId}`);
  583. function sendEquipHttpRequest(eqinfo) {
  584. let request = GM_xmlhttpRequest({
  585. method: 'POST',
  586. url: `https://www.guguzhen.com/fyg_read.php`,
  587. headers: headersPOST,
  588. data: 'f=7',
  589. onload: response => {
  590. let div0 = readEquipmentDOM(response.responseText);
  591. let equipment = getEquipmentInfo(div0.children);
  592. let ids = new Array();
  593. for (let i = 0; i < eqinfo.length; i++) {
  594. for (let j = 0; j < equipment.length; j++) {
  595. if (eqinfo[i] == equipment[j].slice(0, -2).join()) {
  596. ids.push(equipment[j]);
  597. break;
  598. }
  599. }
  600. }
  601. let c = ids.length;
  602. let puton_data = getPostData(/puton\(id\)\{[\s\S]*\}/m, /data: ".*\+id\+.*"/).slice(7, -1);
  603. for (let i = 0; i < ids.length; i++) {
  604. GM_xmlhttpRequest({
  605. method: 'POST',
  606. url: `https://www.guguzhen.com/fyg_click.php`,
  607. headers: headersPOST,
  608. data: puton_data.replace('"+id+"', ids[i][ids[i].length - 1]),
  609. onload: response => {
  610. if (response.responseText == 'ok') {
  611. c--;
  612. if (c == 0) {
  613. document.getElementsByClassName('topline')[0].children[1].innerText = '装备√';
  614. if (document.getElementsByClassName('topline')[0].children[2].innerText == '光环√') {
  615. window.location.reload();
  616. document.getElementById("popup").style.display = "none";
  617. }
  618. }
  619. }
  620. }
  621. });
  622. }
  623. }
  624. });
  625. return request;
  626. }
  627. function sendBeginEquipHttpRequest(bind_info) {
  628. let isStore = false;
  629. document.getElementsByClassName('topline')[0].children[1].innerText = '装备×';
  630. let request = GM_xmlhttpRequest({
  631. method: 'POST',
  632. url: `https://www.guguzhen.com/fyg_read.php`,
  633. headers: headersPOST,
  634. data: 'f=7',
  635. onload: response => {
  636. let div0 = readEquipmentDOM(response.responseText);
  637. let equipment = getEquipmentInfo(div0.children);
  638. let equiped = getEquipmentInfo(document.getElementsByClassName('fyg_tc')[3].children);
  639. let ids = new Array();
  640. let err = 0;
  641. for (let i = 0; i < 4; i++) {
  642. let exist = 0;
  643. for (let j = 0; j < 4; j++) {
  644. if (bind_info[i] == equiped[j].slice(0, -2).join()) { //已装备
  645. exist = 1;
  646. break;
  647. }
  648. }
  649. if (exist == 0) { //未装备
  650. for (let j = 0; j < equipment.length; j++) {
  651. if (bind_info[i] == equipment[j].slice(0, -2).join()) {
  652. ids.push(equipment[j]);
  653. exist = 1;
  654. break;
  655. }
  656. }
  657. if (exist == 0) {
  658. console.log(bind_info[i]);
  659. alert('有装备不存在,请重新绑定');
  660. err = 1;
  661. window.location.reload();
  662. }
  663. }
  664. }
  665. if (err == 0) {
  666. let c = ids.length;
  667. if (c == 0) {
  668. document.getElementsByClassName('topline')[0].children[1].innerText = '装备√';
  669. if (document.getElementsByClassName('topline')[0].children[2].innerText == '光环√') {
  670. window.location.reload();
  671. document.getElementById("popup").style.display = "none";
  672. }
  673. }
  674. let puton_data = getPostData(/puton\(id\)\{[\s\S]*\}/m, /data: ".*\+id\+.*"/).slice(7, -1);
  675. let puto_data = 'c=22' + puton_data.slice(3);
  676. let storeCount = 0;
  677. let storePuton = new Array();
  678. for (let i = 0; i < ids.length; i++) {
  679. GM_xmlhttpRequest({
  680. method: 'POST',
  681. url: `https://www.guguzhen.com/fyg_click.php`,
  682. headers: headersPOST,
  683. data: puton_data.replace('"+id+"', ids[i][ids[i].length - 1]),
  684. onload: response => {
  685. if (response.responseText == 'ok') {
  686. c--;
  687. if (c == 0 && !isStore) {
  688. document.getElementsByClassName('topline')[0].children[1].innerText = '装备√';
  689. if (document.getElementsByClassName('topline')[0].children[2].innerText == '光环√') {
  690. window.location.reload();
  691. document.getElementById("popup").style.display = "none";
  692. }
  693. } else if (c == 0 && isStore) {
  694. request = sendEquipHttpRequest(storePuton);
  695. }
  696. } else if (response.responseText == '这不是你的装备') {
  697. let item = ids[i].slice(0, -1);
  698. item = new Array(fullNameOf[item[0]], `Lv${item[1]}`, `${item[2]}%`, `${item[3]}%`, `${item[4]}%`, `${item[5]}%`, `${item[6] == 1 ? '神秘' : ''}`).join(' ');
  699. //alert(`${item}\n在仓库中,装备失败,请检查`);
  700. storeCount++;
  701. document.getElementsByClassName('topline')[0].children[1].innerText = '装备× 取出仓库...';
  702. GM_xmlhttpRequest({
  703. method: 'POST',
  704. url: `https://www.guguzhen.com/fyg_click.php`,
  705. headers: headersPOST,
  706. data: puto_data.replace('"+id+"', ids[i][ids[i].length - 1]),
  707. onload: response => {
  708. console.log(response.responseText);
  709. if (response.responseText == 'ok') {
  710. storeCount--;
  711. if (storeCount == 0) {
  712. document.getElementsByClassName('topline')[0].children[1].innerText = '装备×';
  713. }
  714. isStore = true;
  715. storePuton.push(ids[i].slice(0, 6));
  716. c--;
  717. if (c == 0) {
  718. request = sendEquipHttpRequest(storePuton);
  719. }
  720. } else if (response.responseText == '背包已满。') {
  721. alert(`背包已满,仓库装备\n${item}\n无法取出,请整理背包`);
  722. c--;
  723. if (c == 0 && !isStore) {
  724. document.getElementsByClassName('topline')[0].children[1].innerText = '装备√';
  725. if (document.getElementsByClassName('topline')[0].children[2].innerText == '光环√') {
  726. window.location.reload();
  727. document.getElementById("popup").style.display = "none";
  728. }
  729. } else if (c == 0 && isStore) {
  730. request = sendEquipHttpRequest(storePuton);
  731. }
  732. }
  733. }
  734. });
  735. }
  736. }
  737. });
  738. }
  739. }
  740. }
  741. });
  742. return request;
  743. }
  744. let upcard_data = getPostData(/upcard\(id\)\{[\s\S]*\}/m, /data: ".*\+id\+.*"/).slice(7, -1).replace('"+id+"', roleId);
  745. if (bind_info != null) {
  746. GM_xmlhttpRequest({
  747. method: 'POST',
  748. url: `https://www.guguzhen.com/fyg_click.php`,
  749. headers: headersPOST,
  750. data: upcard_data,
  751. onload: response => {
  752. if (response.responseText == 'ok' || response.responseText == '你没有这张卡片或已经装备中') {
  753. console.log(`card response: ${response.responseText}`);
  754. bind_info = bind_info.split('|');
  755. let equRequest = sendBeginEquipHttpRequest(bind_info);
  756. let halo = bind_info[bind_info.length - 1].split(',');
  757. for (let i = 0; i < halo.length; i++) {
  758. switch (halo[i]) {
  759. case '启程之誓':
  760. halo[i] = '101';
  761. break;
  762. case '启程之心':
  763. halo[i] = '102';
  764. break;
  765. case '启程之风':
  766. halo[i] = '103';
  767. break;
  768. case '破壁之心':
  769. halo[i] = '201';
  770. break;
  771. case '破魔之心':
  772. halo[i] = '202';
  773. break;
  774. case '复合护盾':
  775. halo[i] = '203';
  776. break;
  777. case '鲜血渴望':
  778. halo[i] = '204';
  779. break;
  780. case '削骨之痛':
  781. halo[i] = '205';
  782. break;
  783. case '伤口恶化':
  784. halo[i] = '301';
  785. break;
  786. case '精神创伤':
  787. halo[i] = '302';
  788. break;
  789. case '铁甲尖刺':
  790. halo[i] = '303';
  791. break;
  792. case '忍无可忍':
  793. halo[i] = '304';
  794. break;
  795. case '热血战魂':
  796. halo[i] = '305';
  797. break;
  798. case '点到为止':
  799. halo[i] = '306';
  800. break;
  801. case '沸血之志':
  802. halo[i] = '401';
  803. break;
  804. case '波澜不惊':
  805. halo[i] = '402';
  806. break;
  807. case '飓风之力':
  808. halo[i] = '403';
  809. break;
  810. case '红蓝双刺':
  811. halo[i] = '404';
  812. break;
  813. case '荧光护盾':
  814. halo[i] = '405';
  815. break;
  816. case '绝对护盾': //old
  817. halo[i] = '405';
  818. break;
  819. case '后发制人':
  820. halo[i] = '406';
  821. break;
  822. }
  823. }
  824. let halosave_data = getPostData(/halosave\(\)\{[\s\S]*\}/m, /data: ".*\+savearr\+.*"/).slice(7, -1).replace('"+savearr+"', halo.join());
  825. let haloRequest = GM_xmlhttpRequest({
  826. method: 'POST',
  827. url: `https://www.guguzhen.com/fyg_click.php`,
  828. headers: headersPOST,
  829. data: halosave_data,
  830. onload: response => {
  831. if (response.responseText == 'ok') {
  832. document.getElementsByClassName('topline')[0].children[2].innerText = '光环√';
  833. if (document.getElementsByClassName('topline')[0].children[1].innerText == '装备√') {
  834. window.location.reload();
  835. document.getElementById("popup").style.display = "none";
  836. }
  837. }
  838. }
  839. });
  840. unsafeWindow.quit = function() {
  841. document.getElementById("popup").style.display = "none";
  842. equRequest.abort();
  843. haloRequest.abort();
  844. document.getElementById("popup").innerHTML = initHTML;
  845. };
  846. document.getElementById("popup").style.display = "flex";
  847. }
  848. }
  849. });
  850. } else {
  851. alert('未绑定');
  852. }
  853. }
  854. unsafeWindow.showPopup = function(t) {
  855. document.getElementById("popup").innerHTML = initHTML;
  856. let role = t.parentNode.parentNode.parentNode.parentNode.children[0].children[0];
  857. let roleId = role.getAttribute('onclick').match(/[0-9]+/)[0];
  858. role = role.children[0].innerText.replace(/\s+/g, '').split('级')[1] + role.children[1].innerText.replace(/\s+/g, '');
  859. console.log(`bindRole: ${roleId} ${role}`);
  860. let bind_info = null;
  861. let ud = getUserData();
  862. if (ud.dataBind[roleId] != null) {
  863. bind_info = ud.dataBind[roleId];
  864. }
  865. if (bind_info != null) {
  866. bind_info = bind_info.split('|');
  867. }
  868. let equRequest = GM_xmlhttpRequest({ //获取装备
  869. method: 'POST',
  870. url: `https://www.guguzhen.com/fyg_read.php`,
  871. headers: headersPOST,
  872. data: 'f=7',
  873. onload: response => {
  874. let div0 = readEquipmentDOM(response.responseText);
  875. let equipment = getEquipmentInfo(div0.children);
  876. equipment = equipment.concat(getEquipmentInfo(document.getElementsByClassName('fyg_tc')[3].children));
  877. $('.popup-content').height(Math.min(equipment.length, 19) * 25 + 120);
  878. $('.popup-content').width(400);
  879. $('.popup-content').css('overflow', 'scroll');
  880. let e = new Array(new Array(), new Array(), new Array(), new Array());
  881. let origin = new Array(new Array(), new Array(), new Array(), new Array());
  882. equipment.sort((e1, e2) => {
  883. return sortdict[e1[0]] - sortdict[e2[0]];
  884. });
  885. equipment.forEach(item => {
  886. let i = 0;
  887. if (sortdict[item[0]] < sortdict.BOUND_0) {
  888. i = 0;
  889. } else if (sortdict[item[0]] >= sortdict.BOUND_0 && sortdict[item[0]] < sortdict.BOUND_1) {
  890. i = 1;
  891. } else if (sortdict[item[0]] >= sortdict.BOUND_1 && sortdict[item[0]] < sortdict.BOUND_2) {
  892. i = 2;
  893. } else {
  894. i = 3;
  895. }
  896. origin[i].push(item)
  897. //添加文字
  898. e[i].push(new Array(fullNameOf[item[0]], `Lv${item[1]}`, `${item[2]}%`, `${item[3]}%`, `${item[4]}%`, `${item[5]}%`, `${item[6] == 1 ? '神秘' : ''}`));
  899. });
  900. function selector_equ() {
  901. var equipNum = $('.equipment_selector .equipment_item').index(this);
  902. $('.equipment_selector .equipment_item')
  903. .eq(equipNum)
  904. .css('background-color', 'rgb(135, 206, 250)')
  905. .siblings('.equipment_selector .equipment_item')
  906. .css('background-color', 'rgb(255, 255, 255)');
  907. }
  908. let content = document.getElementsByClassName('equipment_selector');
  909. for (let i = 0; i < 4; i++) {
  910. for (let j = 0; j < e[i].length; j++) {
  911. let li0 = document.createElement('li');
  912. li0.setAttribute('class', 'equipment_item');
  913. li0.addEventListener('click', selector_equ, false);
  914. li0.innerHTML = `<a href="javascript:void(0)">${e[i][j].join(' ')}</a>`;
  915. if (bind_info != null && bind_info.indexOf(origin[i][j].slice(0, -2).join(',')) != -1) {
  916. li0.style.backgroundColor = 'rgb(135, 206, 250)';
  917. }
  918. content[i].appendChild(li0);
  919. }
  920. }
  921. }
  922. });
  923. localStorage.setItem('halo_max', '0'); //天赋点
  924. let haloRequest = GM_xmlhttpRequest({ //获取天赋点
  925. method: 'POST',
  926. url: `https://www.guguzhen.com/fyg_read.php`,
  927. headers: headersPOST,
  928. data: 'f=5',
  929. onload: response => {
  930. let halo = response.responseText.match(/<h3>.*</)[0].slice(4, -1);
  931. localStorage.setItem('halo_max', halo.match(/[0-9]+/).join());
  932. halo = `天赋点:${halo.match(/[0-9]+/)[0]},技能位:${role.match(/[0-9]技/)[0].slice(0, 1)}`;
  933. document.getElementsByClassName('halo_selector')[0].innerHTML = `<div>${halo}</div>
  934. <a href="javascript:void(0)" class="halo_item">启程之誓 10</a>
  935. <a href="javascript:void(0)" class="halo_item">启程之心 10</a>
  936. <a href="javascript:void(0)" class="halo_item">启程之风 10</a>
  937. <div></div>
  938. <a href="javascript:void(0)" class="halo_item">破壁之心 30</a>
  939. <a href="javascript:void(0)" class="halo_item">破魔之心 30</a>
  940. <a href="javascript:void(0)" class="halo_item">复合护盾 30</a>
  941. <a href="javascript:void(0)" class="halo_item">鲜血渴望 30</a>
  942. <a href="javascript:void(0)" class="halo_item">削骨之痛 30</a>
  943. <div></div>
  944. <a href="javascript:void(0)" class="halo_item">伤口恶化 50</a>
  945. <a href="javascript:void(0)" class="halo_item">精神创伤 50</a>
  946. <a href="javascript:void(0)" class="halo_item">铁甲尖刺 50</a>
  947. <a href="javascript:void(0)" class="halo_item">忍无可忍 50</a>
  948. <a href="javascript:void(0)" class="halo_item">热血战魂 50</a>
  949. <a href="javascript:void(0)" class="halo_item">点到为止 50</a>
  950. <div></div>
  951. <a href="javascript:void(0)" class="halo_item">沸血之志 100</a>
  952. <a href="javascript:void(0)" class="halo_item">波澜不惊 100</a>
  953. <a href="javascript:void(0)" class="halo_item">飓风之力 100</a>
  954. <a href="javascript:void(0)" class="halo_item">红蓝双刺 100</a>
  955. <a href="javascript:void(0)" class="halo_item">荧光护盾 100</a>
  956. <a href="javascript:void(0)" class="halo_item">后发制人 100</a>`;
  957. function selector_halo() {
  958. if ($(this).css('background-color') != 'rgb(135, 206, 250)') {
  959. $(this).css('background-color', 'rgb(135, 206, 250)');
  960. } else {
  961. $(this).css('background-color', 'rgb(255, 255, 255)');
  962. }
  963. }
  964. $('.halo_item').each(function(i, e) {
  965. $(e).on('click', selector_halo);
  966. if (bind_info != null && bind_info[4].split(',').indexOf($(e).text().split(' ')[0]) != -1) {
  967. $(e).css('background-color', 'rgb(135, 206, 250)');
  968. }
  969. });
  970. document.getElementById('load_tip').innerText = '';
  971. }
  972. });
  973. unsafeWindow.quit = function() {
  974. document.getElementById("popup").style.display = "none";
  975. equRequest.abort();
  976. haloRequest.abort();
  977. document.getElementById("popup").innerHTML = initHTML;
  978. };
  979. unsafeWindow.unbind = function() {
  980. let ud = getUserData();
  981. if (ud.dataBind[roleId] != null) {
  982. delete ud.dataBind[roleId];
  983. }
  984. setUserData(ud);
  985. };
  986. //绑定
  987. function hidePopup() {
  988. let equ = new Array();
  989. let halo = new Array();
  990. let sum = 0;
  991. $(".equipment_item").each(function(i, e) {
  992. if ($(e).attr("style") != null && $(e).css("background-color") != "rgb(255, 255, 255)") {
  993. equ.push(e.innerText.split(' '));
  994. }
  995. });
  996. $(".halo_item").each(function(i, e) {
  997. if ($(e).attr("style") != null && $(e).css("background-color") != "rgb(255, 255, 255)") {
  998. let ee = e.innerText.split(' ');
  999. sum += parseInt(ee[1]);
  1000. halo.push(ee[0]);
  1001. }
  1002. });
  1003. let h = parseInt(localStorage.getItem('halo_max'));
  1004. if (equ.length == 4 && sum <= h && halo.length <= parseInt(role.match(/[0-9]技/).slice(0, 1))) {
  1005. for (let i = 0; i < 4; i++) {
  1006. equ[i] = equ[i].slice(0, 6)
  1007. let name = equ[i][0];
  1008. name = eqToAbbr(name);
  1009. equ[i][0] = name;
  1010. equ[i][1] = equ[i][1].substr(2);
  1011. for (let j = 2; j < 6; j++) {
  1012. equ[i][j] = equ[i][j].slice(0, -1)
  1013. }
  1014. console.log(equ[i]);
  1015. }
  1016. let bind_info = new Array(equ[0], equ[1], equ[2], equ[3], halo);
  1017. let ud = getUserData();
  1018. ud.dataBind[roleId] = bind_info.join('|');
  1019. setUserData(ud);
  1020. console.log(localStorage);
  1021. document.getElementById('popup').innerHTML = initHTML;
  1022. document.getElementById('popup').style.display = 'none';
  1023. } else {
  1024. alert('有装备未选或天赋错误');
  1025. }
  1026. }
  1027. document.getElementById('bind').addEventListener('click', hidePopup, false);
  1028. document.getElementById('popup').style.display = 'flex';
  1029. };
  1030. function addBindBtn() {
  1031. let col6 = document.querySelector('#backpacks > div:nth-child(1) > div.col-md-6');
  1032. let btng = document.createElement('div');
  1033. btng.className = 'btn-group';
  1034. col6.insertBefore(btng, col6.children[2]);
  1035. let s0 = document.createElement('span');
  1036. s0.setAttribute('class', 'fyg_lh30');
  1037. s0.innerHTML = '<a href="###" style="color:#F00" onclick="showPopup(this)"> 绑定装备&光环 </a>'
  1038. btng.appendChild(s0);
  1039. let s1 = document.createElement('span');
  1040. s1.setAttribute('class', 'fyg_lh30');
  1041. s1.innerHTML = '<a href="###" style="color:#00FF" onclick="equipOnekey(this)"> 一键装备 </a>'
  1042. btng.appendChild(s1);
  1043. let p = document.getElementsByClassName('panel panel-primary')[1];
  1044. if (p.lastChild.id != 'cardpage_pop') {
  1045. p.appendChild(cardPagePop);
  1046. }
  1047. }
  1048. let waitForHomePage = setInterval(() => {
  1049. let col6 = document.querySelector('#backpacks > div:nth-child(1) > div.col-md-6');
  1050. if (col6 != null && col6.children[1].innerText.includes('卡片') && col6.children.length == 5) {
  1051. clearInterval(waitForHomePage);
  1052. addBindBtn();
  1053. }
  1054. }, 100);
  1055. let observer = new MutationObserver((mutationsList, observer) => {
  1056. let page = document.getElementsByClassName('nav nav-secondary nav-justified')[0].children;
  1057. let index = 0;
  1058. for (let i = 0; i < 4; i++) {
  1059. if (page[i].className == 'active') {
  1060. index = i;
  1061. }
  1062. }
  1063. switch (index) {
  1064. case 0:
  1065. $('.pop_main').hide();
  1066. btnc1.onclick = () => {
  1067. $('.pop_main').show()
  1068. $('.pop_con').css({ 'top': 0, 'opacity': 0 })
  1069. $('.pop_con').animate({ 'top': '50%', 'opacity': 1 })
  1070. try {
  1071. let bag = [].slice.call(document.getElementById('backpacks').children[0].children[1].children)
  1072. .concat([].slice.call(document.getElementById('backpacks').children[1].children[1].children));
  1073. let bagdata = new Array();
  1074. let equip = document.getElementsByClassName('fyg_tc')[3];
  1075. let data = new Array();
  1076. if (bag[bag.length - 1].className.split(' ')[2] != 'fyg_mp3') {
  1077. bag = bag.slice(0, -1);
  1078. }
  1079. //console.log(bag)
  1080. bagdata = getEquipmentInfo(bag);
  1081. data = getEquipmentInfo(equip.children);
  1082. bagdata.sort((e1, e2) => {
  1083. return sortdict[e1[0]] - sortdict[e2[0]];
  1084. });
  1085. //console.log(bagdata);
  1086. d.innerHTML = `<div class="pop_main">
  1087. <div class="pop_con">
  1088. <div class="pop_text">/</div>
  1089. <div class="pop_text">/</div>
  1090. <div class="pop_text">/</div>
  1091. <div class="pop_text">/</div>
  1092. <div class="pop_text" style="color:red">Bag:</div>
  1093. ${new Array(bagdata.length + 1).join('<div class="pop_text">/</div>')}
  1094. <div class="pop_text" style="color:red">Amulet:</div>
  1095. <div class="pop_text">/</div>
  1096. <a href="#">×</a>
  1097. </div>
  1098. </div>`;
  1099. $('.pop_con a').click(() => {
  1100. $('.pop_con').animate({ 'top': 0, 'opacity': 0 }, () => {
  1101. $('.pop_main').hide()
  1102. })
  1103. })
  1104. $('.pop_main').show()
  1105. $('.pop_con').css({ 'top': 0, 'opacity': 0 })
  1106. $('.pop_con').animate({ 'top': '50%', 'opacity': 1 })
  1107. let text = $('.pop_text');
  1108. text[0].innerText = `${data[0].slice(0, -1).join(' ')}`;
  1109. text[1].innerText = `${data[1].slice(0, -1).join(' ')}`;
  1110. text[2].innerText = `${data[2].slice(0, -1).join(' ')}`;
  1111. text[3].innerText = `${data[3].slice(0, -1).join(' ')}`;
  1112. for (let i = 0; i < bagdata.length; i++) {
  1113. text[5 + i].innerText = `${bagdata[i].slice(0, -1).join(' ')}`;
  1114. }
  1115. let amulet = document.getElementById('backpacks').lastChild.children[1].innerText.match(/\+[0-9]+/g);
  1116. let amuletAbbr = new Array('STR', 'AGI', 'INT', 'VIT', 'SPR', 'MND', 'PATK', 'MATK', 'SPD', 'REC', 'HP', 'SLD', 'LCH', 'RFL', 'CRT', 'SKL', 'PDEF', 'MDEF');
  1117. for (let i = amulet.length - 1; i >= 0; i--) {
  1118. if (amulet[i][1] == '0') {
  1119. amulet.splice(i, 1);
  1120. } else {
  1121. amulet[i] = amuletAbbr[i] + amulet[i];
  1122. }
  1123. }
  1124. text[6 + bagdata.length].innerText = `AMULET ${amulet.join(' ').replace(/\+/g, ' ')} ENDAMULET`;
  1125. } catch (err) { console.log(err); }
  1126. }
  1127. try {
  1128. if (!((mutationsList[0].addedNodes[0].className != null && mutationsList[0].addedNodes[0].className.split(' ')[0] == 'popover') ||
  1129. (mutationsList[0].removedNodes[0].className != null && mutationsList[0].removedNodes[0].className.split(' ')[0] == 'popover'))) {
  1130. addCollapse();
  1131. }
  1132. } catch (err) {}
  1133. break;
  1134. case 1:
  1135. $('.pop_main').hide();
  1136. btnc1.onclick = () => { console.log('Click None'); };
  1137. var observerCard = new MutationObserver(() => {
  1138. observerCard.disconnect();
  1139. console.log('Backpacks Changed');
  1140. try {
  1141. let col6 = document.querySelector('#backpacks > div:nth-child(1) > div.col-md-6');
  1142. if (col6.children[1].innerText.includes('卡片') && col6.children.length == 5) {
  1143. btnc1.onclick = () => {
  1144. try {
  1145. d.innerHTML = '<div class="pop_main">\n<div class="pop_con">\n<div class="pop_text">0</div>\n<div class="pop_text">0</div>\n<a href="#">×</a>\n</div>\n<div class="mask"></div>\n</div>';
  1146. $('.pop_con a').click(() => {
  1147. $('.pop_con').animate({ 'top': 0, 'opacity': 0 }, () => {
  1148. $('.pop_main').hide()
  1149. })
  1150. })
  1151. $('.pop_main').show()
  1152. $('.pop_con').css({ 'top': 0, 'opacity': 0 })
  1153. $('.pop_con').animate({ 'top': '50%', 'opacity': 1 })
  1154. let text = $('.pop_text');
  1155. let cardName = document.querySelector("#backpacks > div:nth-child(1) > div.col-md-4 > div > div.row > div.col-xs-2.fyg_f18.fyg_tr").innerText;
  1156. let cardInfo = document.querySelector("#backpacks > div:nth-child(1) > div.col-md-4 > div > div.fyg_tl").innerText.match(/[0-9]+/g);
  1157. text[1].innerText = `${document.getElementById('sjll').getAttribute('value')} ${document.getElementById('sjmj').getAttribute('value')} ${document.getElementById('sjzl').getAttribute('value')} ${document.getElementById('sjtp').getAttribute('value')} ${document.getElementById('sjjs').getAttribute('value')} ${document.getElementById('sjyz').getAttribute('value')}`;
  1158. switch (cardName) {
  1159. case '琳':
  1160. text[0].innerText = `LIN ${cardInfo[0]} ${cardInfo[1]} ${cardInfo[2]}`;
  1161. break;
  1162. case '艾':
  1163. text[0].innerText = `AI ${cardInfo[0]} ${cardInfo[1]} ${cardInfo[2]}`;
  1164. break;
  1165. case '默':
  1166. text[0].innerText = `MO ${cardInfo[0]} ${cardInfo[1]} ${cardInfo[2]}`;
  1167. break;
  1168. case '梦':
  1169. text[0].innerText = `MENG ${cardInfo[0]} ${cardInfo[1]} ${cardInfo[2]}`;
  1170. break;
  1171. case '薇':
  1172. text[0].innerText = `WEI ${cardInfo[0]} ${cardInfo[1]} ${cardInfo[2]}`;
  1173. break;
  1174. case '伊':
  1175. text[0].innerText = `YI ${cardInfo[0]} ${cardInfo[1]} ${cardInfo[2]}`;
  1176. break;
  1177. }
  1178. } catch (err) { console.log(err); }
  1179. }
  1180. addBindBtn();
  1181. }
  1182. } catch (err) {}
  1183. }, 1000);
  1184. var waitForCard = setInterval(() => {
  1185. timeoutWaitForCard++;
  1186. //console.log(timeoutWaitForCard);
  1187. if (timeoutWaitForCard > 100) {
  1188. timeoutWaitForCard = 0;
  1189. console.log('Timeout WaitForCard');
  1190. clearInterval(waitForCard);
  1191. }
  1192. if (document.getElementsByClassName('btn btn-primary btn-group dropup').length > 0) {
  1193. timeoutWaitForCard = 0;
  1194. clearInterval(waitForCard);
  1195. console.log('WaitForCard');
  1196. let roleCards = document.getElementById('backpacks').children;
  1197. let roleKeys = new Array();
  1198. if (roleCards[0].className.indexOf('btn') != -1) { //清除已不存在的卡片的绑定信息
  1199. for (let i = 0; i < roleCards.length; i++) {
  1200. roleKeys.push(roleCards[i].getAttribute('onclick').match(/[0-9]+/)[0]);
  1201. }
  1202. let udata = getUserData();
  1203. console.log(roleKeys);
  1204. for (let key in udata.dataBind) {
  1205. console.log(key);
  1206. if (roleKeys.indexOf(key) == -1) {
  1207. delete udata.dataBind[key];
  1208. }
  1209. }
  1210. setUserData(udata);
  1211. }
  1212. observerCard.observe(document.getElementById('backpacks'), { childList: true });
  1213. }
  1214. }, 100);
  1215. break;
  1216. case 2:
  1217. $('.pop_main').hide();
  1218. btnc1.onclick = () => {
  1219. try {
  1220. d.innerHTML = '<div class="pop_main">\n<div class="pop_con">\n<div class="pop_text">0</div>\n<a href="#">×</a>\n</div>\n<div class="mask"></div>\n</div>';
  1221. $('.pop_con a').click(() => {
  1222. $('.pop_con').animate({ 'top': 0, 'opacity': 0 }, () => {
  1223. $('.pop_main').hide()
  1224. })
  1225. })
  1226. $('.pop_main').show()
  1227. $('.pop_con').css({ 'top': 0, 'opacity': 0 })
  1228. $('.pop_con').animate({ 'top': '50%', 'opacity': 1 })
  1229. let text = $('.pop_text');
  1230. let aura = document.getElementsByClassName('btn btn-primary');
  1231. let data = new Array();
  1232. data.push(aura.length);
  1233. for (let i = 0; i < aura.length; i++) {
  1234. let t = aura[i].innerText;
  1235. t = t.trim();
  1236. switch (t[0]) {
  1237. case '启':
  1238. switch (t[3]) {
  1239. case '誓':
  1240. data.push('SHI');
  1241. break;
  1242. case '心':
  1243. data.push('XIN');
  1244. break;
  1245. case '风':
  1246. data.push('FENG');
  1247. break;
  1248. }
  1249. break;
  1250. case '破':
  1251. switch (t[1]) {
  1252. case '壁':
  1253. data.push('BI');
  1254. break;
  1255. case '魔':
  1256. data.push('MO');
  1257. break;
  1258. }
  1259. break;
  1260. case '复':
  1261. data.push('DUN');
  1262. break;
  1263. case '鲜':
  1264. data.push('XUE');
  1265. break;
  1266. case '削':
  1267. data.push('XIAO');
  1268. break;
  1269. case '伤':
  1270. data.push('SHANG');
  1271. break;
  1272. case '精':
  1273. data.push('SHEN');
  1274. break;
  1275. case '铁':
  1276. data.push('CI');
  1277. break;
  1278. case '忍':
  1279. data.push('REN');
  1280. break;
  1281. case '热':
  1282. data.push('RE');
  1283. break;
  1284. case '点':
  1285. data.push('DIAN');
  1286. break;
  1287. case '沸':
  1288. data.push('FEI');
  1289. break;
  1290. case '波':
  1291. data.push('BO');
  1292. break;
  1293. case '飓':
  1294. data.push('JU');
  1295. break;
  1296. case '红':
  1297. data.push('####');
  1298. break;
  1299. case '荧':
  1300. data.push('JUE');
  1301. break;
  1302. case '后':
  1303. data.push('HOU');
  1304. break;
  1305. default:
  1306. data.push('NONE');
  1307. break;
  1308. }
  1309. }
  1310. text[0].innerText = `${data.join(' ')}`;
  1311. //$('.pop_main').hide();
  1312. } catch (err) {
  1313. console.log(err);
  1314. }
  1315. }
  1316. break;
  1317. case 3:
  1318. $('.pop_main').hide();
  1319. btnc1.onclick = () => {}
  1320. break;
  1321. }
  1322. });
  1323. observer.observe(document.getElementById('backpacks'), { childList: true, characterData: true });
  1324. }
  1325. }, 500);
  1326. let p = document.getElementsByClassName('panel panel-primary')[1];
  1327. p.insertBefore(btnc1, p.children[0]);
  1328. let d = document.createElement('div');
  1329. d.id = 'alert';
  1330. d.innerHTML = '<div class="pop_main">\n<div class="pop_con">\n<div class="pop_text">0</div>\n<a href="#">×</a>\n</div>\n<div class="mask"></div>\n</div>';
  1331. //'<div class="pop_main">\n<div class="pop_con">\n<div class="pop_text">0</div>\n<div class="pop_text">0</div>\n<div class="pop_text">0</div>\n<div class="pop_text">0</div>\n<div class="pop_text">Bag:</div>\n<div class="pop_text">0</div>\n<div class="pop_text">0</div>\n<div class="pop_text">0</div>\n<div class="pop_text">0</div>\n<div class="pop_text">0</div>\n<div class="pop_text">0</div>\n<div class="pop_text">0</div>\n<div class="pop_text">0</div>\n<div class="pop_text">0</div>\n<div class="pop_text">0</div>\n<div class="pop_text">0</div>\n<div class="pop_text">0</div>\n<div class="pop_text">0</div>\n<div class="pop_text">0</div>\n<a href="#">×</a>\n</div>\n<div class="mask"></div>\n</div>';
  1332. p.insertBefore(d, p.children[0]);
  1333. $('.pop_main').hide();
  1334. $('.pop_con a').click(() => {
  1335. $('.pop_con').animate({ 'top': 0, 'opacity': 0 }, () => {
  1336. $('.pop_main').hide()
  1337. })
  1338. })
  1339. } else if (window.location.pathname == '/fyg_beach.php') {
  1340. function insertAfter(newEl, targetEl) {
  1341. var parentEl = targetEl.parentNode;
  1342. if (parentEl.lastChild == targetEl) {
  1343. parentEl.appendChild(newEl);
  1344. } else {
  1345. parentEl.insertBefore(newEl, targetEl.nextSibling);
  1346. }
  1347. }
  1348. let beachCheck = document.createElement('form');
  1349. beachCheck.innerHTML = `<div class="form-group form-check">
  1350. <label class="form-check-label" for="beachcheck">屏蔽垃圾装备</label>
  1351. <input type="checkbox" class="form-check-input" id="beachcheck">
  1352. <label>分析中..</label>
  1353. <button button type="button" onclick="siftSetting()">筛选设置</button>
  1354. </div>`;
  1355. document.getElementsByClassName('panel panel-primary')[2].insertBefore(beachCheck, document.getElementsByClassName('panel panel-primary')[2].children[1]);
  1356. document.querySelector("#beachcheck").addEventListener('click', () => { localStorage.setItem('beachcheck', document.querySelector("#beachcheck").checked) }, false);
  1357. document.querySelector("#beachcheck").checked = (localStorage.getItem('beachcheck') == 'true');
  1358. let popStyle = `<style>
  1359. .popup {
  1360. width: 100vw;
  1361. height: 100vh;
  1362. background-color: rgba(0, 0, 0, .5);
  1363. position: fixed;
  1364. left: 0;
  1365. top: 0;
  1366. bottom: 0;
  1367. right: 0;
  1368. z-index: 9999;
  1369. display: none;
  1370. justify-content: center;
  1371. align-items: center;
  1372. }
  1373. .popup-content {
  1374. width: 400px;
  1375. height: 200px;
  1376. background-color: #fff;
  1377. box-sizing: border-box;
  1378. padding: 10px 30px;
  1379. color: black;
  1380. }
  1381. .topline {
  1382. width: 100%;
  1383. border-bottom: 1px solid black;
  1384. }
  1385. </style>`;
  1386. let divSetting = document.createElement('div');
  1387. divSetting.setAttribute('id', 'siftpage_pop');
  1388. let eqs = new Array(fullName.slice(0, sortdict.BOUND_0), fullName.slice(sortdict.BOUND_0 + 1, sortdict.BOUND_1), fullName.slice(sortdict.BOUND_1 + 1, sortdict.BOUND_2), fullName.slice(sortdict.BOUND_2 + 1));
  1389. for (let i = 0; i < 4; i++) {
  1390. for (let j = 0; j < eqs[i].length; j++) {
  1391. eqs[i][j] = `
  1392. <span class="dropdown dropdown-hover">
  1393. <button class="btn" type="button" id="btn${eqToAbbr(eqs[i][j])}" data-toggle="dropdown">${eqs[i][j]} <span class="caret"></span></button>
  1394. <ul class="dropdown-menu">
  1395. <li><a href="javascript:void(0)" class="attri_item">属性1</a></li>
  1396. <li><a href="javascript:void(0)" class="attri_item">属性2</a></li>
  1397. <li><a href="javascript:void(0)" class="attri_item">属性3</a></li>
  1398. <li><a href="javascript:void(0)" class="attri_item">属性4</a></li>
  1399. </ul>
  1400. </span>
  1401. <input type="checkbox" class="form-check-input siftsetting" id="${eqToAbbr(eqs[i][j])}">&nbsp;`;
  1402. }
  1403. }
  1404. let initSettingHTML = `<div class="popup-content">
  1405. <div class="topline">
  1406. <p></p>
  1407. <form><div class="form-group form-check">
  1408. ${eqs[0]}
  1409. </div></form>
  1410. </div>
  1411. <div class="topline">
  1412. <p></p>
  1413. <form><div class="form-group form-check">
  1414. ${eqs[1]}
  1415. </div></form>
  1416. </div>
  1417. <div class="topline">
  1418. <p></p>
  1419. <form><div class="form-group form-check">
  1420. ${eqs[2]}
  1421. </div></form>
  1422. </div>
  1423. <div class="topline">
  1424. <p></p>
  1425. <form><div class="form-group form-check">
  1426. ${eqs[3]}
  1427. </div></form>
  1428. </div>
  1429. <p></p>
  1430. <p style="color:red">勾选的装备不会被拾取,有神秘除外</p>
  1431. <p style="color:red">勾选的属性不会被对比,即此条属性大于已有装备也不会被拾取,即忽略无用属性</p>
  1432. <button type="button" onclick="exitSift()">完成</button>
  1433. </div>`;
  1434. divSetting.innerHTML = `${popStyle}
  1435. <div class="popup" id="siftpop">
  1436. ${initSettingHTML}
  1437. </div>`;
  1438. unsafeWindow.siftSetting = function() {
  1439. $('.popup-content').height(Math.min(fullName.length, 19) * 10 + 200);
  1440. $('.popup-content').width(700);
  1441. $('.popup-content').css('overflow', 'scroll');
  1442. function selector_sift() {
  1443. //console.log($(this).text()[0]);
  1444. if ($(this).text()[0] != '✔') {
  1445. $(this).text('✔' + $(this).text());
  1446. } else {
  1447. $(this).text($(this).text().slice(1));
  1448. }
  1449. }
  1450. $('.attri_item').each(function(i, e) {
  1451. $(e).on('click', selector_sift);
  1452. });
  1453. $('.attri_item').hover(
  1454. function() {
  1455. $(this).css({ 'color': '#fff', 'background-color': '#3280fc' });
  1456. },
  1457. function() {
  1458. $(this).css({ 'color': '#000', 'background-color': '#fff' });
  1459. });
  1460. let eqchecks = document.getElementsByClassName('form-check-input siftsetting');
  1461. let ud = getUserData();
  1462. for (let i = 0; i < eqchecks.length; i++) {
  1463. if (ud.dataBeachSift == null) {
  1464. ud.dataBeachSift = { "PLATE": "true,false,false,false,false", "LEATHER": "true,false,false,false,false", "CLOTH": "true,false,false,false,false" };
  1465. setUserData(ud);
  1466. } else {
  1467. if (ud.dataBeachSift[eqchecks[i].id] != null) {
  1468. let s = ud.dataBeachSift[eqchecks[i].id].split(',');
  1469. eqchecks[i].checked = (s[0] == 'true');
  1470. let attri = eqchecks[i].previousSibling.previousSibling.children[1].children;
  1471. for (let i = 0; i < attri.length; i++) {
  1472. if (s[1 + i] == 'true') {
  1473. attri[i].children[0].innerText = '✔' + attri[i].children[0].innerText;
  1474. }
  1475. }
  1476. }
  1477. }
  1478. }
  1479. document.getElementById('siftpop').style.display = 'flex';
  1480. }
  1481. unsafeWindow.exitSift = function() {
  1482. let eqchecks = document.getElementsByClassName('form-check-input siftsetting');
  1483. let ud = getUserData();
  1484. for (let i = 0; i < eqchecks.length; i++) {
  1485. let checklist = eqchecks[i].previousSibling.previousSibling.children[1].innerText.split('\n')
  1486. let checkres = new Array(eqchecks[i].checked, false, false, false, false);
  1487. for (let i = 0, j = 1; i < checklist.length; i++) {
  1488. if (checklist[i].replace(/\s+/g, '').length > 0) {
  1489. if (checklist[i].replace(/\s+/g, '')[0] == '✔') {
  1490. checkres[j] = true;
  1491. j++;
  1492. } else if (checklist[i].replace(/\s+/g, '')[0] == '属') {
  1493. checkres[j] = false;
  1494. j++;
  1495. }
  1496. }
  1497. }
  1498. ud.dataBeachSift[eqchecks[i].id] = `${checkres}`;
  1499. }
  1500. setUserData(ud);
  1501. document.getElementById('siftpop').style.display = 'none';
  1502. document.getElementById('siftpop').innerHTML = initSettingHTML;
  1503. }
  1504. let p2 = document.getElementsByClassName('panel panel-primary')[2];
  1505. if (p2.lastChild.id != 'siftpage_pop') {
  1506. p2.appendChild(divSetting);
  1507. }
  1508. let divAmulet = document.createElement('div');
  1509. divAmulet.setAttribute('id', 'amuletpage_pop');
  1510. let initAmuletHTML = `<div class="popup-content">
  1511. <div class="topline">
  1512. <p></p>
  1513. </div>
  1514. <button type="button" onclick="exitAmulet()">取消</button>
  1515. <button type="button" disabled="disabled" onclick="goAmulet()">继续</button>
  1516. <span>请稍候..</span>
  1517. </div>`;
  1518. divAmulet.innerHTML = `${popStyle}
  1519. <div class="popup" id="amuletpop">
  1520. ${initAmuletHTML}
  1521. </div>`;
  1522. let toAmuletExit = false;
  1523. let continueAmulet = true;
  1524. unsafeWindow.exitAmulet = function() {
  1525. toAmuletExit = true;
  1526. document.getElementById('amuletpop').style.display = 'none';
  1527. document.getElementById('amuletpop').innerHTML = initAmuletHTML;
  1528. }
  1529. unsafeWindow.goAmulet = function() {
  1530. continueAmulet = true;
  1531. }
  1532. let p1 = document.getElementsByClassName('panel panel-primary')[1];
  1533. if (p1.lastChild.id != 'amuletpage_pop') {
  1534. p1.appendChild(divAmulet);
  1535. }
  1536. let batbtns = document.getElementsByClassName('panel-body')[1].children[0];
  1537. let toAmuletBtn = document.createElement('button');
  1538. toAmuletBtn.className = 'btn btn-danger';
  1539. toAmuletBtn.innerText = '批量沙滩转护符(背包至少留一个空位)';
  1540. let _amuletsID = new Array();
  1541. let _equipmentsID = new Array();
  1542. let _pickID = new Array();
  1543. let _safeid = null;
  1544. let _next = -1;
  1545. let waitForContinue = null;
  1546. toAmuletBtn.onclick = () => {
  1547. _amuletsID = new Array();
  1548. _equipmentsID = new Array();
  1549. _pickID = new Array();
  1550. _safeid = null;
  1551. _next = -1;
  1552. waitForContinue = null;
  1553. toAmuletExit = false;
  1554. continueAmulet = true;
  1555. let bagItems = document.querySelector("#backpacks").children;
  1556. if (bagItems != null && bagItems.length > 2 && confirm('确定要把沙滩所有装备转换成护符吗?')) {
  1557. for (let i = 0; i < bagItems.length; i++) {
  1558. if (bagItems[i].className.split(' ').length == 3 && bagItems[i].innerText.indexOf('+') != -1) {
  1559. _amuletsID.push(bagItems[i].getAttribute('onclick').match(/'[0-9]+'/)[0].slice(1, -1));
  1560. } else if (bagItems[i].className.split(' ').length == 3 && bagItems[i].innerText.indexOf('+') == -1) {
  1561. _equipmentsID.push(bagItems[i].getAttribute('onclick').match(/'[0-9]+'/)[0].slice(1, -1));
  1562. }
  1563. }
  1564. let btns = document.getElementsByClassName('fyg_mp3');
  1565. for (let i = 0; i < btns.length; i++) {
  1566. if (btns[i].parentNode.id == 'beachall' && btns[i].className.indexOf('btn') != -1) {
  1567. let rare = btns[i].className.split(' ')[1];
  1568. if (rare != 'fyg_colpz01bg' && rare != 'fyg_colpz02bg') {
  1569. _pickID.push(btns[i].getAttribute('onclick').match(/\([0-9]+\)/)[0].slice(1, -1))
  1570. }
  1571. }
  1572. }
  1573. _safeid = getPostData(/sttz\(\)\{[\s\S]*\}/m, /data: ".*"/).slice(12, -1);
  1574. console.log(_equipmentsID);
  1575. console.log(_amuletsID);
  1576. console.log(_pickID);
  1577. console.log(_safeid);
  1578. let amuletBlock = document.getElementById('amuletpop').children[0].children[0];
  1579. let btnExit = document.getElementById('amuletpop').children[0].children[1];
  1580. let btnContinue = document.getElementById('amuletpop').children[0].children[2];
  1581. let infospan = document.getElementById('amuletpop').children[0].children[3];
  1582. function showAmuletPop() {
  1583. $('.popup-content').height(Math.min(_pickID.length, 19) * 10 + 200);
  1584. $('.popup-content').width(700);
  1585. $('.popup-content').css('overflow', 'scroll');
  1586. document.getElementById('amuletpop').style.display = 'flex';
  1587. }
  1588. unsafeWindow.destroyAmulet = (e) => {
  1589. let btn = e.parentNode.parentNode.parentNode;
  1590. let id = btn.getAttribute('id');
  1591. let pirlam_data = `c=9&id=${id}&yz=124&${_safeid}`;
  1592. GM_xmlhttpRequest({ //pirl(id)
  1593. method: 'POST',
  1594. url: `https://www.guguzhen.com/fyg_click.php`,
  1595. headers: headersPOST,
  1596. data: pirlam_data,
  1597. onload: response => {
  1598. console.log(response.responseText.indexOf('水'));
  1599. if (response.responseText.indexOf('水') != -1) {
  1600. GM_xmlhttpRequest({ //read
  1601. method: 'POST',
  1602. url: `https://www.guguzhen.com/fyg_read.php`,
  1603. headers: headersPOST,
  1604. data: `f=2`,
  1605. onload: response => {
  1606. _amuletsID.splice(_amuletsID.indexOf(id), 1);
  1607. btn.parentNode.removeChild(btn);
  1608. console.log('core +1');
  1609. }
  1610. });
  1611. } else {
  1612. console.log(`except at destroy: ${response.responseText}`);
  1613. }
  1614. }
  1615. });
  1616. }
  1617. unsafeWindow.storeAmulet = (e) => {
  1618. let btn = e.parentNode.parentNode.parentNode;
  1619. let id = btn.getAttribute('id');
  1620. let pirlam_data = `c=21&id=${id}&${_safeid}`;
  1621. console.log(pirlam_data);
  1622. GM_xmlhttpRequest({ //puti(id)
  1623. method: 'POST',
  1624. url: `https://www.guguzhen.com/fyg_click.php`,
  1625. headers: headersPOST,
  1626. data: pirlam_data,
  1627. onload: response => {
  1628. if (response.responseText == 'ok') {
  1629. GM_xmlhttpRequest({ //read
  1630. method: 'POST',
  1631. url: `https://www.guguzhen.com/fyg_read.php`,
  1632. headers: headersPOST,
  1633. data: `f=2`,
  1634. onload: response => {
  1635. _amuletsID.splice(_amuletsID.indexOf(id), 1);
  1636. btn.parentNode.removeChild(btn);
  1637. }
  1638. });
  1639. } else {
  1640. console.log(`except at store: ${response.responseText}`);
  1641. alert('仓库已满');
  1642. }
  1643. }
  1644. });
  1645. }
  1646. showAmuletPop();
  1647. function toAmulet(count, equipmentsID, amuletsID, pickID, safeid) {
  1648. infospan.innerText = '请稍候..';
  1649. btnContinue.disabled = 'disabled';
  1650. if (count == 0) {
  1651. infospan.innerText = '';
  1652. btnExit.innerText = '完成';
  1653. return;
  1654. }
  1655. if (toAmuletExit) {
  1656. console.log('toAmuletExit');
  1657. return;
  1658. }
  1659. let stpick_data = `c=1&id=${pickID[count-1]}&${safeid}`;
  1660. GM_xmlhttpRequest({ //pick equipment
  1661. method: 'POST',
  1662. url: `https://www.guguzhen.com/fyg_click.php`,
  1663. headers: headersPOST,
  1664. data: stpick_data,
  1665. onload: response => {
  1666. if (toAmuletExit) {
  1667. console.log('toAmuletExit');
  1668. return;
  1669. }
  1670. if (response.responseText != 'ok') {
  1671. console.log(`fullbag: ${response.responseText}`);
  1672. infospan.innerText = '背包已满,请处理后继续';
  1673. btnContinue.disabled = '';
  1674. continueAmulet = false;
  1675. _next = count;
  1676. _equipmentsID = equipmentsID;
  1677. _amuletsID = amuletsID;
  1678. _pickID = pickID;
  1679. _safeid = safeid;
  1680. waitForContinue = setInterval(() => {
  1681. // $('.amulet_menu').bind('click', () => {
  1682. // let id = $(this).parent().parent().parent().attr('id');
  1683. // console.log(`splice: ${id}`);
  1684. // _amuletsID.splice(_amuletsID.indexOf(id), 1);
  1685. // });
  1686. if (continueAmulet) {
  1687. clearInterval(waitForContinue);
  1688. toAmulet(_next, _equipmentsID, _amuletsID, _pickID, _safeid);
  1689. } else if (toAmuletExit) {
  1690. console.log('toAmuletExit');
  1691. clearInterval(waitForContinue);
  1692. }
  1693. }, 200);
  1694. //alert('背包已满,请处理后继续');
  1695. return;
  1696. }
  1697. GM_xmlhttpRequest({ //find eqid
  1698. method: 'POST',
  1699. url: `https://www.guguzhen.com/fyg_read.php`,
  1700. headers: headersPOST,
  1701. data: 'f=2',
  1702. onload: response => {
  1703. if (toAmuletExit) {
  1704. console.log('toAmuletExit');
  1705. return;
  1706. }
  1707. let eqid = null;
  1708. let bagdiv = document.createElement('div');
  1709. bagdiv.innerHTML = response.responseText;
  1710. for (let i = 0; i < bagdiv.children.length; i++) {
  1711. if (bagdiv.children[i].className.split(' ').length == 3 && bagdiv.children[i].innerText.indexOf('+') == -1) {
  1712. eqid = bagdiv.children[i].getAttribute('onclick').match(/'[0-9]+'/)[0].slice(1, -1);
  1713. if (equipmentsID.length == 0 || equipmentsID.indexOf(eqid) == -1) {
  1714. break;
  1715. } else {
  1716. eqid = null;
  1717. }
  1718. }
  1719. }
  1720. console.log(`eqid: ${eqid}`);
  1721. let pirleq_data = `c=9&id=${eqid}&yz=124&${safeid}`;
  1722. GM_xmlhttpRequest({ //pirl(id)
  1723. method: 'POST',
  1724. url: `https://www.guguzhen.com/fyg_click.php`,
  1725. headers: headersPOST,
  1726. data: pirleq_data,
  1727. onload: response => {
  1728. console.log(response.responseText);
  1729. if (toAmuletExit) {
  1730. console.log('toAmuletExit');
  1731. return;
  1732. }
  1733. GM_xmlhttpRequest({ //find amid
  1734. method: 'POST',
  1735. url: `https://www.guguzhen.com/fyg_read.php`,
  1736. headers: headersPOST,
  1737. data: 'f=2',
  1738. onload: response => {
  1739. if (toAmuletExit) {
  1740. console.log('toAmuletExit');
  1741. return;
  1742. }
  1743. let amid = null;
  1744. let bagdiv = document.createElement('div');
  1745. bagdiv.innerHTML = response.responseText;
  1746. for (let i = 0; i < bagdiv.children.length; i++) {
  1747. if (bagdiv.children[i].className.split(' ').length == 3 && bagdiv.children[i].innerText.indexOf('+') != -1) {
  1748. amid = bagdiv.children[i].getAttribute('onclick').match(/'[0-9]+'/)[0].slice(1, -1);
  1749. if (amuletsID.length == 0 || amuletsID.indexOf(amid) == -1) {
  1750. console.log(bagdiv.children[i]);
  1751. let btn0 = document.createElement('div');
  1752. btn0.setAttribute('class', 'btn-group');
  1753. btn0.setAttribute('id', amid);
  1754. btn0.innerHTML = `<button type="button" class="btn btn-light dropdown-toggle" data-toggle="dropdown" style="padding: 0px; text-align: left; box-shadow: none; line-height: 90%;">
  1755. <div class="popover-content-show" style="padding: 10px 10px 0px;">${bagdiv.children[i].dataset.content}</div>
  1756. <span class="caret"></span>
  1757. </button>
  1758. <ul class="dropdown-menu" role="menu">
  1759. <li><a class="amulet_menu" href="javascript:void(0);" style="background-color:#FF8C00" onclick="destroyAmulet(this)">销毁</a></li>
  1760. <li><a class="amulet_menu" href="javascript:void(0);" style="background-color:#00CED1" onclick="storeAmulet(this)">入库</a></li>
  1761. </ul>`;
  1762. amuletBlock.appendChild(btn0);
  1763. amuletsID.push(amid);
  1764. break;
  1765. } else {
  1766. amid = null;
  1767. }
  1768. }
  1769. }
  1770. console.log(`amid: ${amid}`);
  1771. toAmulet(count - 1, equipmentsID, amuletsID, pickID, safeid);
  1772. }
  1773. });
  1774. }
  1775. });
  1776. }
  1777. });
  1778. }
  1779. });
  1780. }
  1781. toAmulet(_pickID.length, _equipmentsID, _amuletsID, _pickID, _safeid);
  1782. }
  1783. }
  1784. batbtns.appendChild(toAmuletBtn);
  1785. let equipment = new Array();
  1786. let equipedbtn = null;
  1787. //读取拥有的装备
  1788. GM_xmlhttpRequest({
  1789. method: 'POST',
  1790. url: `https://www.guguzhen.com/fyg_read.php`,
  1791. headers: headersPOST,
  1792. data: 'f=7',
  1793. onload: response => {
  1794. let div0 = readEquipmentDOM(response.responseText);
  1795. for (let i = div0.children.length - 1; i >= 0; i--) {
  1796. if (div0.children[i].className.split(' ').length != 3 || div0.children[i].innerText.indexOf('+') != -1) {
  1797. div0.removeChild(div0.children[i]);
  1798. }
  1799. }
  1800. // console.log(div0);
  1801. equipedbtn = [].slice.call(div0.children);
  1802. let equipbag = getEquipmentInfo(div0.children);
  1803. GM_xmlhttpRequest({
  1804. method: 'POST',
  1805. url: `https://www.guguzhen.com/fyg_read.php`,
  1806. headers: headersPOST,
  1807. data: 'f=9',
  1808. onload: response => {
  1809. document.querySelector(".form-check").children[2].innerText = '';
  1810. let div0 = document.createElement('div');
  1811. div0.innerHTML = response.responseText;
  1812. equipedbtn = equipedbtn.concat([].slice.call(div0.getElementsByClassName('fyg_tc')[3].children));
  1813. equipedbtn.sort(sortEqByName);
  1814. let equiped = getEquipmentInfo(div0.getElementsByClassName('fyg_tc')[3].children);
  1815. equipment = equipbag.concat(equiped);
  1816. if (equipment.length == 0) {
  1817. equipment[0] = -1;
  1818. }
  1819. }
  1820. });
  1821. }
  1822. });
  1823. //分析装备并显示属性
  1824. function pickEquipment(equipment) {
  1825. if (document.querySelector("#beachcheck").checked) {
  1826. //屏蔽鼠标事件
  1827. $('#beachall .fyg_mp3').css('pointer-events', 'none');
  1828. } else {
  1829. $('#beachall .fyg_mp3').css('pointer-events', 'auto');
  1830. }
  1831. if (equipment[0] == -1) return;
  1832. let btns = document.getElementsByClassName('fyg_mp3');
  1833. let udata = getUserData();
  1834. if (udata.dataBeachSift == null) {
  1835. udata.dataBeachSift = { "PLATE": "true,false,false,false,false", "LEATHER": "true,false,false,false,false", "CLOTH": "true,false,false,false,false" };
  1836. setUserData(udata);
  1837. }
  1838. for (let i = 0; i < btns.length; i++) {
  1839. if (btns[i].parentNode.id == 'beachall' && btns[i].className.indexOf('btn') != -1) {
  1840. let isFind = false;
  1841. let isPick = false;
  1842. let sift = new Array(5).fill('false')
  1843. let btninfo = getEquipmentInfo(new Array(btns[i]))[0];
  1844. if (udata.dataBeachSift != null && udata.dataBeachSift[btninfo[0]] != null) {
  1845. sift = udata.dataBeachSift[btninfo[0]].split(',');
  1846. }
  1847. if (btninfo[6] == 1) {
  1848. //神秘必捡
  1849. isPick = true;
  1850. } else if (sift[0] == 'true') {
  1851. //筛选设置不捡
  1852. isPick = false;
  1853. } else {
  1854. for (let j = 0; j < equipment.length; j++) {
  1855. if (equipment[j][0] == btninfo[0]) {
  1856. isFind = true;
  1857. let e1 = new Array(parseInt(equipment[j][1]), parseInt(equipment[j][2]), parseInt(equipment[j][3]), parseInt(equipment[j][4]), parseInt(equipment[j][5]));
  1858. let e2 = new Array(parseInt(btninfo[1]), parseInt(btninfo[2]), parseInt(btninfo[3]), parseInt(btninfo[4]), parseInt(btninfo[5]));
  1859. function product(e1, e2) {
  1860. return e1 * e2;
  1861. }
  1862. function linear(e1, e2, a, b) {
  1863. return (e1 / a + b) * e2;
  1864. }
  1865. let comp = new Array(false, false, false, false);
  1866. switch (btninfo[0]) {
  1867. case 'BLADE':
  1868. comp[0] = linear(e1[0], e1[1], 5, 20) < linear(e2[0], e2[1], 5, 20);
  1869. comp[1] = linear(e1[0], e1[2], 5, 20) < linear(e2[0], e2[2], 5, 20);
  1870. comp[2] = linear(e1[0], e1[3], 20, 10) < linear(e2[0], e2[3], 20, 10);
  1871. comp[3] = linear(e1[0], e1[4], 20, 10) < linear(e2[0], e2[4], 20, 10);
  1872. break;
  1873. case 'STAFF':
  1874. comp[0] = product(e1[0], e1[1]) < product(e2[0], e2[1]);
  1875. comp[1] = product(e1[0], e1[2]) < product(e2[0], e2[2]);
  1876. comp[2] = linear(e1[0], e1[3], 20, 5) < linear(e2[0], e2[3], 20, 5);
  1877. comp[3] = linear(e1[0], e1[4], 15, 10) < linear(e2[0], e2[4], 15, 10);
  1878. break;
  1879. case 'WAND':
  1880. comp[0] = product(e1[0], e1[1]) < product(e2[0], e2[1]);
  1881. comp[1] = product(e1[0], e1[2]) < product(e2[0], e2[2]);
  1882. comp[2] = product(e1[0], e1[3]) < product(e2[0], e2[3]);
  1883. comp[3] = product(e1[0], e1[4]) < product(e2[0], e2[4]);
  1884. break;
  1885. case 'SWORD':
  1886. comp[0] = product(e1[0], e1[1]) < product(e2[0], e2[1]);
  1887. comp[1] = product(e1[0], e1[2]) < product(e2[0], e2[2]);
  1888. comp[2] = product(e1[0], e1[3]) < product(e2[0], e2[3]);
  1889. comp[3] = linear(e1[0], e1[4], 15, 10) < linear(e2[0], e2[4], 15, 10);
  1890. break;
  1891. case 'CLAYMORE':
  1892. comp[0] = product(e1[0], e1[1]) < product(e2[0], e2[1]);
  1893. comp[1] = product(e1[0], e1[2]) < product(e2[0], e2[2]);
  1894. comp[2] = linear(e1[0], e1[3], 5, 30) < linear(e2[0], e2[3], 5, 30);
  1895. comp[3] = linear(e1[0], e1[4], 20, 1) < linear(e2[0], e2[4], 20, 1);
  1896. break;
  1897. case 'SHIELD':
  1898. comp[0] = linear(e1[0], e1[1], 15, 10) < linear(e2[0], e2[1], 15, 10);
  1899. comp[1] = product(e1[0], e1[2]) < product(e2[0], e2[2]);
  1900. comp[2] = product(e1[0], e1[3]) < product(e2[0], e2[3]);
  1901. comp[3] = product(e1[0], e1[4]) < product(e2[0], e2[4]);
  1902. break;
  1903. case 'BOW':
  1904. comp[0] = product(e1[0], e1[1]) < product(e2[0], e2[1]);
  1905. comp[1] = product(e1[0], e1[2]) < product(e2[0], e2[2]);
  1906. comp[2] = product(e1[0], e1[3]) < product(e2[0], e2[3]);
  1907. comp[3] = linear(e1[0], e1[4], 15, 10) < linear(e2[0], e2[4], 15, 10);
  1908. break;
  1909. case 'ASSBOW':
  1910. comp[0] = linear(e1[0], e1[1], 5, 30) < linear(e2[0], e2[1], 5, 30);
  1911. comp[1] = linear(e1[0], e1[2], 20, 10) < linear(e2[0], e2[2], 20, 10);
  1912. comp[2] = linear(e1[0], e1[3], 20, 10) < linear(e2[0], e2[3], 20, 10);
  1913. comp[3] = product(e1[0], e1[4]) < product(e2[0], e2[4]);
  1914. break;
  1915. case 'DAGGER':
  1916. comp[0] = linear(e1[0], e1[1], 5, 0) < linear(e2[0], e2[1], 5, 0);
  1917. comp[1] = linear(e1[0], e1[2], 5, 0) < linear(e2[0], e2[2], 5, 0);
  1918. comp[2] = product(e1[0], e1[3]) < product(e2[0], e2[3]);
  1919. comp[3] = linear(e1[0], e1[4], 5, 25) < linear(e2[0], e2[4], 5, 25);
  1920. break;
  1921. case 'GLOVES':
  1922. comp[0] = product(e1[0], e1[1]) < product(e2[0], e2[1]);
  1923. comp[1] = product(e1[0], e1[2]) < product(e2[0], e2[2]);
  1924. comp[2] = product(e1[0], e1[3]) < product(e2[0], e2[3]);
  1925. comp[3] = product(e1[0], e1[4]) < product(e2[0], e2[4]);
  1926. break;
  1927. case 'BRACELET':
  1928. comp[0] = linear(e1[0], e1[1], 5, 1) < linear(e2[0], e2[1], 5, 1);
  1929. comp[1] = linear(e1[0], e1[2], 20, 1) < linear(e2[0], e2[2], 20, 1);
  1930. comp[2] = product(e1[0], e1[3]) < product(e2[0], e2[3]);
  1931. comp[3] = product(e1[0], e1[4]) < product(e2[0], e2[4]);
  1932. break;
  1933. case 'VULTURE':
  1934. comp[0] = linear(e1[0], e1[1], 15, 5) < linear(e2[0], e2[1], 15, 5);
  1935. comp[1] = linear(e1[0], e1[2], 15, 5) < linear(e2[0], e2[2], 15, 5);
  1936. comp[2] = linear(e1[0], e1[3], 15, 5) < linear(e2[0], e2[3], 15, 5);
  1937. comp[3] = product(e1[0], e1[4]) < product(e2[0], e2[4]);
  1938. break;
  1939. case 'CLOAK':
  1940. comp[0] = product(e1[0], e1[1]) < product(e2[0], e2[1]);
  1941. comp[1] = product(e1[0], e1[2]) < product(e2[0], e2[2]);
  1942. comp[2] = linear(e1[0], e1[3], 5, 25) < linear(e2[0], e2[3], 5, 25);
  1943. comp[3] = product(e1[0], e1[4]) < product(e2[0], e2[4]);
  1944. break;
  1945. case 'CLOTH':
  1946. isPick = false;
  1947. break;
  1948. case 'LEATHER':
  1949. isPick = false;
  1950. break;
  1951. case 'PLATE':
  1952. isPick = false;
  1953. break;
  1954. case 'THORN':
  1955. comp[0] = linear(e1[0], e1[1], 5, 20) < linear(e2[0], e2[1], 5, 20);
  1956. comp[1] = product(e1[0], e1[2]) < product(e2[0], e2[2]);
  1957. comp[2] = product(e1[0], e1[3]) < product(e2[0], e2[3]);
  1958. comp[3] = linear(e1[0], e1[4], 15, 10) < linear(e2[0], e2[4], 15, 10);
  1959. break;
  1960. case 'SCARF':
  1961. comp[0] = product(e1[0], e1[1]) < product(e2[0], e2[1]);
  1962. comp[1] = product(e1[0], e1[2]) < product(e2[0], e2[2]);
  1963. comp[2] = product(e1[0], e1[3]) < product(e2[0], e2[3]);
  1964. comp[3] = product(e1[0], e1[4]) < product(e2[0], e2[4]);
  1965. break;
  1966. case 'TIARA':
  1967. comp[0] = product(e1[0], e1[1]) < product(e2[0], e2[1]);
  1968. comp[1] = linear(e1[0], e1[2], 3, 1) < linear(e2[0], e2[2], 3, 1);
  1969. comp[2] = product(e1[0], e1[3]) < product(e2[0], e2[3]);
  1970. comp[3] = product(e1[0], e1[4]) < product(e2[0], e2[4]);
  1971. break;
  1972. case 'RIBBON':
  1973. comp[0] = product(e1[0], e1[1]) < product(e2[0], e2[1]);
  1974. comp[1] = product(e1[0], e1[2]) < product(e2[0], e2[2]);
  1975. comp[2] = product(e1[0], e1[3]) < product(e2[0], e2[3]);
  1976. comp[3] = product(e1[0], e1[4]) < product(e2[0], e2[4]);
  1977. break;
  1978. }
  1979. isPick = (
  1980. sift[1] == 'false' && comp[0] ||
  1981. sift[2] == 'false' && comp[1] ||
  1982. sift[3] == 'false' && comp[2] ||
  1983. sift[4] == 'false' && comp[3]);
  1984. if (isPick) {
  1985. break;
  1986. }
  1987. }
  1988. }
  1989. if (!isFind) {
  1990. isPick = true;
  1991. }
  1992. }
  1993. if (isPick) {
  1994. let btn0 = document.createElement('button');
  1995. btn0.setAttribute('class', 'btn btn-light');
  1996. btn0.setAttribute('onclick', btns[i].getAttribute('onclick'));
  1997. btn0.setAttribute('data-toggle', 'popover');
  1998. btn0.setAttribute('data-trigger', 'hover');
  1999. btn0.setAttribute('data-placement', 'left');
  2000. btn0.setAttribute('data-html', 'true');
  2001. let popover = document.createElement('div');
  2002. popover.innerHTML = `<style>.popover{max-width:360px}</style>`
  2003. for (let eqbtn of equipedbtn) {
  2004. if (sortdict[eqToAbbr(btns[i].dataset.originalTitle.split(' ')[2])] == parseInt(eqbtn.getAttribute('data-abbr'))) {
  2005. let btn1 = document.createElement('button');
  2006. btn1.setAttribute('class', 'btn btn-light');
  2007. btn1.style.cssText = 'padding:10px 5px 0px 5px;text-align:left;box-shadow:none;background-color:none;line-height:100%';
  2008. btn1.innerHTML = eqbtn.dataset.content;
  2009. if (btn1.lastChild.nodeType == 3) { //清除背景介绍文本
  2010. btn1.lastChild.remove();
  2011. }
  2012. if (btn1.lastChild.className.indexOf('bg-danger') != -1) {
  2013. btn1.lastChild.style.cssText = 'padding:0;max-width:160px;white-space:pre-line;word-break:break-all;line-height:110%';
  2014. }
  2015. popover.appendChild(btn1);
  2016. }
  2017. }
  2018. btn0.setAttribute('data-content', popover.innerHTML);
  2019. btn0.innerHTML = `<h3 class="popover-title" style="color:white;background-color: ${getComputedStyle(btns[i]).getPropertyValue("background-color")}">${btns[i].dataset.originalTitle}</h3><div class="popover-content-show">${btns[i].dataset.content}</div>`;
  2020. insertAfter(btn0, btns[i]);
  2021. }
  2022. }
  2023. }
  2024. $(function() {
  2025. $('[data-toggle="popover"]').popover();
  2026. });
  2027. $('.popover-content-show').css({
  2028. 'padding': '10px 10px 0px 10px'
  2029. });
  2030. $('.btn-light').css({
  2031. 'padding': 0,
  2032. 'text-align': 'left',
  2033. 'box-shadow': 'none',
  2034. 'background-color': 'none',
  2035. 'line-height': '90%'
  2036. });
  2037. $('.bg-danger').css({
  2038. 'padding': '5px 5px 5px 5px',
  2039. 'max-width': '200px',
  2040. 'white-space': 'pre-line',
  2041. 'word-break': 'break-all',
  2042. 'line-height': '110%'
  2043. });
  2044. }
  2045. //等待海滩装备加载
  2046. let show = setInterval(() => {
  2047. if ($('#beachall .fyg_mp3').toArray().length != 0) {
  2048. clearInterval(show);
  2049. //等待装备读取完成
  2050. let pick = setInterval(() => {
  2051. if (equipment.length > 0) {
  2052. clearInterval(pick);
  2053. pickEquipment(equipment);
  2054. }
  2055. }, 500);
  2056. }
  2057. }, 500);
  2058. function getBeachBtnNum() {
  2059. let eqbtns = $('#beachall .fyg_mp3').toArray();
  2060. let num = 0;
  2061. for (let i = 0; i < eqbtns.length; i++) {
  2062. if (eqbtns[i].className.indexOf('btn') != -1) {
  2063. num++;
  2064. }
  2065. }
  2066. return num;
  2067. }
  2068. let btnNum = -1;
  2069. let initBtnNum = setInterval(() => {
  2070. if ($('#beachall .fyg_mp3').toArray().length > 0) {
  2071. clearInterval(initBtnNum);
  2072. btnNum = getBeachBtnNum();
  2073. //console.log(`be:${btnNum}`);
  2074. }
  2075. }, 2000);
  2076. let observerBody0 = new MutationObserver(() => {
  2077. let nowlength = getBeachBtnNum();
  2078. //console.log(`be:${btnNum},${nowlength}`);
  2079. if (btnNum != -1 && btnNum != nowlength) { //海滩装备数量发生改变
  2080. //console.log(`${btnNum},${nowlength}`);
  2081. btnNum = nowlength;
  2082. //等待海滩状态刷新
  2083. let readd = setInterval(() => {
  2084. if ($('#beachall .btn btn-light').toArray().length == 0) {
  2085. clearInterval(readd);
  2086. pickEquipment(equipment);
  2087. }
  2088. }, 1000);
  2089. }
  2090. }, 1000);
  2091. observerBody0.observe(document.getElementsByClassName('panel panel-primary')[2], { childList: true, subtree: true, });
  2092. } else if (window.location.pathname == '/fyg_pk.php') {
  2093. let btngroup0 = document.createElement('div');
  2094. btngroup0.setAttribute('class', 'action_selector');
  2095. btngroup0.innerHTML = `<p></p><div class="btn-group" role="group">
  2096. <button type="button" class="btn btn-secondary">0</button>
  2097. <button type="button" class="btn btn-secondary">10</button>
  2098. <button type="button" class="btn btn-secondary">20</button>
  2099. <button type="button" class="btn btn-secondary">30</button>
  2100. <button type="button" class="btn btn-secondary">40</button>
  2101. <button type="button" class="btn btn-secondary">50</button>
  2102. <button type="button" class="btn btn-secondary">60</button>
  2103. <button type="button" class="btn btn-secondary">70</button>
  2104. <button type="button" class="btn btn-secondary">80</button>
  2105. <button type="button" class="btn btn-secondary">90</button>
  2106. <button type="button" class="btn btn-secondary">100</button>
  2107. </div>`;
  2108. let btngroup1 = document.createElement('div');
  2109. btngroup1.setAttribute('class', 'action_selector');
  2110. btngroup1.innerHTML = `<p></p><div class="btn-group" role="group">
  2111. <button type="button" class="btn btn-secondary">0</button>
  2112. <button type="button" class="btn btn-secondary">5</button>
  2113. <button type="button" class="btn btn-secondary">10</button>
  2114. <button type="button" class="btn btn-secondary">15</button>
  2115. <button type="button" class="btn btn-secondary">20</button>
  2116. <button type="button" class="btn btn-secondary">25</button>
  2117. <button type="button" class="btn btn-secondary">30</button>
  2118. <button type="button" class="btn btn-secondary">35</button>
  2119. <button type="button" class="btn btn-secondary">40</button>
  2120. <button type="button" class="btn btn-secondary">45</button>
  2121. <button type="button" class="btn btn-secondary">50</button>
  2122. <button type="button" class="btn btn-secondary">55</button>
  2123. <button type="button" class="btn btn-secondary">60</button>
  2124. <button type="button" class="btn btn-secondary">65</button>
  2125. <button type="button" class="btn btn-secondary">70</button>
  2126. <button type="button" class="btn btn-secondary">75</button>
  2127. <button type="button" class="btn btn-secondary">80</button>
  2128. <button type="button" class="btn btn-secondary">85</button>
  2129. <button type="button" class="btn btn-secondary">90</button>
  2130. <button type="button" class="btn btn-secondary">95</button>
  2131. <button type="button" class="btn btn-secondary">100</button>
  2132. </div>`;
  2133. let btngroup2 = document.createElement('div');
  2134. btngroup2.setAttribute('class', 'action_selector');
  2135. btngroup2.innerHTML = `<p></p><div class="btn-group" role="group">
  2136. <button type="button" class="btn btn-secondary">0</button>
  2137. <button type="button" class="btn btn-secondary">5</button>
  2138. <button type="button" class="btn btn-secondary">10</button>
  2139. <button type="button" class="btn btn-secondary">15</button>
  2140. <button type="button" class="btn btn-secondary">20</button>
  2141. <button type="button" class="btn btn-secondary">25</button>
  2142. <button type="button" class="btn btn-secondary">30</button>
  2143. <button type="button" class="btn btn-secondary">35</button>
  2144. <button type="button" class="btn btn-secondary">40</button>
  2145. <button type="button" class="btn btn-secondary">45</button>
  2146. <button type="button" class="btn btn-secondary">50</button>
  2147. <button type="button" class="btn btn-secondary">55</button>
  2148. <button type="button" class="btn btn-secondary">60</button>
  2149. <button type="button" class="btn btn-secondary">65</button>
  2150. <button type="button" class="btn btn-secondary">70</button>
  2151. <button type="button" class="btn btn-secondary">75</button>
  2152. <button type="button" class="btn btn-secondary">80</button>
  2153. <button type="button" class="btn btn-secondary">85</button>
  2154. <button type="button" class="btn btn-secondary">90</button>
  2155. <button type="button" class="btn btn-secondary">95</button>
  2156. <button type="button" class="btn btn-secondary">100</button>
  2157. </div>`;
  2158. let observerBody0 = new MutationObserver(() => {
  2159. //observerBody0.disconnect();
  2160. if (document.getElementsByClassName('btn-secondary').length == 0) {
  2161. let addbtn = setInterval(() => {
  2162. let col = document.querySelector("#pklist > div > div.col-md-8");
  2163. if (col != null) {
  2164. clearInterval(addbtn);
  2165. let obtns = document.getElementsByClassName('btn-block dropdown-toggle fyg_lh30');
  2166. col.insertBefore(btngroup0, obtns[0]);
  2167. col.insertBefore(btngroup1, obtns[1]);
  2168. col.insertBefore(btngroup2, obtns[2]);
  2169. if (document.getElementsByClassName('btn-outline-secondary').length == 0) {
  2170. if (localStorage.getItem('dataReward') == null) {
  2171. localStorage.setItem('dataReward', '{"sumShell":"0","sumExp":"0"}');
  2172. }
  2173. let ok = document.createElement('div');
  2174. ok.innerHTML = `<p></p><button type="button" class="btn btn-outline-secondary">任务执行</button>`;
  2175. col.appendChild(ok);
  2176. function gobattle() {
  2177. let times = new Array(0, 0, 0);
  2178. let sum = 0;
  2179. $(".btn-secondary").each(function(i, e) {
  2180. if ($(e).attr("style") != null && $(e).css("background-color") == "rgb(135, 206, 250)") {
  2181. let a = parseInt(e.innerText);
  2182. let b = $(".btn-group .btn-secondary").index(e);
  2183. sum += a;
  2184. if (b < 11) {
  2185. times[0] = a / 10;
  2186. } else if (b >= 11 && b < 32) {
  2187. times[1] = a / 5;
  2188. } else if (b >= 32) {
  2189. times[2] = a / 5;
  2190. }
  2191. }
  2192. });
  2193. if (sum <= parseInt(document.getElementsByClassName('fyg_colpz03')[0].innerText)) {
  2194. let gox_data = getPostData(/gox\(\)\{[\s\S]*\}/m, /data: ".*"/).slice(7, -1);
  2195. //let gox_data = document.getElementsByTagName('script')[2].innerText.match(/gox\(\)\{[\s\S]*\}/)[0].match(/data:\s*".*"/)[0].slice(7,-1);
  2196. let dataReward = JSON.parse(localStorage.getItem('dataReward'));
  2197. let sum0 = parseInt(dataReward.sumShell);
  2198. let sum1 = parseInt(dataReward.sumExp);
  2199. function func0(time) {
  2200. if (time == 0) {
  2201. if (times[0] != 0) {
  2202. GM_xmlhttpRequest({
  2203. method: 'POST',
  2204. url: `https://www.guguzhen.com/fyg_read.php`,
  2205. headers: headersPOST,
  2206. data: 'f=12',
  2207. onload: response => {
  2208. let ap = response.responseText.match(/class="fyg_colpz03" style="font-size:32px;font-weight:900;">[0-9]+</)[0].match(/>[0-9]+</)[0].slice(1, -1);
  2209. document.getElementsByClassName('fyg_colpz03')[0].innerText = ap;
  2210. let rankp = response.responseText.match(/class="fyg_colpz02" style="font-size:32px;font-weight:900;">[0-9]+%</)[0].match(/[0-9]+%/)[0];
  2211. document.getElementsByClassName('fyg_colpz02')[0].innerText = rankp;
  2212. let div_sum = document.createElement('div');
  2213. div_sum.innerText = `贝壳总次数:经验总次数=${sum0}:${sum1}=${(sum0 == 0 || sum1 == 0) ? 'undefined' : (sum0 / sum1).toFixed(4)}`;
  2214. dataReward.sumShell = sum0;
  2215. dataReward.sumExp = sum1;
  2216. localStorage.setItem('dataReward', JSON.stringify(dataReward));
  2217. document.getElementsByClassName('btn-outline-secondary')[0].parentNode.appendChild(div_sum);
  2218. times[0] = 0;
  2219. }
  2220. });
  2221. }
  2222. return;
  2223. }
  2224. GM_xmlhttpRequest({
  2225. method: 'POST',
  2226. url: `https://www.guguzhen.com/fyg_click.php`,
  2227. headers: headersPOST,
  2228. data: gox_data,
  2229. onload: response => {
  2230. if (response.responseText.slice(0, 2) == '获得') {
  2231. let info = response.responseText.slice(0, response.responseText.indexOf('<'));
  2232. let div_info = document.createElement('div');
  2233. div_info.innerText = info;
  2234. document.getElementsByClassName('btn-outline-secondary')[0].parentNode.appendChild(div_info);
  2235. if (info.indexOf('贝壳') != -1) {
  2236. sum0 += 1;
  2237. } else if (info.indexOf('经验') != -1) {
  2238. sum1 += 1;
  2239. }
  2240. func0(time - 1);
  2241. } else {
  2242. let div_info = document.createElement('div');
  2243. div_info.innerText = '段位进度不足';
  2244. document.getElementsByClassName('btn-outline-secondary')[0].parentNode.appendChild(div_info);
  2245. func0(0);
  2246. }
  2247. }
  2248. });
  2249. }
  2250. function func1(time) {
  2251. if (time == 0) {
  2252. times[1] = 0;
  2253. return;
  2254. }
  2255. let observerPk = new MutationObserver((mutationsList, observer) => {
  2256. let isPk = 0;
  2257. for (let mutation of mutationsList) {
  2258. if (mutation.type == 'childList') {
  2259. isPk = 1;
  2260. //console.log(targetNode.firstChild);
  2261. }
  2262. }
  2263. if (isPk) {
  2264. observerPk.disconnect();
  2265. func1(time - 1);
  2266. }
  2267. });
  2268. observerPk.observe(document.querySelector("#pk_text"), { characterData: true, childList: true });
  2269. jgjg(1);
  2270. }
  2271. function func2(time) {
  2272. if (time == 0) {
  2273. times[2] = 0;
  2274. return;
  2275. }
  2276. let observerPk = new MutationObserver((mutationsList, observer) => {
  2277. let isPk = 0;
  2278. for (let mutation of mutationsList) {
  2279. if (mutation.type == 'childList') {
  2280. isPk = 1;
  2281. //console.log(targetNode.firstChild);
  2282. }
  2283. }
  2284. if (isPk) {
  2285. observerPk.disconnect();
  2286. func2(time - 1);
  2287. }
  2288. });
  2289. observerPk.observe(document.querySelector("#pk_text"), { characterData: true, childList: true });
  2290. jgjg(2);
  2291. }
  2292. func0(times[0]);
  2293. let waitFor0 = setInterval(() => {
  2294. if (times[0] == 0) {
  2295. clearInterval(waitFor0);
  2296. func1(times[1]);
  2297. }
  2298. }, 1000);
  2299. let waitFor1 = setInterval(() => {
  2300. if (times[0] == 0 && times[1] == 0) {
  2301. clearInterval(waitFor1);
  2302. func2(times[2]);
  2303. }
  2304. }, 1000);
  2305. } else {
  2306. alert('体力不足');
  2307. }
  2308. }
  2309. document.getElementsByClassName('btn-outline-secondary')[0].addEventListener('click', gobattle, false);
  2310. }
  2311. function selector_act() {
  2312. var btnNum = $(".btn-group .btn-secondary").index(this);
  2313. $(".btn-group .btn-secondary")
  2314. .eq(btnNum)
  2315. .css("background-color", "rgb(135, 206, 250)")
  2316. .siblings(".btn-group .btn-secondary")
  2317. .css("background-color", "rgb(255, 255, 255)");
  2318. }
  2319. let btnselector = document.getElementsByClassName('btn-secondary');
  2320. for (let i = 0; i < btnselector.length; i++) {
  2321. btnselector[i].addEventListener('click', selector_act, false);
  2322. }
  2323. }
  2324. }, 1000);
  2325. }
  2326. });
  2327. observerBody0.observe(document.getElementsByClassName('panel panel-primary')[0], { childList: true, subtree: true, });
  2328. let keepCheck = document.createElement('form');
  2329. keepCheck.innerHTML = `<div class="form-group form-check">
  2330. <label class="form-check-label" for="keepcheck">暂时保持记录</label>
  2331. <input type="checkbox" class="form-check-input" id="keepcheck">
  2332. </div>`;
  2333. document.getElementsByClassName('panel panel-primary')[1].insertBefore(keepCheck, document.getElementById('pk_text'));
  2334. document.querySelector("#keepcheck").addEventListener('click', () => { localStorage.setItem('keepcheck', document.querySelector("#keepcheck").checked) }, false);
  2335. document.querySelector("#keepcheck").checked = (localStorage.getItem('keepcheck') == 'true');
  2336. let div0_pk_text_more = document.createElement('div');
  2337. div0_pk_text_more.setAttribute('id', 'pk_text_more');
  2338. div0_pk_text_more.setAttribute('class', 'panel-body');
  2339. document.getElementsByClassName('panel panel-primary')[1].appendChild(div0_pk_text_more);
  2340. let pkText = document.querySelector("#pk_text").innerHTML;
  2341. let observerBody1 = new MutationObserver(() => {
  2342. if (document.querySelector("#keepcheck").checked == true) {
  2343. document.querySelector("#pk_text_more").innerHTML = pkText + document.querySelector("#pk_text_more").innerHTML;
  2344. pkText = document.querySelector("#pk_text").innerHTML;
  2345. }
  2346. });
  2347. observerBody1.observe(document.querySelector("#pk_text"), { characterData: true, childList: true });
  2348. let btn1 = document.createElement('button');
  2349. let btn2 = document.createElement('button');
  2350. let span0 = document.createElement('span');
  2351. span0.innerHTML = ' 提交中...';
  2352. span0.className = 'tip';
  2353. //btn1.innerHTML = '正在读取卡片...';
  2354. btn1.innerHTML = '提交数据';
  2355. btn1.onmousedown = () => {
  2356. if (btn1.innerText[0] == '提') {
  2357. $('.tip').show();
  2358. }
  2359. };
  2360. btn1.onclick = () => {
  2361. if (btn1.innerText[0] == '提') {
  2362. try {
  2363. alert('数据采集已关闭');
  2364. $('.tip').hide();
  2365. //localStorage.clear();
  2366. // let npc = document.getElementById('pklist').children;
  2367. // for(let i = 2;i<12;i++){
  2368. // //console.log(npc[o].innerText[0]);
  2369. // if(npc[i].innerText[0]!='已'){
  2370. // localStorage.setItem('over', 0); //未与全部npc战斗
  2371. // alert('未与全部npc战斗,请与全部npc完成战斗后提交')
  2372. // break;
  2373. // }
  2374. // else{
  2375. // localStorage.setItem('over', 1);
  2376. // }
  2377. // }
  2378. // if(submitData()){
  2379. // alert('数据已提交,第一次使用记得把用户名站内发给thewzmath');
  2380. // $('.tip').hide();
  2381. // }
  2382. // else{
  2383. // if(localStorage.length<=4&&localStorage.getItem('over')=='1'){
  2384. // alert('无数据');
  2385. // }
  2386. // $('.tip').hide();
  2387. // }
  2388. } catch (err) {
  2389. console.log(err);
  2390. alert('数据提交失败,请重试');
  2391. $('.tip').hide();
  2392. }
  2393. }
  2394. };
  2395. btn2.innerText = '清空数据';
  2396. btn2.onclick = () => {
  2397. if (confirm('确定要清空数据吗?\n*确定后会刷新页面')) {
  2398. localStorage.clear();
  2399. window.location.reload();
  2400. }
  2401. }
  2402. wishExpireTip();
  2403. let p = document.getElementsByClassName('panel panel-primary')[0];
  2404. p.insertBefore(span0, p.children[0]);
  2405. p.insertBefore(btn1, p.children[0]);
  2406. p.insertBefore(btn2, p.children[0]);
  2407. $('.tip').hide();
  2408. }
  2409. })();