Auto Clicker

Auto Clicker for Browsers!!

  1. // ==UserScript==
  2. // @name Auto Clicker
  3. // @namespace https://greasyfork.org/en/users/988790
  4. // @version 1.6
  5. // @description Auto Clicker for Browsers!!
  6. // @author pixxy
  7. // @match *://*/*
  8. // @grant none
  9. // @icon https://image.flaticon.com/icons/svg/99/99188.svg
  10. // @compatible chrome
  11. // @compatible firefox
  12. // @compatible opera
  13. // @compatible safari
  14. // ==/UserScript==
  15.  
  16. let x,y,set,cps=10;
  17.  
  18. document.addEventListener('keyup',function(evt){
  19. if(evt.keyCode==77&&evt.altKey){
  20. if(!set==true){
  21. set=true;
  22. let inp=prompt("How many clicks would you like per second? Recommended Max : 100,000 cps");
  23. if(!isNaN(inp)&&inp.trim().length>0){
  24. if(inp>100000){
  25. let check=confirm(`${inp} clicks per second may crash your browser! Are you sure you would like to continue?`)
  26. if(check){
  27. alert("Ok whatever you say...");
  28. console.warn("Idiot...");
  29. cps=inp;
  30. }
  31. else{
  32. set=false;
  33. alert("Thanks for understanding. Please click ctrl + m to try again.")
  34. }
  35. }
  36. else if(inp<1000){
  37. cps=1000;
  38. }
  39. else{
  40. cps=inp;
  41. }
  42. }
  43. alert("You may now click on any point in this tab to set the autoclicker to it. Have fun !!");
  44. onmousedown = function(e){
  45. x=e.clientX;
  46. y=e.clientY;
  47. };
  48. let autoClick=setInterval(function(){
  49. if(x!==undefined&&y!==undefined&&set==true){
  50. for(let i=0;i<cps/1000;i++){
  51. click(x,y);
  52. }
  53. }
  54. },1)}
  55. else{
  56. set=false
  57. }
  58. }
  59. })
  60.  
  61.  
  62. function click(x, y){
  63. let ev = new MouseEvent('click', {
  64. 'view': window,
  65. 'bubbles': true,
  66. 'cancelable': true,
  67. 'screenX': x,
  68. 'screenY': y
  69. });
  70.  
  71. let el = document.elementFromPoint(x, y);
  72. el.dispatchEvent(ev);
  73. }
  74.  
  75.