Notion Font Customizer

Customize font in Notion pages.

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

  1. // ==UserScript==
  2. // @name Notion Font Customizer
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.1
  5. // @description Customize font in Notion pages.
  6. // @author MiracleXYZ
  7. // @include http*://www.notion.so/*
  8. // @exclude http*://www.notion.so/appcache2.html
  9. // @require http://libs.baidu.com/jquery/2.0.0/jquery.min.js
  10. // ==/UserScript==
  11.  
  12.  
  13. function changeStyle() {
  14. function GetUrlParam(paraName) {
  15.     var url = document.location.toString();
  16.     var arrObj = url.split("?");
  17.  
  18.     if (arrObj.length > 1) {
  19.       var arrPara = arrObj[1].split("&");
  20.       var arr;
  21.  
  22.       for (var i = 0; i < arrPara.length; i++) {
  23.         arr = arrPara[i].split("=");
  24.  
  25.         if (arr != null && arr[0] == paraName) {
  26.           return arr[1];
  27.         }
  28.       }
  29.       return "";
  30.     }
  31.     else {
  32.       return "";
  33.     }
  34.   }
  35.  
  36. function pathToBlock (path) {
  37. pathList = path.split("-");
  38. realPath = pathList[pathList.length - 1];
  39. return [
  40. realPath.slice(0, 8),
  41. realPath.slice(8, 12),
  42. realPath.slice(12, 16),
  43. realPath.slice(16, 20),
  44. realPath.slice(20)
  45. ].join("-");
  46. }
  47.  
  48. var blocks = [];
  49.  
  50. var pathname = window.location.pathname;
  51. var path = pathname.split("/")[2];
  52. blocks.push(pathToBlock(path));
  53.  
  54. var search = window.location.search;
  55. var params = search.slice(1).split("&");
  56. for (idx in params) {
  57. if (params[idx][0] == "p") {
  58. blocks.push(pathToBlock(params[idx].slice(2)));
  59. }
  60. };
  61.  
  62. console.log(blocks);
  63.  
  64. for (idx in blocks) {
  65. block = blocks[idx];
  66. $("div.notion-selectable[data-block-id='" + block + "']").css({
  67. "font-family": "Times New Roman, 宋体"
  68. });
  69. console.log("Font changed.");
  70. }
  71.  
  72. $("div.notion-page-content").css({
  73. "font-size": "16px",
  74. "font-family": "Times New Roman, 宋体"
  75. });
  76. }
  77.  
  78. // $(window).on("load", changeStyle);
  79.  
  80. $(document).keyup(function(e) {
  81. if(e.keyCode == 71 && e.ctrlKey && e.altKey){
  82. // alert("You pressed Ctrl + Alt + G!");
  83. changeStyle();
  84. }
  85. });
  86.