Skip to content

Commit bfe4fde

Browse files
authored
Update enhancedautohatchery.js
1 parent fe7c084 commit bfe4fde

1 file changed

Lines changed: 29 additions & 4 deletions

File tree

enhancedautohatchery.js

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// @namespace Pokeclicker Scripts
44
// @match https://www.pokeclicker.com/
55
// @grant none
6-
// @version 1.2
6+
// @version 1.3
77
// @author Ephenia (Original/Credit: Drak + Ivan Lay)
88
// @description Automatically hatches eggs at 100% completion. Adds an On/Off button for auto hatching as well as an option for automatically hatching store bought eggs and dug up fossils.
99
// ==/UserScript==
@@ -15,6 +15,8 @@ var autoHatchLoop;
1515
var randFossilEgg;
1616
var eggFossilState;
1717
var eggFossilColor;
18+
var hatcherySortVal;
19+
var hatcherySortDir;
1820
var trainerCards = document.querySelectorAll('.trainer-card');
1921
var breedingDisplay = document.getElementById('breedingDisplay');
2022

@@ -40,7 +42,7 @@ function initAutoHatch() {
4042

4143
$("#auto-hatch-start").click (toggleAutoHatch)
4244
$("#auto-egg-fossil").click (toggleEggFossil)
43-
document.getElementById('breedingModal').querySelector('button[aria-controls="breeding-sort"]').setAttribute("style", "display:none");
45+
//document.getElementById('breedingModal').querySelector('button[aria-controls="breeding-sort"]').setAttribute("style", "display:none");
4446

4547
if (hatchState == "ON") {
4648
autoHatcher();
@@ -84,13 +86,28 @@ function autoHatcher() {
8486
//change daycare sorting
8587
var pS = Settings.getSetting('partySort');
8688
var hS = Settings.getSetting('hatcherySort');
87-
if (pS.observableValue() != hS.observableValue()) {
89+
if (pS.observableValue() != hatcherySortVal) {
8890
hS.observableValue(pS.observableValue())
91+
hatcherySortVal = pS.observableValue()
92+
localStorage.setItem("hatcherySortVal", hatcherySortVal);
8993
}
94+
if (hS.observableValue() != hatcherySortVal) {
95+
hatcherySortVal = hS.observableValue()
96+
pS.observableValue(hS.observableValue())
97+
localStorage.setItem("hatcherySortVal", hatcherySortVal);
98+
}
99+
90100
var pSD = Settings.getSetting('partySortDirection');
91101
var hSD = Settings.getSetting('hatcherySortDirection');
92-
if (pSD.observableValue() != hSD.observableValue()) {
102+
if (pSD.observableValue() != hatcherySortDir) {
103+
hatcherySortDir = pSD.observableValue()
93104
hSD.observableValue(pSD.observableValue())
105+
localStorage.setItem("hatcherySortDir", hatcherySortDir);
106+
}
107+
if (hSD.observableValue() != hatcherySortDir) {
108+
hatcherySortDir = hSD.observableValue()
109+
pSD.observableValue(hSD.observableValue())
110+
localStorage.setItem("hatcherySortDir", hatcherySortDir);
94111
}
95112

96113
// Attempt to hatch each egg. If the egg is at 100% it will succeed
@@ -256,8 +273,16 @@ if (localStorage.getItem('autoHatchState') == null) {
256273
if (localStorage.getItem('autoEggFossil') == null) {
257274
localStorage.setItem("autoEggFossil", "OFF");
258275
}
276+
if (localStorage.getItem('hatcherySortVal') == null) {
277+
localStorage.setItem("hatcherySortVal", 0);
278+
}
279+
if (localStorage.getItem('hatcherySortDir') == null) {
280+
localStorage.setItem("hatcherySortDir", true);
281+
}
259282
hatchState = localStorage.getItem('autoHatchState');
260283
eggFossilState = localStorage.getItem('autoEggFossil');
284+
hatcherySortVal = +localStorage.getItem('hatcherySortVal');
285+
hatcherySortDir = +localStorage.getItem('hatcherySortDir');
261286

262287
for (var i = 0; i < trainerCards.length; i++) {
263288
trainerCards[i].addEventListener('click', checkAutoHatch, false);

0 commit comments

Comments
 (0)