This file contains 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
// ==UserScript== | |
// @name Antimatter M-key Spammer | |
// @namespace https://gist.github.com/GabeStah/83466ed568649e1bf711fb0f451932ff | |
// @updateURL https://gist.github.com/GabeStah/83466ed568649e1bf711fb0f451932ff | |
// @downloadURL https://gist.github.com/GabeStah/83466ed568649e1bf711fb0f451932ff | |
// @version 0.27 | |
// @description try to take over the world! | |
// @author You | |
// @match http://ivark.github.io/ | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
// Loop delay in milliseconds. | |
var LOOP_DELAY = 200; | |
var DIMSAC_MINIMUM = 2.00; | |
var DIMSAC_ENABLED = false; | |
var DIMSAC_INTERVAL; | |
var MKEY_ENABLED = true; | |
var MKEY_INTERVAL; | |
var CHECKBOXES = [ | |
{ | |
id: 'maxAll', | |
name: 'Max All', | |
enabled: true, | |
keyCode: 77, // m | |
interval: undefined, | |
}, | |
{ | |
id: 'sacrifice', | |
name: 'Sacrifice', | |
enabled: true, | |
keyCode: 83, // s | |
interval: undefined, | |
}, | |
{ | |
id: 'dimension', | |
name: 'Dimension Shift', | |
enabled: false, | |
keyCode: 68, // d | |
interval: undefined, | |
}, | |
{ | |
id: 'galaxy', | |
name: 'Antimatter Galaxies', | |
enabled: false, | |
keyCode: 71, // g | |
interval: undefined, | |
}, | |
]; | |
// Your code here... | |
var keydown = function(k) { | |
var oEvent = document.createEvent('KeyboardEvent'); | |
// Chromium Hack | |
Object.defineProperty(oEvent, 'keyCode', { | |
get : function() { | |
return this.keyCodeVal; | |
} | |
}); | |
Object.defineProperty(oEvent, 'which', { | |
get : function() { | |
return this.keyCodeVal; | |
} | |
}); | |
if (oEvent.initKeyboardEvent) { | |
oEvent.initKeyboardEvent("keydown", true, true, document.defaultView, false, false, false, false, k, k); | |
} else { | |
oEvent.initKeyEvent("keydown", true, true, document.defaultView, false, false, false, false, k, 0); | |
} | |
oEvent.keyCodeVal = k; | |
if (oEvent.keyCode !== k) { | |
alert("keyCode mismatch " + oEvent.keyCode + "(" + oEvent.which + ")"); | |
} | |
document.dispatchEvent(oEvent); | |
}; | |
// Press "m" key. | |
//MKEY_INTERVAL = setInterval(() => { | |
// keydown(77); | |
//}, LOOP_DELAY); | |
$('<div id="spammer-container"></div>').appendTo('body'); | |
function setValue(id, key, value) { | |
CHECKBOXES.forEach(function(e) { | |
if (e.id == id) { | |
e[key] = value; | |
} | |
}); | |
} | |
function getValue(id, key) { | |
var result; | |
CHECKBOXES.forEach(function(e) { | |
if (e.id == id) { | |
result = e[key]; | |
} | |
}); | |
return result; | |
} | |
function modifyInterval(id, enable) { | |
if (enable) { | |
setValue(id, 'interval', setInterval(() => { | |
// Sacrifice | |
if (id == 'sacrifice') { | |
var current = calcSacrificeBoost().mantissa * Math.pow(10, calcSacrificeBoost().exponent); | |
// If current sac bonus is greater than minimum, sacrifice. | |
if (current >= DIMSAC_MINIMUM) { | |
keydown(getValue(id, 'keyCode')); | |
} | |
} else { | |
// Default | |
keydown(getValue(id, 'keyCode')); | |
} | |
}, LOOP_DELAY)); | |
} else { | |
clearInterval(getValue(id, 'interval')); | |
setValue(id, 'interval', undefined); | |
} | |
} | |
function addCheckbox(id, value, label, onChange) { | |
var container = $('#spammer-container'); | |
var inputs = container.find('input'); | |
modifyInterval(id, getValue(id, 'enabled')); | |
$('<input />', { type: 'checkbox', id: id, value: value, checked: value}).appendTo(container).change(function() { | |
setValue(id, 'enabled', $(this).prop('checked')); | |
//console.log($(this).attr('id'), $(this).attr('value')); | |
//console.log(getValue(id, 'name'), getValue(id, 'keyCode'), getValue(id, 'enabled')); | |
modifyInterval(id, false); | |
if (getValue(id, 'enabled')) { | |
modifyInterval(id, true); | |
} | |
}); | |
$('<label />', { 'for': id, text: label }).appendTo(container); | |
} | |
CHECKBOXES.forEach(function(e) { | |
//console.log(e); | |
addCheckbox(e.id, e.enabled, e.name); | |
}); | |
console.log(GM_info.version); | |
// addCheckbox('m-spam-enabled', true, 'M-Key', () => { | |
// console.log($(this).id, $(this).value); | |
// }); | |
// addCheckbox('sacrifice-enabled', true, 'Sacrifice', () => { | |
// console.log($(this).id, $(this).value); | |
// }); | |
// $('<button id="m-key-enabled">M-Key: Enabled</button>').appendTo('body').click(function() { | |
// MKEY_ENABLED = !MKEY_ENABLED; | |
// console.log(MKEY_ENABLED); | |
// if (MKEY_ENABLED == true) { | |
// clearInterval(MKEY_INTERVAL); | |
// MKEY_INTERVAL = setInterval(() => { | |
// keydown(77); | |
// }, LOOP_DELAY); | |
// } else { | |
// clearInterval(MKEY_INTERVAL); | |
// } | |
// $(this).text("M-Key: " + (MKEY_ENABLED ? "Enabled" : "Disabled")); | |
// }); | |
// $('<button id="dimensional-sacrifice-enabled">Dim-Sac: Disabled</button>').appendTo('body').click(function() { | |
// DIMSAC_ENABLED = !DIMSAC_ENABLED; | |
// console.log(DIMSAC_ENABLED); | |
// if (DIMSAC_ENABLED == true) { | |
// clearInterval(DIMSAC_INTERVAL); | |
// DIMSAC_INTERVAL = setInterval(() => { | |
// // Galaxy | |
// keydown(71); | |
// // Dimensions | |
// keydown(68); | |
// var current = calcSacrificeBoost().mantissa * Math.pow(10, calcSacrificeBoost().exponent); | |
// // If current sac bonus is greater than minimum, sacrifice. | |
// if (current >= DIMSAC_MINIMUM) { | |
// keydown(83); | |
// } | |
// }, LOOP_DELAY); | |
// } else { | |
// clearInterval(DIMSAC_INTERVAL); | |
// } | |
// $(this).text("Dim-Sac: " + (DIMSAC_ENABLED ? "Enabled" : "Disabled")); | |
// }); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment