idle

挂机无止境AH等级过滤,和初始金币

  1. // ==UserScript==
  2. // @name idle
  3. // @version 1.1
  4. // @namespace HolyNight
  5. // @description 挂机无止境AH等级过滤,和初始金币
  6. // @author shengguangchanhui@foxmail.com
  7. // @run-at document-start
  8. // @match https://www.idleinfinity.cn/*
  9. // @require https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.22.1/moment.min.js
  10. // @require https://cdnjs.cloudflare.com/ajax/libs/jquery-url-parser/2.3.1/purl.min.js
  11. // ==/UserScript==
  12.  
  13. function ahInit(){
  14. // 改变竞标框默认金币
  15. $("[name='gold'][id='gold'][type='number']").attr('value', 2000000);
  16.  
  17. // 监听过滤条件输入框的改变
  18. $(".panel-filter").on("input propertychange", function () {
  19. $(".equip-container .selected").removeClass("selected")
  20.  
  21. // 输入的值
  22. var value = $(this).val();
  23. // 保存到缓存,方便下次使用
  24. window.localStorage.setItem($(this).attr("id"), value);
  25. if (value.length > 0) {
  26. var values = value.split(",");
  27. var equips = $(this).parent().prev().find(".equip-content");
  28.  
  29. // 正则判断是否是数字
  30. const min = /^<[0-9]+.?[0-9]*$/;
  31. const max = /^>[0-9]+.?[0-9]*$/;
  32.  
  33. // 提取装备等级的正则表达式
  34. const level = /\([0-9]*\)/;
  35.  
  36. // 去的当页数据
  37. equips.each(function (i, e) {
  38. var match = 0;
  39. $.each(values, function (j, p) {
  40. let text = $(e).text();
  41. if (min.test(p)) {
  42. // 纯数字,作为掉落等级来判断
  43. let exec = String(level.exec(text));
  44. exec = exec.substring(1, exec.length - 1);
  45. p = p.substring(1, p.length);
  46. if (parseInt(exec) <= parseInt(p)) match++;
  47. } else if (max.test(p)) {
  48. let exec = String(level.exec(text));
  49. exec = exec.substring(1, exec.length - 1);
  50. p = p.substring(1, p.length);
  51. if (parseInt(exec) >= parseInt(p)) match++;
  52. } else if (text.indexOf(p) >= 0) {
  53. // 其他属性
  54. match++;
  55. }
  56. });
  57. if (match == values.length) {
  58. $(e).prev().addClass("selected");
  59. }
  60. });
  61. }
  62. });
  63.  
  64. $(document).ready(function () {
  65. $(".panel-filter").each(function (i, input) {
  66. var value = window.localStorage.getItem($(this).attr("id"));
  67. if (value != null && value.length > 0) {
  68. $(this).val(value);
  69. $(this).trigger("propertychange");
  70. }
  71. });
  72. });
  73. }
  74.  
  75. window.addEventListener('load', ahInit, false);