forked from dodying/UserJs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhvMonsterStats.user.js
73 lines (70 loc) · 2.5 KB
/
hvMonsterStats.user.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/* eslint-env browser */
// ==UserScript==
// @name [HV]MonsterStats
// @namespace https://github.com/dodying/UserJs
// @include http://alt.hentaiverse.org/?s=Bazaar&ss=ml&slot=*
// @include http*://hentaiverse.org/?s=Bazaar&ss=ml&slot=*
// @version 1.01
// @grant none
// @author dodying
// @namespace https://github.com/dodying/UserJs
// @supportURL https://github.com/dodying/UserJs/issues
// @icon https://gitee.com/dodying/userJs/raw/master/Logo.png
// @run-at document-end
// ==/UserScript==
(function () {
const morale = $$('.msl>div>div>img')[1].style.width;
let i;
if (morale.match(/\d+/)[0] * 1 <= 110) { // Morale<=110
const grades = [];
let elements = $$('.mcr tr>td:nth-child(2)');
for (i = 0; i < elements.length; i++) {
grades.push(($$('.mcr tr')[i].querySelector('td:nth-child(1)>img[src*="_a.png"]')) ? parseInt(elements[i].textContent) : Infinity);
}
const min = Math.min.apply(null, grades);
elements = $$('.mcr tr>td:nth-child(1)>img');
let target;
for (i = 0; i < elements.length; i++) {
target = elements[inArray(min, grades)];
if (target.hasAttribute('onclick')) {
target.click();
break;
} else {
grades[inArray(min, grades)] = -1;
}
}
} else if ($('[src="/y/character/inc.png"]')) {
const img = $$('[src="/y/character/inc.png"]');
const costs = Array.prototype.map.call(img, (i) => i.getAttribute('onmouseover').match(/Upgrade Cost: (\d+) Chaos Tokens?[ ]+Stock: (\d+)/)[1] * 1);
img[costs.indexOf(Math.min.apply(null, costs))].click();
} else {
const slot = window.location.href.match(/slot=(\d+)/)[1];
let dateNow = new Date();
dateNow = `${dateNow.getUTCFullYear()}/${dateNow.getUTCMonth() + 1}/${dateNow.getUTCDate()}`;
let monsterLab = (window.localStorage.monsterLab) ? JSON.parse(window.localStorage.monsterLab) : {
date: dateNow,
};
if (monsterLab.date === dateNow && monsterLab[slot] === true) {
return;
} if (monsterLab.date !== dateNow) {
monsterLab = {
date: dateNow,
};
}
monsterLab[slot] = true;
window.localStorage.monsterLab = JSON.stringify(monsterLab);
$('#monster_nav>div:nth-child(3)>img').click();
}
function $(e) {
return document.querySelector(e);
}
function $$(e) {
return document.querySelectorAll(e);
}
function inArray(text, array) {
for (let i = 0; i < array.length; i++) {
if (array[i] === text) return i;
}
return false;
}
}());