Notion Font Customizer

Customize font in Notion pages.

目前為 2019-01-04 提交的版本,檢視 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Notion Font Customizer
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  Customize font in Notion pages.
// @author       MiracleXYZ
// @include      http*://www.notion.so/*
// @exclude      http*://www.notion.so/appcache2.html
// @require      http://libs.baidu.com/jquery/2.0.0/jquery.min.js
// ==/UserScript==


function changeStyle() {
    function GetUrlParam(paraName) {
    var url = document.location.toString();
    var arrObj = url.split("?");

    if (arrObj.length > 1) {
      var arrPara = arrObj[1].split("&");
      var arr;

      for (var i = 0; i < arrPara.length; i++) {
        arr = arrPara[i].split("=");

        if (arr != null && arr[0] == paraName) {
          return arr[1];
        }
      }
      return "";
    }
    else {
      return "";
    }
  }

    function pathToBlock (path) {
        pathList = path.split("-");
        realPath = pathList[pathList.length - 1];
        return [
            realPath.slice(0, 8),
            realPath.slice(8, 12),
            realPath.slice(12, 16),
            realPath.slice(16, 20),
            realPath.slice(20)
        ].join("-");
    }

    var blocks = [];

    var pathname = window.location.pathname;
    var path = pathname.split("/")[2];
    blocks.push(pathToBlock(path));

    var search = window.location.search;
    var params = search.slice(1).split("&");
    for (idx in params) {
        if (params[idx][0] == "p") {
            blocks.push(pathToBlock(params[idx].slice(2)));
        }
    };

    console.log(blocks);

    for (idx in blocks) {
        block = blocks[idx];
        $("div.notion-selectable[data-block-id='" + block + "']").css({
            "font-family": "Times New Roman, 宋体"
        });
        console.log("Font changed.");
    }

    $("div.notion-page-content").css({
        "font-size": "16px",
        "font-family": "Times New Roman, 宋体"
    });
}

// $(window).on("load", changeStyle);

$(document).keyup(function(e) {
    if(e.keyCode == 71 && e.ctrlKey && e.altKey){
        // alert("You pressed Ctrl + Alt + G!");
        changeStyle();
    }
});