38 lines
1.1 KiB
JavaScript
38 lines
1.1 KiB
JavaScript
// ==UserScript==
|
|
// @name LC Font Changer
|
|
// @namespace http://tampermonkey.net/
|
|
// @version 2024-08-01
|
|
// @description Configure a custom font for Leetcode's code editor
|
|
// @author Sangeeth Sudheer
|
|
// @match https://leetcode.com/problems/*
|
|
// @icon https://www.google.com/s2/favicons?sz=64&domain=leetcode.com
|
|
// @grant unsafeWindow
|
|
// @grant GM_getValue
|
|
// @grant GM_setValue
|
|
// ==/UserScript==
|
|
|
|
(function() {
|
|
'use strict';
|
|
|
|
function waitForLoad(cb) {
|
|
if ((unsafeWindow.monaco?.editor?.getEditors?.()?.length ?? 0) > 0) {
|
|
console.log("Invoking callback");
|
|
cb();
|
|
} else {
|
|
setTimeout(() => waitForLoad(cb), 1000);
|
|
}
|
|
}
|
|
|
|
function getFontFamily() {
|
|
let savedValue = GM_getValue("fontFamily", null);
|
|
|
|
if (!savedValue) {
|
|
GM_setValue("fontFamily", "Courier");
|
|
savedValue = "Courier";
|
|
}
|
|
|
|
return savedValue;
|
|
}
|
|
|
|
waitForLoad(() => unsafeWindow.monaco.editor.getEditors()[0].updateOptions({ fontFamily: getFontFamily() }));
|
|
})(); |