Colab: Arrow Assignment Operator with Fira Font (←)

Use Fira Mono in Colab with Fira Code for spans containing '<-' for better arrow appearance

Mint 2025.07.18.. Lásd a legutóbbi verzió

// ==UserScript==
// @name         Colab: Arrow Assignment Operator with Fira Font (←)
// @namespace    https://greasyfork.org/users/867680
// @version      1.2
// @description  Use Fira Mono in Colab with Fira Code for spans containing '<-' for better arrow appearance
// @author       You
// @match        https://colab.research.google.com/drive/*
// @grant        GM_addStyle
// @run-at       document-idle
// @license      MIT
// ==/UserScript==

(function () {
  GM_addStyle(`
    @import url('https://fonts.googleapis.com/css2?family=Fira+Mono&display=swap');
    @import url('https://cdn.jsdelivr.net/gh/tonsky/FiraCode@4/distr/fira_code.css');

    .view-line,
    .monaco-editor .mtk {
      font-family: 'Fira Mono', monospace !important;
      font-feature-settings: "liga" on, "calt" on;
      font-variant-ligatures: none;
      font-size: 13px !important;
      //text-shadow: 0 0 0.3px currentColor;
    }
  `);

  const patchArrowSpans = () => {
    const spans = document.querySelectorAll('.view-line span');

    for (const span of spans) {
      if (
        span.childNodes.length === 1 &&
        span.textContent.includes('<-') &&
        !span.dataset.arrowFixed
      ) {
        span.style.fontFamily = "'Fira Code', monospace";
        span.style.display = 'inline-block';
        span.dataset.arrowFixed = 'true';
      }
    }
  };

  setInterval(patchArrowSpans, 300);
})(); // generated with ChatGPT