Created
September 3, 2015 22:26
-
-
Save arjan0307/c1214f6c0ddfa17c18a5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class window.KittenManager | |
actions: | |
hunting: | |
state: false | |
time_interval: null | |
parchmenting: | |
state: false | |
time_interval: null | |
manuscripting: | |
state: false | |
time_interval: null | |
compendiuming: | |
state: false | |
time_interval: null | |
blueprinting: | |
state: false | |
time_interval: null | |
steeling: | |
state: false | |
time_interval: null | |
praising: | |
state: false | |
time_interval: null | |
starclicking: | |
state: false | |
time_interval: null | |
constructor: () -> | |
@container = $('<div />') | |
@container.css({'width': '300px', 'background-color': '#000000', 'color': '#ffffff', 'opacity': '0.8', 'position': 'absolute', 'bottom': 0, 'right': 0 }) | |
@container.attr('id', 'flynn') | |
@container.data('actions', {}) | |
$table = $('<table><tbody></tbody></table>') | |
for action, values of @actions | |
@container.data('actions')[action] = {} | |
@container.data('actions')[action]['button'] = $('<button>Off</button>') | |
@container.data('actions')[action]['button'].data('state', false) | |
@container.data('actions')[action]['button'].data('action', action) | |
manager = @ | |
@container.data('actions')[action]['button'].on 'click', ((e) -> | |
manager.toggleButton.apply(manager, [e, this]) | |
) | |
$table.find('tbody').append(" | |
<tr><td>#{action}</td></tr> | |
") | |
$table.find('tr').last().append('<td />').append(@container.data('actions')[action]['button']) | |
$table.css({'width': '100%', 'border': 'solid 1px #000000' }) | |
@container.append($table) | |
$('body').append(@container) | |
toggleButton: (e, button) -> | |
$button = $(button) | |
action = $button.data('action') | |
@["handleToggle#{@capitalize(action)}"]() | |
if @actions[action].state | |
$button.html('Off') | |
@actions[action].state = false | |
else | |
$button.html('On') | |
@actions[action].state = true | |
handleToggleHunting: () -> | |
if @actions.hunting.state | |
clearInterval(@actions.hunting.time_interval) | |
else | |
@actions.hunting.time_interval = setInterval( -> | |
$('#fastHuntContainer').find('a')[0].click() | |
, 1000) | |
handleToggleParchmenting: () -> | |
if @actions.parchmenting.state | |
clearInterval(@actions.parchmenting.time_interval) | |
else | |
@actions.parchmenting.time_interval = setInterval( -> | |
$('td:contains("parchment")').siblings().find('a:contains("all")')[0].click() | |
, 1000) | |
handleToggleManuscripting: () -> | |
if @actions.manuscripting.state | |
clearInterval(@actions.manuscripting.time_interval) | |
else | |
@actions.manuscripting.time_interval = setInterval( -> | |
$('td:contains("manuscript")').siblings().find('a:contains("all")')[0].click() | |
, 1000) | |
handleToggleCompendiuming: () -> | |
if @actions.compendiuming.state | |
clearInterval(@actions.compendiuming.time_interval) | |
else | |
@actions.compendiuming.time_interval = setInterval( -> | |
$('td:contains("compendium")').siblings().find('a:contains("all")')[0].click() | |
, 1000) | |
handleToggleBlueprinting: () -> | |
if @actions.blueprinting.state | |
clearInterval(@actions.blueprinting.time_interval) | |
else | |
@actions.blueprinting.time_interval = setInterval( -> | |
$('td:contains("blueprint")').siblings().find('a:contains("all")')[0].click() | |
, 1000) | |
handleToggleSteeling: () -> | |
if @actions.steeling.state | |
clearInterval(@actions.steeling.time_interval) | |
else | |
@actions.steeling.time_interval = setInterval( -> | |
$('td:contains("steel")').siblings().find('a:contains("all")')[0].click() | |
, 1000) | |
handleTogglePraising: () -> | |
if @actions.praising.state | |
clearInterval(@actions.praising.time_interval) | |
else | |
@actions.praising.time_interval = setInterval( -> | |
$('span:contains("Praise the sun!")')[0].click() | |
, 1000) | |
handleToggleStarclicking: () -> | |
if @actions.starclicking.state | |
clearInterval(@actions.starclicking.time_interval) | |
else | |
@actions.starclicking.time_interval = setInterval( -> | |
$("#gameLog").find("input").click(); | |
, 1000) | |
capitalize: (string) -> | |
string.charAt(0).toUpperCase() + string.slice(1) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function() { | |
window.KittenManager = (function() { | |
KittenManager.prototype.actions = { | |
hunting: { | |
state: false, | |
time_interval: null | |
}, | |
parchmenting: { | |
state: false, | |
time_interval: null | |
}, | |
manuscripting: { | |
state: false, | |
time_interval: null | |
}, | |
compendiuming: { | |
state: false, | |
time_interval: null | |
}, | |
blueprinting: { | |
state: false, | |
time_interval: null | |
}, | |
steeling: { | |
state: false, | |
time_interval: null | |
}, | |
praising: { | |
state: false, | |
time_interval: null | |
}, | |
starclicking: { | |
state: false, | |
time_interval: null | |
} | |
}; | |
function KittenManager() { | |
var $table, action, manager, ref, values; | |
this.container = $('<div />'); | |
this.container.css({ | |
'width': '300px', | |
'background-color': '#000000', | |
'color': '#ffffff', | |
'opacity': '0.8', | |
'position': 'absolute', | |
'bottom': 0, | |
'right': 0 | |
}); | |
this.container.attr('id', 'flynn'); | |
this.container.data('actions', {}); | |
$table = $('<table><tbody></tbody></table>'); | |
ref = this.actions; | |
for (action in ref) { | |
values = ref[action]; | |
this.container.data('actions')[action] = {}; | |
this.container.data('actions')[action]['button'] = $('<button>Off</button>'); | |
this.container.data('actions')[action]['button'].data('state', false); | |
this.container.data('actions')[action]['button'].data('action', action); | |
manager = this; | |
this.container.data('actions')[action]['button'].on('click', (function(e) { | |
return manager.toggleButton.apply(manager, [e, this]); | |
})); | |
$table.find('tbody').append("<tr><td>" + action + "</td></tr>"); | |
$table.find('tr').last().append('<td />').append(this.container.data('actions')[action]['button']); | |
} | |
$table.css({ | |
'width': '100%', | |
'border': 'solid 1px #000000' | |
}); | |
this.container.append($table); | |
$('body').append(this.container); | |
} | |
KittenManager.prototype.toggleButton = function(e, button) { | |
var $button, action; | |
$button = $(button); | |
action = $button.data('action'); | |
this["handleToggle" + (this.capitalize(action))](); | |
if (this.actions[action].state) { | |
$button.html('Off'); | |
return this.actions[action].state = false; | |
} else { | |
$button.html('On'); | |
return this.actions[action].state = true; | |
} | |
}; | |
KittenManager.prototype.handleToggleHunting = function() { | |
if (this.actions.hunting.state) { | |
return clearInterval(this.actions.hunting.time_interval); | |
} else { | |
return this.actions.hunting.time_interval = setInterval(function() { | |
return $('#fastHuntContainer').find('a')[0].click(); | |
}, 1000); | |
} | |
}; | |
KittenManager.prototype.handleToggleParchmenting = function() { | |
if (this.actions.parchmenting.state) { | |
return clearInterval(this.actions.parchmenting.time_interval); | |
} else { | |
return this.actions.parchmenting.time_interval = setInterval(function() { | |
return $('td:contains("parchment")').siblings().find('a:contains("all")')[0].click(); | |
}, 1000); | |
} | |
}; | |
KittenManager.prototype.handleToggleManuscripting = function() { | |
if (this.actions.manuscripting.state) { | |
return clearInterval(this.actions.manuscripting.time_interval); | |
} else { | |
return this.actions.manuscripting.time_interval = setInterval(function() { | |
return $('td:contains("manuscript")').siblings().find('a:contains("all")')[0].click(); | |
}, 1000); | |
} | |
}; | |
KittenManager.prototype.handleToggleCompendiuming = function() { | |
if (this.actions.compendiuming.state) { | |
return clearInterval(this.actions.compendiuming.time_interval); | |
} else { | |
return this.actions.compendiuming.time_interval = setInterval(function() { | |
return $('td:contains("compendium")').siblings().find('a:contains("all")')[0].click(); | |
}, 1000); | |
} | |
}; | |
KittenManager.prototype.handleToggleBlueprinting = function() { | |
if (this.actions.blueprinting.state) { | |
return clearInterval(this.actions.blueprinting.time_interval); | |
} else { | |
return this.actions.blueprinting.time_interval = setInterval(function() { | |
return $('td:contains("blueprint")').siblings().find('a:contains("all")')[0].click(); | |
}, 1000); | |
} | |
}; | |
KittenManager.prototype.handleToggleSteeling = function() { | |
if (this.actions.steeling.state) { | |
return clearInterval(this.actions.steeling.time_interval); | |
} else { | |
return this.actions.steeling.time_interval = setInterval(function() { | |
return $('td:contains("steel")').siblings().find('a:contains("all")')[0].click(); | |
}, 1000); | |
} | |
}; | |
KittenManager.prototype.handleTogglePraising = function() { | |
if (this.actions.praising.state) { | |
return clearInterval(this.actions.praising.time_interval); | |
} else { | |
return this.actions.praising.time_interval = setInterval(function() { | |
return $('span:contains("Praise the sun!")')[0].click(); | |
}, 1000); | |
} | |
}; | |
KittenManager.prototype.handleToggleStarclicking = function() { | |
if (this.actions.starclicking.state) { | |
return clearInterval(this.actions.starclicking.time_interval); | |
} else { | |
return this.actions.starclicking.time_interval = setInterval(function() { | |
return $("#gameLog").find("input").click(); | |
}, 1000); | |
} | |
}; | |
KittenManager.prototype.capitalize = function(string) { | |
return string.charAt(0).toUpperCase() + string.slice(1); | |
}; | |
return KittenManager; | |
})(); | |
}).call(this); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Use it by copy pasting the javascript code into a console. Then type the following code in the console:
kitten_manager = KittenManager.new