mirror of
https://github.com/notion-enhancer/notion-enhancer.git
synced 2025-04-04 04:39:03 +00:00
Add files via upload
This commit is contained in:
parent
39fefb01a4
commit
7836e7c95d
370
Notion Customization/Customization Patcher.py
Normal file
370
Notion Customization/Customization Patcher.py
Normal file
@ -0,0 +1,370 @@
|
||||
"""
|
||||
# Step 1
|
||||
1.Locating notion app at ./%Username%/AppData/Local/Programs/Notion
|
||||
2.Unpacking app.asar in new folder at./Notion/resources/app
|
||||
3.Renaming file app.asar to app.asar.bak (because instead app won't use folder "app" to get all resources from it)
|
||||
4.If app.asar already unpacked - it will try to locate folder "app" and skip to next step
|
||||
|
||||
# Step 2
|
||||
1. Editing userscript file to replace "full_path_to_custom_style" with full path to ./custom_style.css
|
||||
2. Adding userscript from main.user.js(should be in same folder with this .py file) to the ./app/renderer/preload.js
|
||||
3. If there is already userscript - it will overwrite it.
|
||||
|
||||
# Step 3
|
||||
1. Adding property "frame: false" to the place where application window is creating
|
||||
|
||||
# Step 4
|
||||
1. Changes "window drag" area, to make window draggable
|
||||
1.1. You can change it by yourself, if you experiencing problems with dragging window or with clicking buttons on app topbar
|
||||
Because this "draggable area" is creating on top of the other stuff, so if it will have button behind it - it won't be clickable.
|
||||
You should change top,left,right properties. Now it's 2px on top, 390px on left and 420px on right;
|
||||
"""
|
||||
import os
|
||||
from time import sleep
|
||||
from shutil import copyfile
|
||||
import re
|
||||
|
||||
try:
|
||||
sleepTime = 0.5
|
||||
sleep(sleepTime)
|
||||
print("========= START OF LOG =========")
|
||||
sleep(sleepTime)
|
||||
LOCALAPPDATA = os.getenv('LOCALAPPDATA')
|
||||
notionResourcesPath = LOCALAPPDATA + '/Programs/Notion/resources'
|
||||
windowToggleHotkey = "'ctrl+shift+a'"
|
||||
|
||||
# Step 1
|
||||
print("Step 1")
|
||||
sleep(sleepTime)
|
||||
if os.path.isfile(notionResourcesPath + '/app.asar'):
|
||||
sleep(sleepTime)
|
||||
print(" Unpacking app.asar")
|
||||
os.system("asar extract %LOCALAPPDATA%/Programs/Notion/resources/app.asar %LOCALAPPDATA%/Programs/Notion/resources/app")
|
||||
sleep(sleepTime)
|
||||
renameSource = notionResourcesPath + '/app.asar'
|
||||
renameDestination = renameSource + '.bak'
|
||||
os.rename(renameSource, renameDestination)
|
||||
print(" Renaming asar.app to asar.app.bak")
|
||||
sleep(sleepTime)
|
||||
else:
|
||||
sleep(sleepTime)
|
||||
print(" There is no file at Notion/resources/app.asar")
|
||||
sleep(sleepTime)
|
||||
print(" Trying to locate unpacked app.asar")
|
||||
sleep(sleepTime)
|
||||
if os.path.exists(notionResourcesPath + '/app'):
|
||||
print(" app.asar already unpacked - Moving to the next step")
|
||||
sleep(sleepTime)
|
||||
else:
|
||||
print(" Nothing found at Notion/resources/app. Exiting. ")
|
||||
input("Press Enter to exit...")
|
||||
exit()
|
||||
print("-Done-\n")
|
||||
sleep(sleepTime)
|
||||
|
||||
print("Step 2")
|
||||
sleep(sleepTime)
|
||||
# Step 2
|
||||
if os.path.isfile(notionResourcesPath + '/app/renderer/preload.js'):
|
||||
print(" Adding userscript to Notion/resources/app/renderer/preload.js")
|
||||
sleep(sleepTime)
|
||||
|
||||
preload = open(notionResourcesPath + '/app/renderer/preload.js', 'rt')
|
||||
preloadStr = preload.read()
|
||||
preload.close()
|
||||
if 'function userscript()' in preloadStr:
|
||||
print(" Userscript already added. Replacing it")
|
||||
sleep(sleepTime)
|
||||
userscript_line = 0
|
||||
with open(notionResourcesPath + '/app/renderer/preload.js') as myFile:
|
||||
for num, line in enumerate(myFile, 1):
|
||||
if "function userscript()" in line:
|
||||
userscript_line = num-1
|
||||
|
||||
preload = open(notionResourcesPath + '/app/renderer/preload.js', 'rt')
|
||||
preloadLines = preload.readlines()
|
||||
preload.close()
|
||||
|
||||
with open(notionResourcesPath + '/app/renderer/preload.js', 'w') as fin:
|
||||
for lineno, line in enumerate(preloadLines, 1):
|
||||
if lineno < userscript_line:
|
||||
fin.write(line)
|
||||
|
||||
print(" Creating link to ./resources/custom_style.css")
|
||||
sleep(sleepTime)
|
||||
preload = open(notionResourcesPath + '/app/renderer/preload.js', 'a')
|
||||
userscript = open('./resources/main.user.js')
|
||||
scriptPath = os.getcwd()
|
||||
scriptPath = scriptPath.replace('\\', '/')
|
||||
userscriptStr = userscript.read()
|
||||
userscriptStr = userscriptStr.replace('full_path_to_custom_style',scriptPath + '/resources/custom_style.css')
|
||||
preload.write('\n' + userscriptStr)
|
||||
preload.close()
|
||||
else:
|
||||
print(" There is no files at Notion/resources/app/renderer/preload.js or/and ./resources/main.user.js - Nothing was done")
|
||||
sleep(sleepTime)
|
||||
print("-Done-\n")
|
||||
sleep(sleepTime)
|
||||
|
||||
print("Step 3")
|
||||
sleep(sleepTime)
|
||||
# Step 3
|
||||
if os.path.isfile(notionResourcesPath + '/app/main/createWindow.js'):
|
||||
print(" Making window frameless at Notion/resources/app/main/createWindow.js")
|
||||
sleep(sleepTime)
|
||||
|
||||
createWindow = open(notionResourcesPath + '/app/main/createWindow.js', 'rt')
|
||||
createWindowText = createWindow.read()
|
||||
createWindowText = createWindowText.replace('{ show: false', '{ frame: false, show: false')
|
||||
|
||||
print(" Adding ""Run Hidden"" functionality at Notion/resources/app/main/createWindow.js")
|
||||
sleep(sleepTime)
|
||||
createWindowText = createWindowText.replace('window.show();', """
|
||||
const path = require("path");
|
||||
const Store = require(path.join(__dirname,'../','store.js'));
|
||||
const store = new Store({
|
||||
configName: "user-preferences",
|
||||
defaults: {
|
||||
runHidden: false,
|
||||
alwaysMaximized: false
|
||||
}});
|
||||
|
||||
var RunHiddenCheckboxState = store.get("runHidden");
|
||||
var AlwaysMaximizedCheckboxState = store.get("alwaysMaximized");
|
||||
|
||||
if(RunHiddenCheckboxState) {
|
||||
//Do nothing
|
||||
} else {
|
||||
if(AlwaysMaximizedCheckboxState) {
|
||||
window.maximize();
|
||||
} else {
|
||||
window.show()
|
||||
}
|
||||
}""")
|
||||
createWindow.close()
|
||||
|
||||
createWindow = open(notionResourcesPath + '/app/main/createWindow.js', 'wt')
|
||||
createWindow.write(createWindowText)
|
||||
createWindow.close()
|
||||
else:
|
||||
print(" There is no files at Notion/resources/app/main/createWindow.js - Nothing was done")
|
||||
sleep(sleepTime)
|
||||
print("-Done-\n")
|
||||
sleep(sleepTime)
|
||||
|
||||
print("Step 4")
|
||||
sleep(sleepTime)
|
||||
# Step 4
|
||||
if os.path.isfile(notionResourcesPath + '/app/renderer/index.js'):
|
||||
print(" Adjusting drag area for frameless window in Notion/resources/app/renderer/index.js")
|
||||
sleep(sleepTime)
|
||||
createWindow = open(notionResourcesPath + '/app/renderer/index.js', 'rt')
|
||||
createWindowText = createWindow.read()
|
||||
topIndex = createWindowText.rfind("top")
|
||||
createWindowTextSplit = createWindowText[topIndex:]
|
||||
createWindowTextSplit = createWindowTextSplit.replace("right: 0", "right: 420 ")
|
||||
createWindowTextSplit = createWindowTextSplit.replace("top: 0", "top: 1 ")
|
||||
createWindowTextSplit = createWindowTextSplit.replace("height: 34", "height: 16")
|
||||
createWindowText = createWindowText[:topIndex] + createWindowTextSplit
|
||||
createWindow.close()
|
||||
|
||||
createWindow = open(notionResourcesPath + '/app/renderer/index.js', 'wt')
|
||||
createWindow.write(createWindowText)
|
||||
createWindow.close()
|
||||
else:
|
||||
print(" There is no files at Notion/resources/app/renderer/index.js - Nothing was done")
|
||||
sleep(sleepTime)
|
||||
print("-Done-\n")
|
||||
sleep(sleepTime)
|
||||
|
||||
print("Step 5")
|
||||
sleep(sleepTime)
|
||||
# Step 5
|
||||
if os.path.isfile(notionResourcesPath + '/app/main/main.js'):
|
||||
print(" Adding tray support at Notion/resources/app/main/main.js")
|
||||
sleep(sleepTime)
|
||||
print(" Adding context menu with settings to tray")
|
||||
sleep(sleepTime)
|
||||
|
||||
hotkeysCodeText = """
|
||||
const {Tray, Menu} = require("electron");
|
||||
let tray = null;
|
||||
electron_1.app.on("ready", function() {
|
||||
handleReady();
|
||||
|
||||
const path = require("path");
|
||||
const Store = require(path.join(__dirname,'../','store.js'));
|
||||
|
||||
const store = new Store({
|
||||
configName: "user-preferences",
|
||||
defaults: {
|
||||
alwaysMaximized: false,
|
||||
CloseToTrayCheckbox: false,
|
||||
runHidden: false
|
||||
}
|
||||
});
|
||||
|
||||
var RunAtStartupCheckboxState = electron_1.app.getLoginItemSettings().openAtLogin;
|
||||
var RunHiddenCheckboxState = store.get("runHidden");
|
||||
var AlwaysMaximizedCheckboxState = store.get("alwaysMaximized");
|
||||
var CloseToTrayCheckboxState = store.get("CloseToTrayCheckbox");
|
||||
|
||||
tray = new Tray(path.join(__dirname,"./icon.ico"));
|
||||
const contextMenu = Menu.buildFromTemplate([
|
||||
{
|
||||
id: "RunAtStartupCheckbox",
|
||||
label: "Run at Startup",
|
||||
type:"checkbox",
|
||||
checked: RunAtStartupCheckboxState,
|
||||
click() {
|
||||
var isChecked = contextMenu.getMenuItemById("RunAtStartupCheckbox").checked;
|
||||
if(isChecked) {
|
||||
electron_1.app.setLoginItemSettings({ openAtLogin: true});
|
||||
} else {
|
||||
electron_1.app.setLoginItemSettings({ openAtLogin: false});
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
id: "runHidden",
|
||||
label: "Run Hidden",
|
||||
type:"checkbox",
|
||||
checked: RunHiddenCheckboxState,
|
||||
click() {
|
||||
var isChecked = contextMenu.getMenuItemById("runHidden").checked;
|
||||
if(isChecked) {
|
||||
store.set("runHidden", true);
|
||||
} else {
|
||||
store.set("runHidden", false);
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
id: "AlwaysMaximizedCheckbox",
|
||||
label: "Open Maximized",
|
||||
type: "checkbox",
|
||||
checked: AlwaysMaximizedCheckboxState,
|
||||
click() {
|
||||
var isChecked = contextMenu.getMenuItemById("AlwaysMaximizedCheckbox").checked;
|
||||
if(isChecked) {
|
||||
store.set("alwaysMaximized", true);
|
||||
} else {
|
||||
store.set("alwaysMaximized", false);
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
id: "CloseToTrayCheckbox",
|
||||
label: "Close To Tray",
|
||||
type: "checkbox",
|
||||
checked: CloseToTrayCheckboxState,
|
||||
click() {
|
||||
var isChecked = contextMenu.getMenuItemById("CloseToTrayCheckbox").checked;
|
||||
if(isChecked) {
|
||||
store.set("CloseToTrayCheckbox", true);
|
||||
} else {
|
||||
store.set("CloseToTrayCheckbox", false);
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
type: "separator"
|
||||
},
|
||||
{
|
||||
label: "Quit",
|
||||
role: "quit"
|
||||
}
|
||||
]);
|
||||
tray.setContextMenu(contextMenu);
|
||||
|
||||
tray.on("click", function() {
|
||||
var win = electron_1.BrowserWindow.getAllWindows()[0];
|
||||
var alwaysMax = contextMenu.getMenuItemById("AlwaysMaximizedCheckbox").checked;
|
||||
if (win.isVisible()) {
|
||||
if(win.isMinimized()) {
|
||||
win.show()
|
||||
} else {
|
||||
win.hide();
|
||||
}
|
||||
} else {
|
||||
if(alwaysMax){
|
||||
win.maximize();
|
||||
} else {
|
||||
win.show();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
var notionToggleHotkey = 'ctrl+shift+a';
|
||||
const globalShortcut = electron_1.globalShortcut;
|
||||
globalShortcut.register(notionToggleHotkey, function() {
|
||||
var win = electron_1.BrowserWindow.getAllWindows()[0];
|
||||
var alwaysMax = contextMenu.getMenuItemById("AlwaysMaximizedCheckbox").checked;
|
||||
if (win.isVisible()) {
|
||||
win.hide();
|
||||
} else {
|
||||
if(alwaysMax){
|
||||
win.maximize();
|
||||
} else {
|
||||
win.show();
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
"""
|
||||
mainJs = open(notionResourcesPath + '/app/main/main.js', 'rt')
|
||||
mainJsText = mainJs.read()
|
||||
mainJs.close()
|
||||
|
||||
print(" Adding hotkey to show/hide Notion window")
|
||||
sleep(sleepTime)
|
||||
if "var notionToggleHotkey" in mainJsText:
|
||||
mainJsText = re.sub(r"var notionToggleHotkey = '([A-Za-z0-9+_\./\\-]*)'", "var notionToggleHotkey = " + windowToggleHotkey, mainJsText)
|
||||
else :
|
||||
mainJsText = mainJsText.replace('electron_1.app.on("ready", handleReady);' , hotkeysCodeText)
|
||||
mainJsText = mainJsText.replace('win.focus()','win.show()',1)
|
||||
|
||||
print(" Copying tray icon ""icon.ico"" to /app/main/ ")
|
||||
sleep(sleepTime)
|
||||
copyfile('./resources/icon.ico', notionResourcesPath + '/app/main/icon.ico' )
|
||||
|
||||
print(" Copying settings saver class ""store.js"" to /app/ ")
|
||||
sleep(sleepTime)
|
||||
copyfile('./resources/store.js', notionResourcesPath + '/app/store.js' )
|
||||
|
||||
mainJs = open(notionResourcesPath + '/app/main/main.js', 'wt')
|
||||
mainJs.write(mainJsText)
|
||||
mainJs.close()
|
||||
sleep(sleepTime)
|
||||
else:
|
||||
print(" There is no files at Notion/resources/app/main/main.js - Nothing was done")
|
||||
sleep(sleepTime)
|
||||
print("-Done-")
|
||||
sleep(sleepTime)
|
||||
|
||||
sleep(0.5)
|
||||
print("========= END OF LOG =========")
|
||||
sleep(0.5)
|
||||
print("""
|
||||
|
||||
____ _ _____ ____ _ _ _____ ____
|
||||
| _ \ / \|_ _/ ___| | | | ____| _ \
|
||||
| |_) / _ \ | || | | |_| | _| | | | |
|
||||
| __/ ___ \| || |___| _ | |___| |_| |
|
||||
|_| /_/ \_|_| \____|_| |_|_____|____/
|
||||
|
||||
""")
|
||||
sleep(4)
|
||||
except Exception as e:
|
||||
sleep(0.5)
|
||||
print("========= END OF LOG =========")
|
||||
sleep(0.5)
|
||||
print("""
|
||||
__________ ____ ____ ____
|
||||
/ ____/ __ \/ __ \/ __ \/ __ \\
|
||||
/ __/ / /_/ / /_/ / / / / /_/ /
|
||||
/ /___/ _, _/ _, _/ /_/ / _, _/
|
||||
/_____/_/ |_/_/ |_|\____/_/ |_|
|
||||
|
||||
\n\n""" + str(e))
|
||||
os.system('pause')
|
80
Notion Customization/Customization Remover.py
Normal file
80
Notion Customization/Customization Remover.py
Normal file
@ -0,0 +1,80 @@
|
||||
"""
|
||||
# Step 1
|
||||
1.Locating notion app at ./%Username%/AppData/Local/Programs/Notion
|
||||
2.Unpacking app.asar in new folder at./Notion/resources/app
|
||||
3.Renaming file app.asar to app.asar.bak (because instead app won't use folder "app" to get all resources from it)
|
||||
4.If app.asar already unpacked - it will try to locate folder "app" and skip to next step
|
||||
|
||||
# Step 2
|
||||
1. Editing userscript file to replace "full_path_to_custom_style" with full path to ./custom_style.css
|
||||
2. Adding userscript from main.user.js(should be in same folder with this .py file) to the ./app/renderer/preload.js
|
||||
3. If there is already userscript - it will overwrite it.
|
||||
|
||||
# Step 3
|
||||
1. Adding property "frame: false" to the place where application window is creating
|
||||
|
||||
# Step 4
|
||||
1. Changes "window drag" area, to make window draggable
|
||||
1.1. You can change it by yourself, if you experiencing problems with dragging window or with clicking buttons on app topbar
|
||||
Because this "draggable area" is creating on top of the other stuff, so if it will have button behind it - it won't be clickable.
|
||||
You should change top,left,right properties. Now it's 2px on top, 390px on left and 420px on right;
|
||||
"""
|
||||
import os
|
||||
from time import sleep
|
||||
from shutil import copyfile
|
||||
from shutil import rmtree
|
||||
import re
|
||||
|
||||
try:
|
||||
sleepTime = 0.5
|
||||
sleep(sleepTime)
|
||||
print("========= START OF LOG =========")
|
||||
sleep(sleepTime)
|
||||
LOCALAPPDATA = os.getenv('LOCALAPPDATA')
|
||||
LOCALAPPDATA = LOCALAPPDATA.replace('\\', '/')
|
||||
notionResourcesPath = LOCALAPPDATA + '/Programs/Notion/resources'
|
||||
|
||||
if os.path.exists(notionResourcesPath + '/app'):
|
||||
rmtree(notionResourcesPath + '/app')
|
||||
print("Removing ""app"" folder")
|
||||
sleep(sleepTime)
|
||||
else:
|
||||
print("There is no ""app"" folder at ./Notion/resources/app - Skipping this step")
|
||||
sleep(sleepTime)
|
||||
|
||||
if os.path.isfile(notionResourcesPath + '/app.asar.bak'):
|
||||
renameSource = notionResourcesPath + '/app.asar.bak'
|
||||
renameDestination = notionResourcesPath + '/app.asar'
|
||||
os.rename(renameSource, renameDestination)
|
||||
print("Renaming app.asar.bak to app.asar")
|
||||
sleep(sleepTime)
|
||||
else:
|
||||
print("There is no ""app.asar.bak"" at ./Notion/resources/app.asar.bak - Skipping this step")
|
||||
sleep(sleepTime)
|
||||
|
||||
sleep(0.5)
|
||||
print("========= LOG =========")
|
||||
sleep(0.5)
|
||||
print("""
|
||||
|
||||
____ _____ __ __ _____ _______ ____
|
||||
| _ \| ____| \/ |/ _ \ \ / | ____| _ \
|
||||
| |_) | _| | |\/| | | | \ \ / /| _| | | | |
|
||||
| _ <| |___| | | | |_| |\ V / | |___| |_| |
|
||||
|_| \_|_____|_| |_|\___/ \_/ |_____|____/
|
||||
|
||||
""")
|
||||
sleep(2)
|
||||
except Exception as e:
|
||||
sleep(0.5)
|
||||
print("========= END OF LOG =========")
|
||||
sleep(0.5)
|
||||
print("""
|
||||
__________ ____ ____ ____
|
||||
/ ____/ __ \/ __ \/ __ \/ __ \\
|
||||
/ __/ / /_/ / /_/ / / / / /_/ /
|
||||
/ /___/ _, _/ _, _/ /_/ / _, _/
|
||||
/_____/_/ |_/_/ |_|\____/_/ |_|
|
||||
|
||||
\n\n""" + str(e))
|
||||
os.system('pause')
|
135
Notion Customization/resources/custom_style.css
Normal file
135
Notion Customization/resources/custom_style.css
Normal file
@ -0,0 +1,135 @@
|
||||
/* Window control buttons block */
|
||||
#window-buttons-area {
|
||||
padding-left: 14px;
|
||||
}
|
||||
/* Light Theme style for window contoll buttons */
|
||||
.notion-light-theme .window-buttons {
|
||||
background: rgb(255, 255, 255);
|
||||
color: black;
|
||||
border: 0;
|
||||
margin: 0px 0px 0px 9px;
|
||||
width: 32px;
|
||||
line-height: 26px;
|
||||
border-radius: 4px;
|
||||
font-size: 16px;
|
||||
transition-duration: 0.2s;
|
||||
font-weight: bold;
|
||||
}
|
||||
.notion-light-theme .window-buttons:hover {
|
||||
background: rgb(239, 239, 239);
|
||||
}
|
||||
/* Light Theme style for window contoll buttons */
|
||||
|
||||
|
||||
/* Dark Theme style for window contoll buttons */
|
||||
.notion-dark-theme .window-buttons {
|
||||
background: rgb(47, 52, 55);
|
||||
border: 0;
|
||||
margin: 0px 0px 0px 9px;
|
||||
width: 32px;
|
||||
line-height: 26px;
|
||||
border-radius: 4px;
|
||||
font-size: 16px;
|
||||
transition-duration: 0.2s;
|
||||
}
|
||||
.notion-dark-theme .window-buttons:hover {
|
||||
background: rgb(71, 76, 80);
|
||||
}
|
||||
/* Dark Theme style for window contoll buttons */
|
||||
|
||||
|
||||
|
||||
/* To make cursor style as pointer when hover on scrollbar */
|
||||
.notion-scroller {
|
||||
cursor: auto;
|
||||
}
|
||||
/* Scrollbar size */
|
||||
::-webkit-scrollbar {
|
||||
width: 5px; /* To change vertical scrollbar width */
|
||||
height: 12px; /* To change horizontal scrollbar height */
|
||||
}
|
||||
/* Element where vertical and horizontal scrollbars converge */
|
||||
::-webkit-scrollbar-corner{
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
/* Light Theme style for Scrollbars */
|
||||
.notion-light-theme ::-webkit-scrollbar-thumb {
|
||||
border-radius: 5px;
|
||||
background-color: #afafaf;
|
||||
}
|
||||
.notion-light-theme ::-webkit-scrollbar-track {
|
||||
border-radius: 5px;
|
||||
background-color: #e4e4e4;
|
||||
}
|
||||
.notion-light-theme ::-webkit-scrollbar-thumb:hover{
|
||||
background: #969696;
|
||||
}
|
||||
/* Light Theme style for Scrollbars */
|
||||
|
||||
|
||||
/* Dark Theme style for Scrollbars */
|
||||
.notion-dark-theme ::-webkit-scrollbar-track {
|
||||
border-radius: 5px;
|
||||
background-color: #3d3d42;
|
||||
}
|
||||
.notion-dark-theme ::-webkit-scrollbar-thumb {
|
||||
border-radius: 5px;
|
||||
background-color: #5d5d5d;
|
||||
}
|
||||
.notion-dark-theme ::-webkit-scrollbar-thumb:hover{
|
||||
background: #868686;
|
||||
}
|
||||
/* Dark Theme style for Scrollbars */
|
||||
|
||||
|
||||
|
||||
/* Changing table padding to make it more wider */
|
||||
[style^="flex-shrink: 0; flex-grow: 1; width: 100%; max-width: 100%; display: flex; align-items: center; flex-direction: column; font-size: 16px; color: rgba(255, 255, 255, 0.9); padding: 0px 96px 30vh;"] .notion-table-view,
|
||||
[class="notion-scroller"]>.notion-table-view {
|
||||
padding-left: 35px !important;
|
||||
padding-right: 15px !important;
|
||||
min-width: 0% !important;
|
||||
}
|
||||
/* Changing the width of horizontal scroller, because of wider table */
|
||||
[style^="flex-shrink: 0; flex-grow: 1; width: 100%; max-width: 100%; display: flex; align-items: center; flex-direction: column; font-size: 16px; color: rgba(255, 255, 255, 0.9); padding: 0px 96px 30vh;"] .notion-selectable .notion-scroller.horizontal::-webkit-scrollbar-track {
|
||||
margin-left: 10px;
|
||||
margin-right: 10px;
|
||||
}
|
||||
/* Hide "+" button when you hover on table row, because of it's useless for me, and this buttons takes like 15px from the left side of table */
|
||||
[style^="flex-shrink: 0; flex-grow: 1; width: 100%; max-width: 100%; display: flex; align-items: center; flex-direction: column; font-size: 16px; color: rgba(255, 255, 255, 0.9); padding: 0px 96px 30vh;"] .notion-table-view [style^="opacity:"]>[role="button"],
|
||||
[class="notion-scroller"]>.notion-table-view [style^="opacity:"]>[role="button"] {
|
||||
display:none !important;
|
||||
}
|
||||
|
||||
/* Same as with table. Makes board view more wider */
|
||||
.notion-board-view {
|
||||
padding-left: 10px !important;
|
||||
padding-right: 10px !important;
|
||||
}
|
||||
/* Changing content block position, less height - higher content block */
|
||||
[style^="position: relative; width: 100%; display: flex; flex-direction: column; align-items: center; height: 30vh;"] {
|
||||
height: 12vh !important;
|
||||
}
|
||||
/* Changing cover image height to match higher content block */
|
||||
[style^="position: relative; width: 100%; display: flex; flex-direction: column; align-items: center; height: 30vh;"] img {
|
||||
height: 20vh !important;
|
||||
}
|
||||
/* Changing table columns width */
|
||||
[data-block-id^="PutYourIDHere"]>[style^="display: flex; position: absolute; background: rgb(47, 52, 55); z-index: 82; height: 33px; color: rgba(255, 255, 255, 0.6);"]>div:nth-child(1)>div:nth-child(10)>div:nth-child(1),
|
||||
[data-block-id^="PutYourIDHere"]>[style^="position: relative; min-width: calc(100% - 192px);"]>[data-block-id]>div:nth-child(10),
|
||||
[data-block-id^="PutYourIDHere"]>div:nth-child(5)>div:nth-child(10){
|
||||
width: 45px !important;
|
||||
}
|
||||
/* Hiding selection, because of changing columns width bugs selection inside table */
|
||||
[data-block-id^="PutYourIDHere"] [style^="position: absolute; top: 0px; left: 0px; pointer-events: none;"]:not(.notion-presence-container) {
|
||||
display: none;
|
||||
}
|
||||
|
||||
/* Changing table header icons to make it smaller */
|
||||
[style^="display: flex; position: absolute; background: rgb(47, 52, 55); z-index: 82; height: 33px; color: rgba(255, 255, 255, 0.6);"] div:nth-child(1) svg {
|
||||
height: 10px !important;
|
||||
width: 10px !important;
|
||||
margin-right: -4px;
|
||||
}
|
||||
|
BIN
Notion Customization/resources/icon.ico
Normal file
BIN
Notion Customization/resources/icon.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 110 KiB |
93
Notion Customization/resources/main.user.js
Normal file
93
Notion Customization/resources/main.user.js
Normal file
@ -0,0 +1,93 @@
|
||||
function userscript() {
|
||||
/* Style Injecting */
|
||||
var fs = require("fs");
|
||||
let css = fs.readFileSync("full_path_to_custom_style"); //will be replaced in python patcher
|
||||
let head, style;
|
||||
head = document.getElementsByTagName('head')[0];
|
||||
if (!head) { return; }
|
||||
style = document.createElement('style');
|
||||
style.type = 'text/css';
|
||||
style.innerHTML = css;
|
||||
head.appendChild(style);
|
||||
/* Style Injecting */
|
||||
|
||||
/* Window Control Buttons */
|
||||
var buttonsIntervalId = window.setInterval(addButtonsOnLoad,100);
|
||||
function addButtonsOnLoad() {
|
||||
if(document.querySelector('div.notion-topbar > div') == undefined) {
|
||||
return;
|
||||
}
|
||||
var browserWindow = require('electron').remote.getCurrentWindow();
|
||||
var element = document.createElement("div");
|
||||
element.id = "window-buttons-area";
|
||||
var node = document.querySelector('div.notion-topbar > div');
|
||||
node.appendChild(element);
|
||||
|
||||
node = document.querySelector("#window-buttons-area");
|
||||
|
||||
/* AlwaysOnTop Button */
|
||||
element = document.createElement("button");
|
||||
element.classList.add("window-buttons");
|
||||
element.innerHTML = "🠛";
|
||||
element.onclick = function () {
|
||||
if(!browserWindow.isAlwaysOnTop()) {
|
||||
browserWindow.setAlwaysOnTop(true);
|
||||
this.innerHTML = "🠙";
|
||||
} else {
|
||||
browserWindow.setAlwaysOnTop(false);
|
||||
this.innerHTML = "🠛";
|
||||
}
|
||||
};
|
||||
node.appendChild(element);
|
||||
/* AlwaysOnTop Button */
|
||||
|
||||
/* Minimize Button */
|
||||
element = document.createElement("button");
|
||||
element.classList.add("window-buttons");
|
||||
element.innerHTML = "⚊";
|
||||
element.onclick = function () { browserWindow.minimize(); };
|
||||
node.appendChild(element);
|
||||
/* Minimize Button */
|
||||
|
||||
/* Maximize Button */
|
||||
element = document.createElement("button");
|
||||
element.classList.add("window-buttons");
|
||||
element.innerHTML = "▢";
|
||||
element.onclick = function () {
|
||||
if (!browserWindow.isMaximized()) {
|
||||
browserWindow.maximize();
|
||||
} else {
|
||||
browserWindow.unmaximize();
|
||||
}
|
||||
};
|
||||
node.appendChild(element);
|
||||
/* Maximize Button */
|
||||
|
||||
/* Close Button */
|
||||
const path = require("path")
|
||||
element = document.createElement("button");
|
||||
element.classList.add("window-buttons");
|
||||
element.innerHTML = "⨉";
|
||||
element.onclick = function () {
|
||||
const Store = require(path.join(__dirname,'../','store.js'));
|
||||
const store = new Store({
|
||||
configName: "user-preferences",
|
||||
defaults: {
|
||||
CloseToTrayCheckbox: false
|
||||
}
|
||||
});
|
||||
var CloseToTrayCheckboxState = store.get("CloseToTrayCheckbox");
|
||||
if(CloseToTrayCheckboxState) {
|
||||
browserWindow.hide();
|
||||
} else {
|
||||
browserWindow.close();
|
||||
}
|
||||
};
|
||||
node.appendChild(element);
|
||||
/* Close Button */
|
||||
|
||||
window.clearInterval(buttonsIntervalId);
|
||||
}
|
||||
/* Window Control Buttons */
|
||||
}
|
||||
require('electron').remote.getGlobal('setTimeout')(() => { userscript();}, 100);
|
30
Notion Customization/resources/store.js
Normal file
30
Notion Customization/resources/store.js
Normal file
@ -0,0 +1,30 @@
|
||||
const electron = require('electron');
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
|
||||
class Store {
|
||||
constructor(opts) {
|
||||
const userDataPath = __dirname
|
||||
this.path = path.join(userDataPath, opts.configName + '.json');
|
||||
|
||||
this.data = parseDataFile(this.path, opts.defaults);
|
||||
}
|
||||
|
||||
get(key) {
|
||||
return this.data[key];
|
||||
}
|
||||
|
||||
set(key, val) {
|
||||
this.data[key] = val;
|
||||
fs.writeFileSync(this.path, JSON.stringify(this.data));
|
||||
}
|
||||
}
|
||||
|
||||
function parseDataFile(filePath, defaults) {
|
||||
try {
|
||||
return JSON.parse(fs.readFileSync(filePath));
|
||||
} catch(error) {
|
||||
return defaults;
|
||||
}
|
||||
}
|
||||
module.exports = Store;
|
Loading…
Reference in New Issue
Block a user