Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function AutoClicker(key = "F2", mode = 1, speed = 1000, isActive = false) {
- this.speed = speed;
- this.key = key;
- this.isActive = isActive;
- this.mode = mode;
- this.toggle = function() {
- isActive = !isActive;
- option.document.querySelector('body').style.backgroundColor = isActive ? "#0F0" : "#F00";
- option.document.querySelectorAll('p')[1].innerHTML = isActive ? "On" : "Off";
- }
- option = window.open("", "", "width=220,height=140");
- isClosed = false;
- document.querySelectorAll('*').forEach(function(elem) {
- elem.addEventListener("mouseover", function moIn(e) {
- if (!isClosed) {
- elem.AutoClick = setInterval(() => {
- if (isActive) {
- leftClick(elem, e)
- }
- }, speed);
- }
- });
- elem.addEventListener("mouseout", function moOut() {
- clearInterval(elem.AutoClick);
- });
- });
- function leftClick(el, event) {
- if (mode = 1) {
- el.dispatchEvent(new MouseEvent('click', event));
- } else {
- el.click();
- }
- }
- document.addEventListener('keydown', keydown);
- function keydown(e) {
- key = option.document.querySelector('p').innerHTML
- if (e.code == key) {
- isActive = !isActive;
- option.document.querySelector('body').style.backgroundColor = isActive ? "#0F0" : "#F00";
- option.document.querySelectorAll('p')[1].innerHTML = isActive ? "On" : "Off";
- }
- }
- option.document.write(`
- <style>*{user-select:none;transition: all 0.2s;}</style>
- <body style="background-color: #F00; font-family: Verdana">
- <input type="number" min="1" value="${speed}">ms
- <br>
- <label for="key">Toggle Key</label>
- <select id="opt"><option value="1">Dispatch</option><option value="2">Click</option></select>
- <input type="text" id="key" style="visibility: hidden;width: 0px;height: 0px;margin: 0px;">
- <p>${key}</p>
- <p>Off</p>
- </body>
- <title>${location.href + ' - Auto Clicker Options'}</title>
- `);
- option.document.addEventListener('keydown', keydown);
- keys = option.document.querySelector('#key');
- keys.onkeydown = keys.onkeyup = function(e) {
- option.document.querySelectorAll('p')[0].innerHTML = e.code;
- }
- modes = option.document.querySelector('select#opt');
- modes.addEventListener('change', function() {
- mode = modes.value;
- });
- window.addEventListener('mousemove', function() {
- speed = option.document.querySelectorAll('input')[0].value;
- });
- window.addEventListener('beforeunload', function() {
- option.close();
- document.querySelectorAll('*').forEach(function(elem) {
- elem.removeEventListener('mouseover', moIn);
- elem.removeEventListener('mouseout' , moOut);
- })
- });
- option.document.addEventListener('beforeunload', function() {
- isClosed = true;
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment