forked from saahphire/NeopetsUserscripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgrarrlKenoHelper.js
More file actions
56 lines (51 loc) · 2.19 KB
/
Copy pathgrarrlKenoHelper.js
File metadata and controls
56 lines (51 loc) · 2.19 KB
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
// ==UserScript==
// @name Neopets: Grarrl Keno Helper
// @namespace https://github.com/saahphire/NeopetsUserscripts
// @version 1.3.0
// @description Adds a button to Grarrl Keno that allows you to play with 10 random eggs with one click instead of five clicks plus typing. Change const bet to your bet amount.
// @author saahphire
// @homepageURL https://github.com/saahphire/NeopetsUserscripts
// @downloadURL https://github.com/saahphire/NeopetsUserscripts/blob/main/grarrlKenoHelper.js
// @updateURL https://github.com/saahphire/NeopetsUserscripts/blob/main/grarrlKenoHelper.js
// @match https://www.neopets.com/prehistoric/keno.phtml
// @icon https://www.google.com/s2/favicons?sz=64&domain=neopets.com
// @grant none
// @license The Unlicense
// ==/UserScript==
const bet = 1;
const style = "display:block;padding:1em;";
const show_winners = () => {
egg_counter = 10;
let greenEggs = 0;
for (let i = 0; i < 9; i++) {
const eggMatch = egg_arr.find(egg => egg === winners[i]);
show_match_chart(winners[i]);
const eggImage = eggMatch ? "green_egg" : "red_egg";
if(eggMatch) greenEggs++;
document.getElementById(`td${winners[i]}`).style.backgroundImage = `url("//images.neopets.com/prehistoric/${eggImage}.gif")`;
}
show_final_results();
document.querySelector(".content b").innerText += ` ${greenEggs} right guess${greenEggs === 1 ? '' : 'es'}`;
}
const onSelect = () => {
const button = document.createElement("button");
button.style = style;
button.innerText = "Just Play";
button.onclick = (e) => {
document.getElementsByName('bet')[0].value = bet;
random_eggs(10);
document.querySelector("form[name='keno']").submit();
}
return button;
}
const onResult = () => {
// If you don't want instant results, comment out the next like (put a // in front of it)
show_winners();
const form = document.querySelector("form[action='keno.phtml']");
form.children[0].style = style;
return form;
}
(function() {
'use strict';
document.querySelector(".content b").prepend(document.getElementsByName('bet').length > 0 ? onSelect() : onResult());
})();