Add lc-font-changer
This commit is contained in:
parent
dec55fd62b
commit
f372e58b89
38
lc-font-changer/lc-font-changer.user.js
Normal file
38
lc-font-changer/lc-font-changer.user.js
Normal file
@ -0,0 +1,38 @@
|
||||
// ==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() }));
|
||||
})();
|
Loading…
Reference in New Issue
Block a user