From e71df80c7a1f2268ce225b6d550179e690a1f89d Mon Sep 17 00:00:00 2001 From: dragonwocky Date: Sun, 29 Mar 2020 21:31:37 +1100 Subject: [PATCH] remove inconsistencies/bugs between platforms --- README.md | 4 ++-- cleaner.py | 10 ++++------ customiser.py | 19 +++++++++---------- docs/docs.js | 2 +- docs/index.html | 4 ++-- resources/hotkey.js | 2 +- resources/preload.js | 2 +- 7 files changed, 20 insertions(+), 23 deletions(-) diff --git a/README.md b/README.md index 9d846ae..e8a9c85 100644 --- a/README.md +++ b/README.md @@ -10,8 +10,8 @@ currently, only win10 is supported. it is possible to run this script via the ws these can be installed via an extension like [stylus](https://chrome.google.com/webstore/detail/stylus/clngdbkpkpeebahjckkjfobafhncgmne?hl=en) or a built-in feature like [userChrome.css](https://www.userchrome.org/).) -1. install [node.js](https://nodejs.org/en/) (if using the wsl, it is recommended to install via [nvm](https://github.com/nvm-sh/nvm#install--update-script).) -2. install [python](https://www.python.org/) (if using the wsl, follow [this guide](https://docs.python-guide.org/starting/install3/linux/).) +1. install [node.js](https://nodejs.org/en/) (if using the wsl, it is recommended to install via [nvm](https://github.com/nvm-sh/nvm#install--update-script)). +2. install [python](https://www.python.org/) (if using the wsl, follow [this guide](https://docs.python-guide.org/starting/install3/linux/)). 3. reboot. 4. in cmd (on windows) or bash (with wsl), run `npm install -g asar` (check installation by running `asar`). 5. [download this enhancer](https://github.com/dragonwocky/notion-enhancer/archive/master.zip) & extract to a location it can safely remain (this must be in the windows filesystem, diff --git a/cleaner.py b/cleaner.py index 0026b0c..74d12b9 100644 --- a/cleaner.py +++ b/cleaner.py @@ -17,10 +17,8 @@ from time import sleep # '###' = warnings # '>' = exit -bold = subprocess.run( - ['tput', 'bold'], stdout=subprocess.PIPE).stdout.rstrip().decode('utf-8') -normal = subprocess.run( - ['tput', 'sgr0'], stdout=subprocess.PIPE).stdout.rstrip().decode('utf-8') +bold = '\033[1m' +normal = '\033[0m' print(f'{bold}=== NOTION ENHANCER CLEANING LOG ==={normal}\n') try: @@ -31,8 +29,8 @@ try: ['cmd.exe', '/c', 'echo', '%localappdata%'], stdout=subprocess.PIPE).stdout \ .rstrip().decode('utf-8')[3:].replace('\\', '/') + '/Programs/Notion/resources' elif sys.platform == 'win32': - filepath = subprocess.run(['echo', '%localappdata%'], stdout=subprocess.PIPE).stdout \ - .rstrip().decode('utf-8').replace('\\', '/') + ' /Programs/Notion/resources' + filepath = subprocess.run(['echo', '%localappdata%'], shell=True, capture_output=True).stdout \ + .rstrip().decode('utf-8').replace('\\', '/') + '/Programs/Notion/resources' else: print(' > script not compatible with your os!\n (report this to dragonwocky#8449 on discord)') exit() diff --git a/customiser.py b/customiser.py index fa7b0f2..925472e 100644 --- a/customiser.py +++ b/customiser.py @@ -22,23 +22,23 @@ hotkey = 'ctrl+shift+a' # '##' = warnings # '>' = exit -bold = subprocess.run( - ['tput', 'bold'], stdout=subprocess.PIPE).stdout.rstrip().decode('utf-8') -normal = subprocess.run( - ['tput', 'sgr0'], stdout=subprocess.PIPE).stdout.rstrip().decode('utf-8') +bold = '\033[1m' +normal = '\033[0m' print(f'{bold}=== NOTION ENHANCER CUSTOMISATION LOG ==={normal}\n') try: filepath = '' + __folder__ = os.path.dirname(os.path.abspath(__file__)).replace('\\', '/') if 'microsoft' in platform.uname()[3].lower() and sys.platform == 'linux': filepath = '/mnt/c/' + \ subprocess.run( ['cmd.exe', '/c', 'echo', '%localappdata%'], stdout=subprocess.PIPE).stdout \ .rstrip().decode('utf-8')[3:].replace('\\', '/') + '/Programs/Notion/resources' + __folder__ = 'C:/' + __folder__[6:] elif sys.platform == 'win32': - filepath = subprocess.run(['echo', '%localappdata%'], stdout=subprocess.PIPE).stdout \ - .rstrip().decode('utf-8').replace('\\', '/') + ' /Programs/Notion/resources' + filepath = subprocess.run(['echo', '%localappdata%'], shell=True, capture_output=True).stdout \ + .rstrip().decode('utf-8').replace('\\', '/') + '/Programs/Notion/resources' else: print(' > script not compatible with your os!\n (report this to dragonwocky#8449 on discord)') exit() @@ -46,7 +46,7 @@ try: if os.path.isfile(filepath + '/app.asar'): print(' ...unpacking app.asar') subprocess.run(['asar', 'extract', filepath + - '/app.asar', filepath + '/app']) + '/app.asar', filepath + '/app'], shell=(True if sys.platform == 'win32' else False)) print(' ...renaming asar.app to asar.app.bak') os.rename(filepath + '/app.asar', filepath + '/app.asar.bak') else: @@ -78,8 +78,7 @@ try: print(' ...linking to ./resources/user.css') with open('./resources/preload.js') as insert: append.write(insert.read().replace( - '$$$user.css$$$', 'C:/' + - os.getcwd().replace('\\', ' / ')[6:] + '___user.css___', __folder__ + '/resources/user.css')) else: print( @@ -155,7 +154,7 @@ try: with open(filepath + '/app/main/main.js', 'a') as append: with open('./resources/hotkey.js') as insert: append.write('\n' + insert.read().replace( - '$$$hotkey$$$', hotkey)) + '___hotkey___', hotkey)) print( f' ...copying tray icon ./resources/notion.ico to {filepath}/app/main/') copyfile('./resources/notion.ico', filepath + '/app/main/notion.ico') diff --git a/docs/docs.js b/docs/docs.js index fcaf471..48374c4 100644 --- a/docs/docs.js +++ b/docs/docs.js @@ -169,7 +169,7 @@ class Scrollnav { const construct = () => { if ( location.pathname.endsWith('index.html') && - window.location.protocol === 'https:' + window.location.protocol !== 'file:' ) location.replace('./' + location.hash); diff --git a/docs/index.html b/docs/index.html index b916087..77019be 100644 --- a/docs/index.html +++ b/docs/index.html @@ -16,8 +16,8 @@ these can be installed via an extension like stylus or a built-in feature like userChrome.css.)

    -
  1. install node.js (if using the wsl, it is recommended to install via nvm.)
  2. -
  3. install python (if using the wsl, follow this guide.)
  4. +
  5. install node.js (if using the wsl, it is recommended to install via nvm).
  6. +
  7. install python (if using the wsl, follow this guide).
  8. reboot.
  9. in cmd (on windows) or bash (with wsl), run npm install -g asar (check installation by running asar).
  10. download this enhancer & extract to a location it can safely remain (this must be in the windows filesystem, diff --git a/resources/hotkey.js b/resources/hotkey.js index c7ba941..cb18b2a 100644 --- a/resources/hotkey.js +++ b/resources/hotkey.js @@ -97,7 +97,7 @@ function enhancements() { } }); - const hotkey = '$$$hotkey$$$'; // will be set by python script + const hotkey = '___hotkey___'; // will be set by python script electron_1.globalShortcut.register(hotkey, () => { const windows = electron_1.BrowserWindow.getAllWindows(); if (windows.some(win => !win.isVisible())) { diff --git a/resources/preload.js b/resources/preload.js index 4ca1503..abaf5da 100644 --- a/resources/preload.js +++ b/resources/preload.js @@ -14,7 +14,7 @@ require('electron').remote.getGlobal('setTimeout')(() => { /* style injection */ const fs = require('fs'), - css = fs.readFileSync('$$$user.css$$$'), // will be set by python script + css = fs.readFileSync('___user.css___'), // will be set by python script style = document.createElement('style'), head = document.getElementsByTagName('head')[0]; if (!head) return;