Add Extra Fonts to Google Docs/Slides

Add extra fonts to the Google Docs and Google Slides font dropdown menus

  1. // ==UserScript==
  2. // @name Add Extra Fonts to Google Docs/Slides
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.1
  5. // @description Add extra fonts to the Google Docs and Google Slides font dropdown menus
  6. // @match https://docs.google.com/document/d/*
  7. // @match https://docs.google.com/presentation/d/*
  8. // @grant none
  9. // @run-at document-end
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. 'use strict';
  14.  
  15. function addFontsToDropdown() {
  16. // Wait for the Google Docs/Slides page to fully load
  17. const interval = setInterval(() => {
  18. // Select the font dropdown element
  19. const fontDropdown = document.querySelector('.quantumWizMenuPaperselectPopup');
  20. if (fontDropdown) {
  21. // Clear the interval once the dropdown is found
  22. clearInterval(interval);
  23. // Define the extra fonts to add
  24. const extraFonts = ['Comic Sans MS', 'Arial Black', 'Courier New'];
  25. // Add the extra fonts to the dropdown
  26. extraFonts.forEach(font => {
  27. const fontOption = document.createElement('div');
  28. fontOption.className = 'quantumWizMenuPaperselectOption';
  29. fontOption.textContent = font;
  30. fontDropdown.appendChild(fontOption);
  31. });
  32.  
  33. // Optionally, you can also add event listeners to handle font selection
  34. // Example:
  35. // fontDropdown.addEventListener('click', function(event) {
  36. // if (event.target && event.target.className.includes('quantumWizMenuPaperselectOption')) {
  37. // const selectedFont = event.target.textContent;
  38. // // Apply the selected font to the document
  39. // }
  40. // });
  41. }
  42. }, 1000); // Check every second
  43. }
  44.  
  45. // Add extra fonts to the dropdown when the page loads
  46. window.addEventListener('load', addFontsToDropdown);
  47. })();