Google Custom Style with Tampermonkey Settings

Customize Google's logos, buttons, icons, and text with Tampermonkey's settings interface

  1. // ==UserScript==
  2. // @name Google Custom Style with Tampermonkey Settings
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.2
  5. // @description Customize Google's logos, buttons, icons, and text with Tampermonkey's settings interface
  6. // @author You
  7. // @match https://www.google.com/*
  8. // @grant GM_addStyle
  9. // @grant GM_registerMenuCommand
  10. // @grant GM_setValue
  11. // @grant GM_getValue
  12. // ==/UserScript==
  13.  
  14. (function() {
  15. 'use strict';
  16.  
  17. // Default settings
  18. let defaultSettings = {
  19. logoSize: 100,
  20. logoPosition: 0,
  21. };
  22.  
  23. // Get stored settings or use defaults
  24. let logoSize = GM_getValue('logoSize', defaultSettings.logoSize);
  25. let logoPosition = GM_getValue('logoPosition', defaultSettings.logoPosition);
  26.  
  27. // Apply initial styles
  28. function applyStyles() {
  29. GM_addStyle(`
  30. img[alt="Google"] {
  31. width: ${logoSize}px !important;
  32. transform: translateX(${logoPosition}px) !important;
  33. }
  34. `);
  35. }
  36.  
  37. // Function to prompt user for input and save settings
  38. function openSettings() {
  39. logoSize = parseInt(prompt('Set logo size (50-300):', logoSize), 10);
  40. logoPosition = parseInt(prompt('Set logo position (-100 to 100):', logoPosition), 10);
  41.  
  42. // Save new settings
  43. GM_setValue('logoSize', logoSize);
  44. GM_setValue('logoPosition', logoPosition);
  45.  
  46. // Apply new styles
  47. applyStyles();
  48. }
  49.  
  50. // Register the settings menu command in Tampermonkey
  51. GM_registerMenuCommand('Customize Google Style', openSettings);
  52.  
  53. // Apply the initial styles when the script runs
  54. applyStyles();
  55. })();