SHOW:
|
|
- or go back to the newest paste.
1 | - | // HeroVille Incremental Plugin |
1 | + | // Cookie Clicker Incremental Plugin |
2 | // NOT OFFICIALLY SUPPORTED | |
3 | // Last Updated: 11/4/2014 | |
4 | ||
5 | //Test to see if plugin already exists (has been loaded already) and destroys it so it can load the current version. | |
6 | if(typeof plugin_assistant !== 'undefined') { | |
7 | plugin_assistant.destroy(); | |
8 | } | |
9 | function _plugin_assistant() { | |
10 | this.version = '1.0'; | |
11 | //create plugin variables and objects | |
12 | var btnClasses = ''; | |
13 | this.intervals = { | |
14 | interval: null, | |
15 | perSecond: 100 | |
16 | }; | |
17 | var intervals = this.intervals; | |
18 | //Create UI Elements | |
19 | this.ui = { | |
20 | body: $('div.page-wrap > div.row').first(), | |
21 | options: $('<div />').addClass(btnClasses), | |
22 | button: $('<button />').addClass(btnClasses).css({'float': 'left', 'margin-left': '15px'}), | |
23 | auto: { | |
24 | gather: $('<button />').addClass(btnClasses).html('Start AutoGather') | |
25 | }, | |
26 | rate: $('<input />').attr({type: 'number', min: 1, max:250}).val(this.intervals.perSecond). | |
27 | css({'margin': '6px 0 0 10px', width: '60px'}) | |
28 | }; | |
29 | var ui = this.ui; | |
30 | //assign CSS to UI Elements | |
31 | this.baseCSS = { | |
32 | "border": "2px solid gray", | |
33 | "display": "none", | |
34 | "margin": "0 0 0 40px", | |
35 | "float": "left", | |
36 | "padding": "10px" | |
37 | }; | |
38 | var baseCSS = this.baseCSS; | |
39 | ui.options.css(baseCSS); | |
40 | for(var btn in ui.auto) { | |
41 | ui.auto[btn].css({cursor: 'pointer'}); | |
42 | } | |
43 | ui.button.css({cursor: 'pointer'}); | |
44 | ui.body.css({'margin-left': '-30px'}); | |
45 | ||
46 | //assign functions to UI Elements | |
47 | ui.button.click(function() { | |
48 | ui.options.toggle(); | |
49 | }); | |
50 | function gather_click() { | |
51 | - | $('#gatherButton').click(); |
51 | + | $('#bigCookie').click(); |
52 | } | |
53 | ui.auto.gather.data('name', 'AutoGather').data('func', gather_click); | |
54 | var buttons = $(ui.auto.gather); | |
55 | buttons.click(function() { | |
56 | var intervals = plugin_assistant.intervals; | |
57 | if(intervals.interval == null){ | |
58 | intervals.interval = window.setInterval($(this).data('func'), 1000 / intervals.perSecond); | |
59 | $(this).html('Stop ' + $(this).data('name')); | |
60 | buttons.add(ui.rate).not($(this)).attr('disabled', 'disabled').css('opacity', 0.5); | |
61 | } else { | |
62 | window.clearInterval(intervals.interval); | |
63 | intervals.interval = null; | |
64 | $(this).html('Start ' + $(this).data('name')); | |
65 | buttons.add(ui.rate).removeAttr('disabled').css('opacity', 1); | |
66 | } | |
67 | }); | |
68 | ui.rate.change(function() { | |
69 | var intervals = plugin_assistant.intervals; | |
70 | intervals.perSecond = parseInt($(this).val()); | |
71 | }); | |
72 | ||
73 | //Assign Elements/Content to UI Elements | |
74 | ui.button.html('OPTIONS'); | |
75 | ui.options.html("<h3 style='margin:0'>Special Options</h3>"); | |
76 | ui.button.appendTo(ui.body); | |
77 | ui.options.appendTo(ui.body); | |
78 | for(var btn in ui.auto) { | |
79 | ui.auto[btn].appendTo(ui.options); | |
80 | $('<br />').appendTo(ui.options); | |
81 | } | |
82 | $('<label />').html('Clicks P/S:').css({'font-weight': 'bold'}).appendTo(ui.options); | |
83 | ui.rate.appendTo(ui.options); | |
84 | $('<br />').appendTo(ui.options); | |
85 | $('<span />').html('Assistant Version: ' + this.version).css({'font-size': 'small'}).appendTo(ui.options); | |
86 | ||
87 | //public methods | |
88 | this.destroy = function() { | |
89 | window.clearInterval(intervals.interval); | |
90 | ui.options.remove(); | |
91 | ui.button.remove(); | |
92 | } | |
93 | if(console != undefined) { | |
94 | console.log('HeroVille Incremental Assistant version ' + this.version + ' loaded'); | |
95 | } | |
96 | } | |
97 | ||
98 | //Start a new instance of the Plugin Assistant on load of the plugin. | |
99 | var plugin_assistant = new _plugin_assistant(); |