-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGoldenCookieObserverBeta.js
65 lines (55 loc) · 1.62 KB
/
GoldenCookieObserverBeta.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
class GoldenCookieObserver {
constructor() {
this.audio = new AudioContext()
this._volume = 5;
}
set volume(val) {
this._volume = val;
};
get volume() {
return this._volume;
}
beep(vol, freq, duration) {
let v = this.audio.createOscillator()
let u = this.audio.createGain()
v.connect(u)
v.frequency.value = freq
v.type = "square"
u.connect(this.audio.destination)
u.gain.value = parseFloat((vol * 0.01).toFixed(2));
v.start(this.audio.currentTime)
v.stop(this.audio.currentTime + duration * 0.001)
}
observe() {
let observer = this;
Game.shimmerTypes['golden'].proxiedSpawned = Game.shimmerTypes['golden'].spawned;
Object.defineProperties(Game.shimmerTypes['golden'], {
"spawned": {
get: function () {
return this.value;
},
set: function (val) {
if (val > 0) {
observer.beep(this.volume, 220, 150);
}
this.value = val;
}
},
});
}
forVersion() {
return "2.022"
}
}
console.log("Thank you for observing with KiraaCorsac's Golden Cookie Observer. We guarantee you a beep for every golden cookie or your money back.")
if(Game == undefined){
console.log("... but this is not Cookie Clicker, is it");
}
Game.Observer = new GoldenCookieObserver;
var proceed = true;
if (Game.version != Game.Observer.forVersion()) {
proceed = confirm(`I made this for verison ${Game.Observer.forVersion()}, you are running this on ${Game.version}. Your computer might explode or something (for example, it might just not work).`);
}
if (proceed) {
Game.Observer.observe();
}