Skip to content

Instantly share code, notes, and snippets.

@LouisGameDev
Last active February 27, 2025 11:11
Show Gist options
  • Save LouisGameDev/1ce3007b0fe9811106e0779d61fdbea4 to your computer and use it in GitHub Desktop.
Save LouisGameDev/1ce3007b0fe9811106e0779d61fdbea4 to your computer and use it in GitHub Desktop.

Revisions

  1. LouisGameDev revised this gist Feb 27, 2025. 1 changed file with 107 additions and 90 deletions.
    197 changes: 107 additions & 90 deletions RuneScape Font.user.js
    Original file line number Diff line number Diff line change
    @@ -2,99 +2,116 @@
    // @name RuneScape Font 16px
    // @version 1.1
    // @author Dawncore/Louis Hong
    // @description Injects RuneScape fonts and font size to all websites
    // @description Injects RuneScape fonts and dynamically adjusts text-shadow based on page color
    // @icon https://www.google.com/s2/favicons?sz=64&domain=runescape.com
    // @match *://*/*
    // @grant GM_addStyle
    // ==/UserScript==

    (function() {
    // Inject the CSS rules
    (function () {
    // Inject the CSS with a dynamic variable for text-shadow
    GM_addStyle(`
    :root {
    --text-shadow: 1px 1px 0 #000; /* Default shadow */
    }
    /* Default everything to RuneScape Plain 12 Regular at 16px */
    html body,
    html body p,
    html body span,
    html body div,
    html body a,
    html body li,
    html body pre,
    html body code,
    html body kbd,
    html body samp,
    html body .hljs,
    html body .hljs * {
    font-family: "RuneScape Plain 12" !important;
    font-size: 16px !important;
    font-style: normal !important; /* disables italics */
    -webkit-font-smoothing: none !important;
    -moz-osx-font-smoothing: none !important;
    font-smooth: never !important;
    text-shadow: 1px 1px 0 #000 !important;
    }
    /* Bold text → Use bold font */
    html body b,
    html body b *,
    html body strong,
    html body strong * {
    font-family: "RuneScape 12" !important;
    font-weight: bold !important;
    -webkit-font-smoothing: none !important;
    -moz-osx-font-smoothing: none !important;
    font-smooth: never !important;
    text-shadow: 1px 1px 0 #000 !important;
    }
    /* Headers → Use bold font */
    html body h1,
    html body h1 *,
    html body h2,
    html body h2 *,
    html body h3,
    html body h3 *,
    html body h4,
    html body h4 *,
    html body h5,
    html body h5 *,
    html body h6,
    html body h6 * {
    font-family: "RuneScape 12" !important;
    font-size: 16px !important;
    font-weight: bold !important;
    font-style: normal !important; /* disables italics */
    -webkit-font-smoothing: none !important;
    -moz-osx-font-smoothing: none !important;
    font-smooth: never !important;
    text-shadow: 1px 1px 0 #000 !important;
    }
    html body sup {
    font-family: "RuneScape Plain 11" !important;
    font-size: 11px !important;
    font-style: normal !important; /* disables italics */
    -webkit-font-smoothing: none !important;
    -moz-osx-font-smoothing: none !important;
    font-smooth: never !important;
    text-shadow: 1px 1px 0 #000 !important;
    }
    html body em,
    html body i {
    font-family: "RuneScape Plain 11" !important;
    font-size: 16px !important;
    font-style: normal !important; /* disables italics */
    -webkit-font-smoothing: none !important;
    -moz-osx-font-smoothing: none !important;
    font-smooth: never !important;
    text-shadow: 1px 1px 0 #000 !important;
    }
    `);
    })();
    html body,
    html body p,
    html body span,
    html body div,
    html body a,
    html body li,
    html body pre,
    html body code,
    html body kbd,
    html body samp,
    html body .hljs,
    html body .hljs * {
    font-family: "RuneScape Plain 12" !important;
    font-size: 16px !important;
    -webkit-font-smoothing: none !important;
    -moz-osx-font-smoothing: none !important;
    font-smooth: never !important;
    font-style: normal !important;
    text-shadow: var(--text-shadow) !important;
    }
    /* Bold text → Use bold font */
    html body b,
    html body b *,
    html body strong,
    html body strong * {
    font-family: "RuneScape 12" !important;
    font-weight: bold !important;
    font-style: normal !important;
    text-shadow: var(--text-shadow) !important;
    }
    /* Headers → Use bold font */
    html body h1,
    html body h1 *,
    html body h2,
    html body h2 *,
    html body h3,
    html body h3 *,
    html body h4,
    html body h4 *,
    html body h5,
    html body h5 *,
    html body h6,
    html body h6 * {
    font-family: "RuneScape 12" !important;
    font-size: 16px !important;
    font-weight: bold !important;
    font-style: normal !important;
    text-shadow: var(--text-shadow) !important;
    }
    html body sup {
    font-family: "RuneScape Plain 11" !important;
    font-size: 11px !important;
    font-style: normal !important;
    text-shadow: var(--text-shadow) !important;
    }
    html body em,
    html body i {
    font-family: "RuneScape Plain 11" !important;
    font-size: 16px !important;
    font-style: normal !important;
    text-shadow: var(--text-shadow) !important;
    }
    `);

    function adjustTextShadow() {
    const allEls = document.querySelectorAll("body *");
    let blackTextCount = 0;
    let totalTextCount = 0;

    allEls.forEach(el => {
    const color = window.getComputedStyle(el).color;
    if (!color) return;
    totalTextCount++;

    if (color === "rgb(0, 0, 0)") {
    blackTextCount++;
    }
    });

    // If 80%+ of text is black, disable text-shadow
    if (blackTextCount / totalTextCount >= 0.3) {
    document.documentElement.style.setProperty("--text-shadow", "none");
    }

    console.log("Black text percentile: " + blackTextCount / totalTextCount);

    }

    adjustTextShadow();
    })();
  2. LouisGameDev revised this gist Feb 27, 2025. 1 changed file with 15 additions and 1 deletion.
    16 changes: 15 additions & 1 deletion RuneScape Font.user.js
    Original file line number Diff line number Diff line change
    @@ -82,5 +82,19 @@ html body sup {
    text-shadow: 1px 1px 0 #000 !important;
    }
    `);
    html body em,
    html body i {
    font-family: "RuneScape Plain 11" !important;
    font-size: 16px !important;
    font-style: normal !important; /* disables italics */
    -webkit-font-smoothing: none !important;
    -moz-osx-font-smoothing: none !important;
    font-smooth: never !important;
    text-shadow: 1px 1px 0 #000 !important;
    }
    `);
    })();
  3. LouisGameDev revised this gist Feb 27, 2025. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion RuneScape Font.user.js
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,6 @@
    // ==UserScript==
    // @name RuneScape Font 16px
    // @version 1.0
    // @version 1.1
    // @author Dawncore/Louis Hong
    // @description Injects RuneScape fonts and font size to all websites
    // @match *://*/*
  4. LouisGameDev revised this gist Feb 27, 2025. 1 changed file with 19 additions and 11 deletions.
    30 changes: 19 additions & 11 deletions RuneScape Font.user.js
    Original file line number Diff line number Diff line change
    @@ -1,25 +1,25 @@
    // ==UserScript==
    // @name RuneScape Font 16px
    // @version 1.0
    // @author Dawncore/Louis Hong
    // @description Injects RuneScape fonts with size rounding on every webpage
    // @author Dawncore/Louis Hong
    // @description Injects RuneScape fonts and font size to all websites
    // @match *://*/*
    // @grant GM_addStyle
    // ==/UserScript==

    (function() {
    // 1. Inject the CSS rules
    // Inject the CSS rules
    GM_addStyle(`
    /* Default everything to RuneScape Plain 12 Regular at 16px */
    html body *,
    /* optional pseudo element override. lots of websites use pseudo elemnets for icon fonts. will break and turn them into "?"
    html body *::before,
    html body *::after,
    */
    html body,
    html body p,
    html body span,
    html body div,
    html body a,
    html body li,
    html body pre,
    html body code,
    html body text,
    html body kbd,
    html body samp,
    html body .hljs,
    @@ -30,6 +30,8 @@ html body .hljs * {
    -webkit-font-smoothing: none !important;
    -moz-osx-font-smoothing: none !important;
    font-smooth: never !important;
    text-shadow: 1px 1px 0 #000 !important;
    }
    /* Bold text → Use bold font */
    @@ -42,9 +44,11 @@ html body strong * {
    -webkit-font-smoothing: none !important;
    -moz-osx-font-smoothing: none !important;
    font-smooth: never !important;
    text-shadow: 1px 1px 0 #000 !important;
    }
    /* Headers → Use bold font*/
    /* Headers → Use bold font */
    html body h1,
    html body h1 *,
    html body h2,
    @@ -58,11 +62,14 @@ html body h5 *,
    html body h6,
    html body h6 * {
    font-family: "RuneScape 12" !important;
    font-size: 16px !important;
    font-weight: bold !important;
    font-style: normal !important; /* disables italics */
    -webkit-font-smoothing: none !important;
    -moz-osx-font-smoothing: none !important;
    font-smooth: never !important;
    text-shadow: 1px 1px 0 #000 !important;
    }
    html body sup {
    @@ -72,7 +79,8 @@ html body sup {
    -webkit-font-smoothing: none !important;
    -moz-osx-font-smoothing: none !important;
    font-smooth: never !important;
    text-shadow: 1px 1px 0 #000 !important;
    }
    `);

    })();
  5. LouisGameDev revised this gist Feb 23, 2025. 1 changed file with 4 additions and 1 deletion.
    5 changes: 4 additions & 1 deletion RuneScape Font.user.js
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,5 @@
    // ==UserScript==
    // @name RuneScape Font + Rounding
    // @name RuneScape Font 16px
    // @version 1.0
    // @author Dawncore/Louis Hong
    // @description Injects RuneScape fonts with size rounding on every webpage
    @@ -10,10 +10,13 @@
    (function() {
    // 1. Inject the CSS rules
    GM_addStyle(`
    /* Default everything to RuneScape Plain 12 Regular at 16px */
    html body *,
    /* optional pseudo element override. lots of websites use pseudo elemnets for icon fonts. will break and turn them into "?"
    html body *::before,
    html body *::after,
    */
    html body pre,
    html body code,
    html body text,
  6. LouisGameDev revised this gist Jan 27, 2025. No changes.
  7. LouisGameDev renamed this gist Jan 27, 2025. 1 changed file with 0 additions and 0 deletions.
  8. LouisGameDev revised this gist Jan 27, 2025. No changes.
  9. LouisGameDev created this gist Jan 27, 2025.
    75 changes: 75 additions & 0 deletions RuneScape Font + Rounding.user.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,75 @@
    // ==UserScript==
    // @name RuneScape Font + Rounding
    // @version 1.0
    // @author Dawncore/Louis Hong
    // @description Injects RuneScape fonts with size rounding on every webpage
    // @match *://*/*
    // @grant GM_addStyle
    // ==/UserScript==

    (function() {
    // 1. Inject the CSS rules
    GM_addStyle(`
    /* Default everything to RuneScape Plain 12 Regular at 16px */
    html body *,
    html body *::before,
    html body *::after,
    html body pre,
    html body code,
    html body text,
    html body kbd,
    html body samp,
    html body .hljs,
    html body .hljs * {
    font-family: "RuneScape Plain 12" !important;
    font-size: 16px !important;
    font-style: normal !important; /* disables italics */
    -webkit-font-smoothing: none !important;
    -moz-osx-font-smoothing: none !important;
    font-smooth: never !important;
    }
    /* Bold text → Use bold font */
    html body b,
    html body b *,
    html body strong,
    html body strong * {
    font-family: "RuneScape 12" !important;
    font-weight: bold !important;
    -webkit-font-smoothing: none !important;
    -moz-osx-font-smoothing: none !important;
    font-smooth: never !important;
    }
    /* Headers → Use bold font*/
    html body h1,
    html body h1 *,
    html body h2,
    html body h2 *,
    html body h3,
    html body h3 *,
    html body h4,
    html body h4 *,
    html body h5,
    html body h5 *,
    html body h6,
    html body h6 * {
    font-family: "RuneScape 12" !important;
    font-weight: bold !important;
    font-style: normal !important; /* disables italics */
    -webkit-font-smoothing: none !important;
    -moz-osx-font-smoothing: none !important;
    font-smooth: never !important;
    }
    html body sup {
    font-family: "RuneScape Plain 11" !important;
    font-size: 11px !important;
    font-style: normal !important; /* disables italics */
    -webkit-font-smoothing: none !important;
    -moz-osx-font-smoothing: none !important;
    font-smooth: never !important;
    }
    `);

    })();