Agma.io Scroll Buttons

lets you scroll zoom on agma with ease if you're on a laptop without a mouse.

  1. // ==UserScript==
  2. // @name Agma.io Scroll Buttons
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.2
  5. // @description lets you scroll zoom on agma with ease if you're on a laptop without a mouse.
  6. // @icon https://www.google.com/s2/favicons?sz=64&domain=agma.io
  7. // @author Day
  8. // @license GPL-3.0-or-later
  9. // @match https://agma.io/*
  10. // @grant none
  11. // ==/UserScript==
  12.  
  13. (function() {
  14. 'use strict';
  15.  
  16. const scrollUpButton = document.createElement('button');
  17. scrollUpButton.id = 'scrollUpButton';
  18. scrollUpButton.innerText = '▲';
  19. scrollUpButton.style.position = 'fixed';
  20. scrollUpButton.style.top = '10px';
  21. scrollUpButton.style.left = '400px';
  22. scrollUpButton.style.width = '30px';
  23. scrollUpButton.style.height = '30px';
  24. scrollUpButton.style.borderRadius = '50%';
  25. scrollUpButton.style.backgroundColor = '#ffffff';
  26. scrollUpButton.style.color = '#000000';
  27. scrollUpButton.style.fontSize = '16px';
  28. scrollUpButton.style.fontWeight = 'bold';
  29. scrollUpButton.style.border = 'none';
  30. scrollUpButton.style.outline = 'none';
  31. document.body.appendChild(scrollUpButton);
  32.  
  33. const scrollDownButton = document.createElement('button');
  34. scrollDownButton.id = 'scrollDownButton';
  35. scrollDownButton.innerText = '▼';
  36. scrollDownButton.style.position = 'fixed';
  37. scrollDownButton.style.top = '10px';
  38. scrollDownButton.style.left = '440px';
  39. scrollDownButton.style.width = '30px';
  40. scrollDownButton.style.height = '30px';
  41. scrollDownButton.style.borderRadius = '50%';
  42. scrollDownButton.style.backgroundColor = '#ffffff';
  43. scrollDownButton.style.color = '#000000';
  44. scrollDownButton.style.fontSize = '16px';
  45. scrollDownButton.style.fontWeight = 'bold';
  46. scrollDownButton.style.border = 'none';
  47. scrollDownButton.style.outline = 'none';
  48. document.body.appendChild(scrollDownButton);
  49.  
  50. document.getElementById('scrollUpButton').addEventListener('click', function() {
  51. const container = document.getElementById('canvas');
  52. simulateScroll(container, -100);
  53. });
  54.  
  55. document.getElementById('scrollDownButton').addEventListener('click', function() {
  56. const container = document.getElementById('canvas');
  57. simulateScroll(container, 100);
  58. });
  59.  
  60. function simulateScroll(element, deltaY) {
  61. const event = new WheelEvent('wheel', {
  62. bubbles: true,
  63. deltaY: deltaY,
  64. view: window
  65. });
  66. element.dispatchEvent(event);
  67. }
  68. })();