IdleTools

一键吃药|一键点亮|一键改造|一键合符文

目前為 2024-12-17 提交的版本,檢視 最新版本

  1. // ==UserScript==
  2. // @name IdleTools
  3. // @version 0.5
  4. // @description 一键吃药|一键点亮|一键改造|一键合符文
  5. // @author 奶牛
  6. // @match https://www.idleinfinity.cn/Equipment/Query?*
  7. // @match https://www.idleinfinity.cn/Map/Detail?*
  8. // @match https://www.idleinfinity.cn/Equipment/Query?*
  9. // @match https://www.idleinfinity.cn/Equipment/Reform?*
  10. // @match https://www.idleinfinity.cn/Equipment/Material?*
  11. // @require https://update.greasyfork.org/scripts/520974/1504661/IdleUtils.js
  12. // @grant none
  13. // @license MIT
  14. // @namespace https://greasyfork.org/users/1411581
  15. // ==/UserScript==
  16. (function () {
  17. //存储角色状态的key值
  18. const charStatus = "charStatus";
  19. //一键吃药记录的物品id
  20. const sanMedKey = "sanMedcineIds";
  21.  
  22. const isClickOnline = "isClickOnline";
  23.  
  24. //改造需要匹配的词条
  25. const reformKeyArr = "reformKeyArr";
  26.  
  27. const reformWhiteList = [["血红", "转换"], ["雄黄", "转换"], ["雷云风暴", "陨石"], ["支配", "陨石"], ["冰封球", "陨石"]]
  28.  
  29. class Idle {
  30. constructor() {
  31.  
  32. this.cids = this.getCharacters();
  33. this.initCidStatus();
  34. this.initCurrentChar();
  35. this.loadPlugin();
  36. }
  37.  
  38. cids = [];
  39. //当前用户
  40. currentId = 0;
  41.  
  42. //获取所有账号
  43. getCharacters() {
  44. let all = [];
  45. $(".dropdown-menu.char-switch li[data-id]").each((index, item) => {
  46. let id = $(item).attr("data-id");
  47. all.push(id);
  48. });
  49. return all;
  50. }
  51. initCurrentChar() {
  52. let localtion = $("a:contains('消息')")[0].href;//消息中有当前id
  53. let url = new URL(localtion);
  54. let urlParams = new URLSearchParams(url.search);
  55. let id = urlParams.get("id");
  56. this.currentId = id;
  57. //在地图页面修正离线状态,其他页面每次刷新初始化都是在线状态
  58. if (window.location.href.indexOf("Map/Detail") > -1) {
  59. var btns = $('a:contains("离线挂机")');
  60. var localObj = JSON.parse(localStorage.getItem(charStatus));
  61. if (btns.length == 0) {
  62.  
  63. localObj[id].isOnline = true;
  64. }
  65. else {
  66. localObj[id].isOnline = false;
  67. }
  68. this.saveMergeStatus(localObj, charStatus);
  69. }
  70.  
  71. }
  72.  
  73. //初始化一些角色相关的对象
  74. initCidStatus() {
  75. var map = {};
  76. this.cids.forEach((item, index) => {
  77. var obj = {};
  78. obj[item] = { isOnline: true, }
  79. this.saveMergeStatus(obj, charStatus);
  80. });
  81. }
  82.  
  83.  
  84. online(callback) {
  85. setTimeout(() => {
  86. $.ajax({
  87. type: "POST", // 或者 "GET",根据实际情况选择
  88. url: "BattleGuaji",
  89. data: $("form").serialize(),
  90. success: function (response) {
  91. if (callback) callback();
  92. location.reload();
  93. }
  94. });
  95. }, 1000)
  96.  
  97. }
  98.  
  99. switchCharacter(id) {
  100. if (!!!id) return;
  101. setTimeout(() => {
  102. location.href = `https://www.idleinfinity.cn/Map/Detail?id=${id}`;
  103. }, 1000)
  104.  
  105. }
  106. //开始循环点亮
  107. onlineLoop() {
  108. let isStart = localStorage.getItem(isClickOnline);
  109. if (!!!isStart) return;//没有点击启动则不开始自动点亮
  110. var localObj = JSON.parse(localStorage.getItem(charStatus));
  111. for (let id in localObj) {
  112. let item = localObj[id];
  113. if (this.currentId == id) {
  114. if (!item.isOnline) {
  115. debugger;
  116. this.online(() => {
  117. var cIndex = this.cids.indexOf(this.currentId);
  118. this.switchCharacter(this.cids[++cIndex]);
  119. });
  120. }
  121. else {
  122. debugger
  123. var cIndex = this.cids.indexOf(this.currentId);
  124. this.switchCharacter(this.cids[++cIndex]);
  125. }
  126.  
  127. }
  128. }
  129. if (this.currentId == this.cids[this.cids.length - 1]) {
  130. localStorage.removeItem(isClickOnline);
  131. }
  132. }
  133.  
  134.  
  135. //保存对象到本地缓存,有则合并,无则直接新增
  136. saveMergeStatus(obj, key) {
  137. var localObj = localStorage.getItem(key);
  138. localObj = JSON.parse(localObj);
  139. if (!!!localObj) {
  140. var str = JSON.stringify(obj);
  141. localStorage.setItem(key, str);
  142. }
  143. else {
  144.  
  145. var t = deepMerge(localObj, obj);
  146. var saveStr = JSON.stringify(t);
  147. localStorage.setItem(key, saveStr);
  148. }
  149. }
  150.  
  151. loadReformPlugin() {
  152. if (location.href.indexOf("Equipment/Reform") == -1) {
  153. localStorage.removeItem(reformKeyArr);
  154. return;
  155. }
  156. var container = $(".panel-heading:eq(1)");
  157. var span1 = $("<span>", {
  158. text: "目标词条1:"
  159. });
  160. var input1 = $("<input>", {
  161. type: "text",
  162. placeholder: "输入匹配词条",
  163. style: "color:#000",
  164. id: "txtTarget1"
  165. })
  166. var input2 = $("<input>", {
  167. type: "text",
  168. placeholder: "输入匹配词条",
  169. style: "color:#000",
  170. id: "txtTarget2"
  171. })
  172.  
  173.  
  174. container.append(span1)
  175. container.append(input1)
  176. var span2 = $("<span>", {
  177. text: "目标词条2:",
  178.  
  179. });
  180. container.append(span2)
  181. container.append(input2)
  182.  
  183. var span3 = $("<span>", {
  184. text: "改造公式:"
  185. });
  186. var opt = $("<select>", {
  187. id: "optType",
  188. })
  189. // 添加option元素
  190. var options = [
  191. { text: '蓝装+12#', value: '10' },
  192. { text: '蓝装+绿|钻宝石', value: '11' },
  193. { text: '蓝装+13#', value: '20' },
  194. { text: '蓝装+14#', value: '30' },
  195. { text: '蓝装+21#', value: '26' },
  196. { text: '套装+23#', value: '16' },
  197. { text: '套装+21#', value: '17' },
  198. { text: '稀有+22#', value: '27' },
  199.  
  200.  
  201.  
  202. ];
  203. //需要一个保留清单 洗出值钱的其他东西保留
  204.  
  205. $.each(options, function (i, option) {
  206. opt.append($('<option></option>').text(option.text).attr('value', option.value));
  207. });
  208. container.append(span3);
  209. container.append(opt);
  210.  
  211. var btn = $('<button>', {
  212. 'class': 'btn btn-default btn-xs dropdown-toggle',
  213. 'text': '开始改造',
  214. 'style': "margin-left:20px",
  215. 'id': "btnReform",
  216. click: () => {
  217. var t1 = $("#txtTarget1").val();
  218. var t2 = $("#txtTarget2").val();
  219. var optType = $("#optType").val();
  220. var arr = this.saveAffixToArr([t1, t2, optType]);
  221. this.saveMergeStatus(arr, reformKeyArr);
  222. this.reformAuto();
  223. }
  224. });
  225. container.append(btn);
  226. this.reformAuto();
  227.  
  228. }
  229.  
  230. reform() {
  231. // location.reload();
  232. // return;
  233. var type = $("#optType").val();
  234. $("#form input[name='type']").val(type);
  235. $.ajax({
  236. type: "POST", // 或者 "GET",根据实际情况选择
  237. url: "EquipReform",
  238. data: $("form").serialize(),
  239. success: function (response) {
  240. location.reload();
  241. }
  242. });
  243.  
  244. }
  245. reformAuto() {
  246.  
  247. var localStr = localStorage.getItem(reformKeyArr);
  248. if (!!!localStr) return;//去掉本地存储就停止
  249. var arr = JSON.parse(localStr);
  250. $("#txtTarget1").val(arr[0]);
  251. $("#txtTarget2").val(arr[1]);
  252. $("#optType").val(arr[2]);
  253. let affix = this.getAffix();
  254. if (!!affix) {
  255. $("#affix").val(affix);
  256. this.setAffixCheckbox(affix);
  257. }
  258. //检测一下是否匹配
  259. var text = $(".equip")[0].innerText;
  260. if (text.indexOf(arr[0]) > -1 && text.indexOf(arr[1]) > -1) {
  261. localStorage.removeItem(reformKeyArr);
  262. confirm("出现了!", function () {
  263.  
  264. });
  265. return;
  266. }
  267. if (this.checkWhiteList(text)) {
  268. localStorage.removeItem(reformKeyArr);
  269. confirm("出现了白名单物品!", function () {
  270.  
  271. });
  272. return;
  273. }
  274. setTimeout(() => {
  275. this.reform();
  276. }, 1500)
  277.  
  278.  
  279. }
  280. checkWhiteList(text) {
  281. debugger;
  282. for (let i = 0; i < reformWhiteList.length; i++) {
  283. var isMatch = true;//满足一组条件才算命中
  284. for (let j = 0; j < reformWhiteList[i].length; j++) {
  285. var condition = reformWhiteList[i][j];
  286. if (text.indexOf(condition) == -1) {
  287.  
  288. isMatch = false;
  289. break;
  290. }
  291. }
  292. if (isMatch) {
  293. return true;
  294. }
  295. }
  296. return false;
  297. }
  298. getAffix() {
  299. var arr = JSON.parse(localStorage.getItem(reformKeyArr));
  300. var affixArr = arr.splice(3);
  301. if (affixArr.length == 0) return "";
  302. return affixArr.join(",");
  303. }
  304.  
  305. //勾选选中的
  306. setAffixCheckbox(affixStr) {
  307. var arr = affixStr.split(",");
  308. arr.forEach((item, index) => {
  309. var fillter = `.affix-select[data-name='${item}']`
  310. $(fillter).prop('checked', true);
  311. })
  312. }
  313. //保存勾选框
  314. saveAffixToArr(arr) {
  315.  
  316. $(".affix-select").each((index, item) => {
  317. var isChecked = $(item).prop("checked");
  318. if (isChecked) {
  319. arr.push($(item).attr("data-name"));
  320. }
  321. })
  322. return arr;
  323. }
  324.  
  325.  
  326.  
  327.  
  328. loadPlugin() {
  329. //自动吃药
  330. loadSanPlugin();
  331. //电量
  332. loadOnlinePlugin();
  333. //自动改造
  334. this.loadReformPlugin();
  335. loadStorePlugin();
  336. }
  337.  
  338. }
  339. let _idle = new Idle();
  340. _idle.onlineLoop();
  341.  
  342.  
  343.  
  344. //载入吃药插件
  345. function loadSanPlugin() {
  346. var equipArr = [];//所有装备的id;
  347. var sanRestoreMap = {};//回复药水所处在数组中的index
  348. $(".equip-box .equip-name .unique[data-id]").each(function (index, item) {
  349. var name = $(this)[0].innerText;
  350. if (name.indexOf("药水") > -1) {
  351. sanRestoreMap[index] = item;
  352. }
  353.  
  354. })
  355. if (countProperties(sanRestoreMap) > 0) {
  356. var btn = $('<button>', {
  357. 'class': 'btn btn-default btn-xs dropdown-toggle',
  358. 'text': '一键吃药',
  359. 'id': "btnSanRestore"
  360. });
  361. var numInput = $('<input>', {
  362. 'class': 'panel-filter panel-filter-mybag',
  363. 'placeholder': '请填写要吃的数量',
  364. 'id': 'sanNumTxt'
  365. });
  366. $(".panel-heading:eq(2) .pull-right").append(btn);
  367. $(".panel-heading:eq(2) .pull-right").append(numInput);
  368. }
  369. $(".equip-box .equip-use[data-id]").each(function (index, item) {
  370.  
  371. let id = $(item).attr("data-id");
  372. equipArr.push(id);
  373. });
  374.  
  375. useSan();//缓存中计数吃药
  376. $("#btnSanRestore").on("click", function () {
  377. var count = 0;
  378. var sanMedcineIds = [];
  379. var num = $("#sanNumTxt").val() * 1;
  380. if (Number.isNaN(num) || num <= 0) {
  381. alert("请填写正确的数量");
  382. return;
  383. }
  384. for (let key in sanRestoreMap) {
  385.  
  386. if (count < num) {
  387. sanMedcineIds.push(equipArr[key]);
  388. }
  389.  
  390. count++;
  391. }
  392. localStorage.setItem(sanMedKey, sanMedcineIds);
  393. useSan();
  394. });
  395.  
  396. //自动吃掉本地存储sanMedcineIds里面的药
  397. function useSan() {
  398. let medcine = localStorage.getItem(sanMedKey);
  399. if (medcine == null) return;
  400. let arr = medcine.split(',');
  401. if (!!!arr[0]) return;
  402. use(arr[0], function () {
  403. arr.splice(0, 1);
  404. localStorage.setItem(sanMedKey, arr);
  405. });
  406. }
  407.  
  408. }
  409.  
  410. //载入上线脚本
  411. function loadOnlinePlugin() {
  412. var btns = $('a:contains("离线挂机")');
  413. if (btns.length == 0) {
  414. return;
  415. }
  416. var container = $(".panel-inverse .panel-footer .pull-right:first");
  417. var btn = $('<button>', {
  418. 'class': 'btn btn-default btn-xs dropdown-toggle',
  419. 'text': '一键点亮',
  420. 'id': "btnOnline"
  421. });
  422. container.append(btn);
  423.  
  424. $("#btnOnline").on("click", function () {
  425. _idle.saveMergeStatus(true, isClickOnline);
  426. debugger;
  427. _idle.switchCharacter(_idle.cids[0]);//从第一个角色开始
  428. });
  429.  
  430. }
  431.  
  432.  
  433.  
  434. //使用道具
  435. function use(eid, callback) {
  436. $.ajax({
  437. url: "EquipUse",
  438. type: "post",
  439. data: {
  440. cid: $("#cid").val(),
  441. eid: eid,
  442. __RequestVerificationToken: $("[name='__RequestVerificationToken']").val()
  443. },
  444. dataType: "html",
  445. success: function (result) {
  446. callback();
  447. location.reload();
  448. },
  449. error: function (request, state, ex) {
  450. console.log(result)
  451. }
  452. });
  453. }
  454.  
  455. function countProperties(obj) {
  456. let count = 0;
  457. for (let prop in obj) {
  458. if (obj.hasOwnProperty(prop)) {
  459. count++;
  460. }
  461. }
  462. return count;
  463. }
  464.  
  465. function deepMerge(target, ...sources) {
  466. for (let source of sources) {
  467. for (let key in source) {
  468. if (source.hasOwnProperty(key)) {
  469. if (typeof target[key] === 'object' && typeof source[key] === 'object') {
  470. deepMerge(target[key], source[key]);
  471. } else {
  472. target[key] = source[key];
  473. }
  474. }
  475. }
  476. }
  477. return target;
  478. }
  479.  
  480. //#region 符文插件
  481.  
  482. //载入符文插件
  483. function loadStorePlugin() {
  484. if (location.href.indexOf("Equipment/Material") == -1) {
  485. return;
  486. }
  487.  
  488. var compandMode = false;
  489. var autoCompandMode = false;
  490. var storedRuneCounts = {}; // 存储每个符文项的数量
  491. var storedCompandCounts = {}; // 合成每个符文项的保留数量
  492.  
  493. function showChange() {
  494. var lastCompandRuneId = parseInt(localStorage.getItem('lastCompandRuneId'));
  495. //刷新页面前正在运行一键升级符文逻辑,且符文检查没有运行完
  496. if (!lastCompandRuneId.isNaN && lastCompandRuneId >= 0 && lastCompandRuneId < 33) {
  497. autoCompandMode = true;
  498. }
  499.  
  500. console.log("上次自动升级符文id:" + lastCompandRuneId + "----是否进入自动升级模式:" + autoCompandMode);
  501. //一键升级模式
  502. if (autoCompandMode) {
  503. var curCompandRuneId = lastCompandRuneId + 1;
  504. $('.col-xs-12.col-sm-4.col-md-3.equip-container').each(function () {
  505. var runeName = $(this).find('p:first .equip-name .artifact:nth-child(2)').text().trim(); // 获取符文名称的第二个 span
  506. var runeCount = parseInt($(this).find('p:first .artifact').last().text().trim()); // 获取符文数量
  507.  
  508. var storedCompandCounts = JSON.parse(localStorage.getItem('storedCompandCounts'));
  509.  
  510. var storedCount = storedCompandCounts[runeName];
  511. if (storedCount.isNaN || storedCount == undefined)
  512. storedCount = 0;
  513. var regexResult = runeName.match(/-(\d+)#/);
  514. var count = 0;
  515. if (runeCount > storedCount) {
  516. count = runeCount - storedCount;
  517. count = count - count % 2;
  518. }
  519.  
  520. if (regexResult[1] == curCompandRuneId) {
  521. localStorage.setItem('lastCompandRuneId', regexResult[1]);
  522. if (count > 1) {
  523. compandStore(regexResult[1], count);
  524. }
  525. else {
  526. showChange();
  527. }
  528. // return;
  529. }
  530. });
  531. compandMode = true;
  532. }
  533.  
  534. //设置升级保留数量模式
  535. if (compandMode) {
  536. // localStorage.setItem('storedCompandCounts', JSON.stringify(""));
  537. //默认保留数量
  538. var storedCompandCounts = JSON.parse(localStorage.getItem('storedCompandCounts')) || {
  539. "夏-13#": 1000,
  540. "多尔-14#": 1000,
  541. "蓝姆-20#": 1000,
  542. "普尔-21#": 1000,
  543. "乌姆-22#": 1000,
  544. "马尔-23#": 1000,
  545. "伊司特-24#": 1000,
  546. "古尔-25#": 1000,
  547. "伐克斯-26#": 1000,
  548. "欧姆-27#": 1000,
  549. "罗-28#": 1000,
  550. "瑟-29#": 1000,
  551. "贝-30#": 1000,
  552. "乔-31#": 1000,
  553. "查姆-32#": 1000,
  554. "萨德-33#": 1000,
  555. };
  556. $('.panel-heading:contains("符文") .rasdsky').remove();
  557.  
  558. var confirmButton = $('<a class="btn btn-xs btn-default" id="confirmButton">确认</a>');
  559. var cancleButton = $('<a class="btn btn-xs btn-default" id="cancleButton">退出</a>');
  560.  
  561. // 将按钮放入一个 div 中,并添加到 panel-heading 中
  562. var buttonContainer = $('<div class="pull-right rasdsky"></div>');
  563. buttonContainer.append(confirmButton);
  564. buttonContainer.append(cancleButton);
  565.  
  566. $('.panel-heading:contains("符文")').append(buttonContainer);
  567. confirmButton.click(function () {
  568. $('.col-xs-12.col-sm-4.col-md-3.equip-container').each(function () {
  569. var runeName = $(this).find('p:first .equip-name .artifact:nth-child(2)').text().trim(); // 获取符文名称的第二个 span
  570. var runeCount = parseInt($(this).find('p:first .artifact').last().text().trim()); // 获取符文数量
  571.  
  572. var _inputElement = $(this).find('.rasdsky-input:first');
  573. var cnt = parseInt(_inputElement.val());
  574. if (storedCompandCounts.hasOwnProperty(runeName)) {
  575. if (!cnt.isNaN && cnt != undefined) {
  576. storedCompandCounts[runeName] = cnt;
  577. }
  578. }
  579. else {
  580. storedCompandCounts[runeName] = 0;
  581. }
  582. // var storedCount = storedCompandCounts[runeName];
  583. // var regexResult = runeName.match(/-(\d+)#/);
  584. // if (runeCount > storedCount) {
  585. // var count = runeCount - storedCount;
  586. // count = count - count % 2;
  587. // compandStore(regexResult[1], count);
  588. // }
  589. });
  590. localStorage.setItem('storedCompandCounts', JSON.stringify(storedCompandCounts)); // 存储到 localStorage
  591.  
  592. //进入一键升级模式
  593. autoCompandMode = true;
  594. localStorage.setItem('lastCompandRuneId', 0);
  595. showChange();
  596. });
  597. cancleButton.click(function () {
  598. compandMode = false;
  599. autoCompandMode = false;
  600. showChange();
  601. });
  602.  
  603. $('.col-xs-12.col-sm-4.col-md-3.equip-container').each(function () {
  604. var runeName = $(this).find('p:first .equip-name .artifact:nth-child(2)').text().trim(); // 获取符文名称的第二个 span
  605.  
  606. var retainCount = 0;
  607. if (storedCompandCounts.hasOwnProperty(runeName)) {
  608. retainCount = storedCompandCounts[runeName];
  609. if (retainCount == undefined || retainCount.isNaN)
  610. retainCount = 0;
  611. }
  612. $(this).find('.rasdsky').remove();
  613.  
  614. var t = ($('<span>').text(' 保留:').css('color', 'grey'));
  615.  
  616. var inputElement = $('<input class="rasdsky-input">').css({
  617. "color": "grey",
  618. "width": 120,
  619. "height": 21,
  620. });
  621. inputElement.val(retainCount);
  622. var p = $('<p class="rasdsky">');
  623. p.append(t);
  624. p.append(inputElement);
  625.  
  626. $(this).append(p)
  627.  
  628. });
  629. }
  630. //查看变动数量模式
  631. else {
  632.  
  633. $('.panel-heading:contains("符文") .rasdsky').remove();
  634. var storedRuneCounts = JSON.parse(localStorage.getItem('storedRuneCounts')) || {};
  635. console.log(storedRuneCounts);
  636. var storedTime = localStorage.getItem('storedTime');
  637.  
  638. // 将按钮放入一个 div 中,并添加到 panel-heading 中
  639. var buttonContainer2 = $('<div class="pull-right rasdsky"></div>');
  640.  
  641. // 创建展示存储时间的元素
  642. var timeDiv = $('<div class="pull-left rasdsky"></div>');
  643. var timeElement = $('<p>').text('存储时间: ' + storedTime);
  644. timeDiv.append(timeElement);
  645. // 创建存储符文数量的按钮
  646. var saveButton = $('<a class="btn btn-xs btn-default" id="saveButton">存储</a>');
  647. // 创建升级符文的按钮
  648. var compandButton = $('<a class="pull-right btn btn-xs btn-default" id="compandButton">升级</a>');
  649.  
  650. buttonContainer2.append(timeDiv);
  651. buttonContainer2.append(saveButton);
  652. buttonContainer2.append(compandButton);
  653.  
  654. $('.panel-heading:contains("符文")').append(buttonContainer2);
  655.  
  656. saveButton.click(function () {
  657. var storedRuneCounts = {};
  658.  
  659. $('.col-xs-12.col-sm-4.col-md-3.equip-container').each(function () {
  660.  
  661. var runeName = $(this).find('p:first .equip-name .artifact:nth-child(2)').text().trim(); // 获取符文名称的第二个 span
  662.  
  663. var runeCount = parseInt($(this).find('p:first .artifact').last().text().trim()); // 获取符文数量
  664. // 检查解析是否成功,如果是 NaN 或者数量小于等于 20 则跳过不存储
  665. var regexResult = runeName.match(/-(\d+)#/);
  666. if (regexResult && parseInt(regexResult[1]) >= 1) {
  667. // 检查解析是否成功,如果是 NaN 则设为 0
  668. if (isNaN(runeCount)) {
  669. runeCount = 0;
  670. }
  671. storedRuneCounts[runeName] = runeCount; // 存储符文数量
  672. }
  673. });
  674.  
  675. var currentTime = new Date().toLocaleString(); // 获取当前时间
  676. localStorage.setItem('storedRuneCounts', JSON.stringify(storedRuneCounts)); // 存储到 localStorage
  677. localStorage.setItem('storedTime', currentTime); // 存储时间到 localStorage
  678. alert("已存储数据", function () { });
  679. });
  680.  
  681. compandButton.click(function () {
  682. compandMode = true;
  683. showChange();
  684. });
  685.  
  686. $('.col-xs-12.col-sm-4.col-md-3.equip-container').each(function () {
  687.  
  688. var $pElement = $(this).find('p:first'); // 获取当前容器下的第一个 <p> 元素
  689.  
  690. var runeName = $(this).find('p:first .equip-name .artifact:nth-child(2)').text().trim(); // 获取符文名称的第二个 span
  691.  
  692. var currentRuneCount = parseInt($(this).find('p:first .artifact').last().text().trim()); // 获取符文数量
  693.  
  694. if (storedRuneCounts.hasOwnProperty(runeName)) {
  695. var storedCount = storedRuneCounts[runeName];
  696. var changeCount = currentRuneCount - storedCount; // 计算数量变动
  697. if (changeCount !== undefined) {
  698. var changeText = ' (' + storedCount + ' -> ' + currentRuneCount + ')'; // 根据变动数量生成对应文本
  699.  
  700. $(this).find('.rasdsky').remove();
  701. // 将变动数量拼接到符文信息的最后,并为 <p> 标签添加对应的样式
  702. $(this).find('p:first .artifact:last').append($('<span class="rasdsky">').text(changeText).css('color', (changeCount > 0) ? 'red' : (changeCount < 0) ? 'green' : 'white')); // 为 <p> 标签添加颜色样式);)
  703. }
  704. }
  705. });
  706. }
  707. }
  708. showChange();
  709. }
  710.  
  711. //升级符文消息
  712. function compandStore(rune, count) {
  713. var t = Math.floor(Math.random() * 1000) + 300;
  714. POST_Message("RuneUpgrade", {
  715. cid: $("#cid").val(),
  716. rune: rune,
  717. count: count,
  718. __RequestVerificationToken: $("[name='__RequestVerificationToken']").val()
  719. }, "html", t, function (result) {
  720. compandMode = true;
  721. location.reload();
  722. }, function (request, state, ex) {
  723. console.log(result)
  724. })
  725. // setTimeout(function () {
  726. // $.ajax({
  727. // url: "RuneUpgrade",
  728. // type: "post",
  729. // data: {
  730. // cid: $("#cid").val(),
  731. // rune: rune,
  732. // count: count,
  733. // __RequestVerificationToken: $("[name='__RequestVerificationToken']").val()
  734. // },
  735. // dataType: "html",
  736.  
  737. // success: function (result) {
  738. // // callback();
  739. // compandMode = true;
  740. // location.reload();
  741. // },
  742.  
  743. // error: function (request, state, ex) {
  744. // // console.log(result)
  745. // }
  746. // });
  747. // }, t);
  748. }
  749.  
  750. //#endregion
  751. })();