Agar.io Custom Skin with Border Color

Upload a custom skin and set the border color in Agar.io

  1. // ==UserScript==
  2. // @name Agar.io Custom Skin with Border Color
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.1
  5. // @description Upload a custom skin and set the border color in Agar.io
  6. // @author You
  7. // @match http://agar.io/*
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11. (function() {
  12. 'use strict';
  13.  
  14. // Wait for Agar.io's script to load
  15. window.addEventListener('load', function() {
  16. let buttonContainer = document.querySelector('.game-container'); // Find the main game container
  17. if (buttonContainer) {
  18. // Create a custom "Upload Image" button
  19. let uploadButton = document.createElement('button');
  20. uploadButton.innerText = 'Subir Imagen';
  21. uploadButton.style.position = 'absolute';
  22. uploadButton.style.top = '10px';
  23. uploadButton.style.right = '10px';
  24. uploadButton.style.padding = '10px';
  25. uploadButton.style.backgroundColor = '#4CAF50';
  26. uploadButton.style.color = 'white';
  27. uploadButton.style.border = 'none';
  28. uploadButton.style.cursor = 'pointer';
  29. uploadButton.style.zIndex = '9999';
  30.  
  31. // Create the color selector
  32. let colorSelector = document.createElement('select');
  33. colorSelector.innerHTML = `
  34. <option value="black">Negro</option>
  35. <option value="white">Blanco</option>
  36. <option value="red">Rojo</option>
  37. <option value="yellow">Amarillo</option>
  38. <option value="blue">Azul</option>
  39. <option value="green">Verde</option>
  40. `;
  41. colorSelector.style.position = 'absolute';
  42. colorSelector.style.top = '50px';
  43. colorSelector.style.right = '10px';
  44. colorSelector.style.padding = '5px';
  45. colorSelector.style.zIndex = '9999';
  46.  
  47. // Append the button and the color selector to the page
  48. buttonContainer.appendChild(uploadButton);
  49. buttonContainer.appendChild(colorSelector);
  50.  
  51. // Handle the image upload
  52. uploadButton.addEventListener('click', function() {
  53. let input = document.createElement('input');
  54. input.type = 'file';
  55. input.accept = 'image/*';
  56. input.click();
  57. input.addEventListener('change', function(event) {
  58. let file = event.target.files[0];
  59. if (file) {
  60. let reader = new FileReader();
  61. reader.onload = function(e) {
  62. let img = new Image();
  63. img.src = e.target.result;
  64. img.onload = function() {
  65. // Apply custom skin to the player in the game
  66. window.game.skin = img;
  67. alert('¡Imagen subida con éxito!');
  68. };
  69. };
  70. reader.readAsDataURL(file);
  71. }
  72. });
  73. });
  74.  
  75. // Update the border color based on the selected option
  76. colorSelector.addEventListener('change', function() {
  77. let selectedColor = colorSelector.value;
  78.  
  79. // Update the border color on the player's skin
  80. window.game.setPlayerBorderColor(selectedColor); // This may depend on the game's specific functions
  81. alert(`Borde de la skin cambiado a: ${selectedColor}`);
  82. });
  83. }
  84. });
  85. })();