Custom Styling for Manning LiveBook

Apply custom CSS to improve readability on Manning LiveBook

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         Custom Styling for Manning LiveBook
// @namespace    http://tampermonkey.net/
// @version      0.16
// @description  Apply custom CSS to improve readability on Manning LiveBook
// @match        https://livebook.manning.com/*
// @grant        GM_addStyle
// @run-at       document-start
// @license MIT
// ==/UserScript==

(function() {
    'use strict';

    // Add Google Fonts link
    const linkElement = document.createElement('link');
    linkElement.rel = 'stylesheet';
    linkElement.href = 'https://fonts.googleapis.com/css2?family=Source+Serif+4:ital,opsz,wght@0,8..60,200..900;1,8..60,200..900&display=swap';
    document.head.appendChild(linkElement);

    GM_addStyle(`
        @import url('https://fonts.googleapis.com/css2?family=Source+Serif+4:ital,opsz,wght@0,8..60,200..900;1,8..60,200..900&display=swap');

        div.text-marginalia-item {
            font-size: 15px;
            font-family: 'Source Serif 4', serif;
            font-weight: 350;
            line-height: 22px;
            color: #cccccc;
        }

        span.highlighted-note-text, span.highlighted-text {
            background-repeat: no-repeat !important;
            background-size: 100% 90% !important;
            background-position: 0 75% !important;
            color: rgb(255, 255, 255) !important;
        }
        
        span.highlighted-text {
            background-color: hsl(50deg 100% 50% / 15%) !important;
            border-bottom-color: hsl(50deg 100% 50% / 80%) !important;
        }
        
        span.highlighted-note-text {
          background-color: hsl(50deg 100% 50% / 15%) !important;
          border-bottom-color: hsl(40deg 100% 50% / 80%) !important;
        }
        
        div.note-content-container.note-content-container-can-edit {
          line-height: 20px;
        }

        #main-page-content {
            background-color: #151c23;
            font-size: 15px;
        }

        #book-markup-container {
            max-width: 760px;
            margin-left: auto;
            margin-right: auto;
        }

        div div p, li {
              font-family: 'Source Serif 4';
              color: rgb(193, 199, 206);
              line-height: 22px;
              font-weight: 350;
              font-size: 15px;
              font-feature-settings: "kern", "liga", "clig", "calt", "onum";
              font-variation-settings: "opsz" 16;
              font-kerning: auto;
              text-rendering: optimizelegibility;
              font-optical-sizing: auto;
        }
        
        li {
            line-height: 28px;
        }

        div p i {
          font-family: 'Source Serif 4' !important;
          font-weight: 550 !important;
          font-style: italic !important;
        }
    `);
})();