Gartic background change

Choose the desired image or gif for the Gartic background

  1. // ==UserScript==
  2. // @name Gartic background change
  3. // @description Choose the desired image or gif for the Gartic background
  4. // @version 1.0
  5. // @author STRAGON
  6. // @license N/A
  7. // @match *://gartic.io/*
  8. // @match *://*/*?__cpo=aHR0cHM6Ly9nYXJ0aWMuaW8
  9. // @icon https://static.cdnlogo.com/logos/s/96/st.svg
  10. // @grant GM_addStyle
  11. // @namespace https://greasyfork.org/en/users/1353946-stragon-x
  12. // ==/UserScript==
  13.  
  14. (function() {
  15. 'use strict';
  16.  
  17. var imageUrl = localStorage.getItem('imageUrl');
  18.  
  19. if (window.location.href.indexOf('https://gartic.io') !== -1) {
  20. if (imageUrl) {
  21. GM_addStyle('body { background: url("' + imageUrl + '") no-repeat fixed center; background-size: cover; }');
  22. }
  23.  
  24. var button = document.createElement('button');
  25.  
  26. button.textContent = 'Change Background';
  27. button.style.zIndex = '99999';
  28. button.style.backgroundColor = 'red';
  29. button.style.position = 'fixed';
  30. button.style.bottom = '0px';
  31. button.style.right = '0px';
  32. button.style.padding = '10px 20px';
  33. button.style.fontSize = '16px';
  34. button.style.borderRadius = '5px';
  35. button.onclick = function() {
  36. var input = document.createElement('input');
  37. input.type = 'file';
  38. input.accept = 'image/*';
  39. input.onchange = function() {
  40. var file = input.files[0];
  41. var reader = new FileReader();
  42. reader.onload = function(event) {
  43. var newImageUrl = event.target.result;
  44. localStorage.setItem('imageUrl', newImageUrl);
  45. GM_addStyle('body { background: url("' + newImageUrl + '") no-repeat fixed center; background-size: cover; }');
  46. };
  47. reader.readAsDataURL(file);
  48. };
  49. input.click();
  50. };
  51. document.body.appendChild(button);
  52. document.getElementById('background').remove();
  53.  
  54. }
  55. })();