Google AI Studio, Fix Google Symbols Rendering for Opera

Selective font and text replacement for Material Symbols

  1. // ==UserScript==
  2. // @name Google AI Studio, Fix Google Symbols Rendering for Opera
  3. // @namespace http://tampermonkey.net/
  4. // @version 2.3
  5. // @description Selective font and text replacement for Material Symbols
  6. // @author TheDerevtso
  7. // @match https://aistudio.google.com/*
  8. // @grant GM_addStyle
  9. // @run-at document-body
  10. // @license MIT
  11. // ==/UserScript==
  12.  
  13. (function() {
  14. 'use strict';
  15.  
  16. GM_addStyle(`
  17. /* Base rule for Material Symbols */
  18. .material-symbols-outlined:not(.ng-star-inserted):not(.item-about) {
  19. font-family: 'Material Symbols Outlined' !important;
  20. }
  21.  
  22. /* Exception for specific nested structure */
  23. .ng-star-inserted .item-about .material-symbols-outlined {
  24. font-family: 'Google Symbols' !important;
  25. }
  26.  
  27. /* Handling elements with ng-star-inserted */
  28. .material-symbols-outlined.ng-star-inserted:not(.item-about) {
  29. font-family: 'Material Symbols Outlined' !important;
  30. }
  31. `);
  32.  
  33. const replacements = [
  34. {
  35. selector: '.save-button .material-symbols-outlined',
  36. closest: '.save-button',
  37. oldText: 'drive',
  38. newText: 'add_to_drive',
  39. replaced: false
  40. },
  41. {
  42. selector: 'a[aria-label="Create Prompt"] .material-symbols-outlined',
  43. closest: 'a[aria-label="Create Prompt"]',
  44. oldText: 'chat_spark',
  45. newText: 'add_comment',
  46. replaced: false
  47. }
  48. ];
  49.  
  50. const closestSelectors = replacements.map(item => item.closest).join(', ');
  51.  
  52. function processReplacements() {
  53. let allReplaced = true;
  54. replacements.forEach(repl => {
  55. if (!repl.replaced) {
  56. document.querySelectorAll(repl.selector).forEach(icon => {
  57. if (icon.textContent.trim() === repl.oldText) {
  58. icon.textContent = repl.newText;
  59. repl.replaced = true;
  60. }
  61. });
  62. }
  63. if (!repl.replaced) allReplaced = false;
  64. });
  65. return allReplaced;
  66. }
  67.  
  68. // Optimized MutationObserver
  69. new MutationObserver((mutations,observer) => {
  70. mutations.forEach(mutation => {
  71. if (mutation.target.closest(closestSelectors)) {
  72. if (processReplacements()) {
  73. observer.disconnect(); // Stop observing after all replacements
  74. }
  75. }
  76. });
  77. }).observe(document.body, {
  78. childList: true,
  79. subtree: true
  80. });
  81.  
  82. })();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址