remove inconsistencies/bugs between platforms

This commit is contained in:
dragonwocky 2020-03-29 21:31:37 +11:00
parent 4810fe1bc1
commit e71df80c7a
Signed by: dragonwocky
GPG Key ID: B570B11B1DFB50E4
7 changed files with 20 additions and 23 deletions

View File

@ -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) 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/).) 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).) 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/).) 2. install [python](https://www.python.org/) (if using the wsl, follow [this guide](https://docs.python-guide.org/starting/install3/linux/)).
3. reboot. 3. reboot.
4. in cmd (on windows) or bash (with wsl), run `npm install -g asar` (check installation by running `asar`). 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, 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,

View File

@ -17,10 +17,8 @@ from time import sleep
# '###' = warnings # '###' = warnings
# '>' = exit # '>' = exit
bold = subprocess.run( bold = '\033[1m'
['tput', 'bold'], stdout=subprocess.PIPE).stdout.rstrip().decode('utf-8') normal = '\033[0m'
normal = subprocess.run(
['tput', 'sgr0'], stdout=subprocess.PIPE).stdout.rstrip().decode('utf-8')
print(f'{bold}=== NOTION ENHANCER CLEANING LOG ==={normal}\n') print(f'{bold}=== NOTION ENHANCER CLEANING LOG ==={normal}\n')
try: try:
@ -31,8 +29,8 @@ try:
['cmd.exe', '/c', 'echo', '%localappdata%'], stdout=subprocess.PIPE).stdout \ ['cmd.exe', '/c', 'echo', '%localappdata%'], stdout=subprocess.PIPE).stdout \
.rstrip().decode('utf-8')[3:].replace('\\', '/') + '/Programs/Notion/resources' .rstrip().decode('utf-8')[3:].replace('\\', '/') + '/Programs/Notion/resources'
elif sys.platform == 'win32': elif sys.platform == 'win32':
filepath = subprocess.run(['echo', '%localappdata%'], stdout=subprocess.PIPE).stdout \ filepath = subprocess.run(['echo', '%localappdata%'], shell=True, capture_output=True).stdout \
.rstrip().decode('utf-8').replace('\\', '/') + ' /Programs/Notion/resources' .rstrip().decode('utf-8').replace('\\', '/') + '/Programs/Notion/resources'
else: else:
print(' > script not compatible with your os!\n (report this to dragonwocky#8449 on discord)') print(' > script not compatible with your os!\n (report this to dragonwocky#8449 on discord)')
exit() exit()

View File

@ -22,23 +22,23 @@ hotkey = 'ctrl+shift+a'
# '##' = warnings # '##' = warnings
# '>' = exit # '>' = exit
bold = subprocess.run( bold = '\033[1m'
['tput', 'bold'], stdout=subprocess.PIPE).stdout.rstrip().decode('utf-8') normal = '\033[0m'
normal = subprocess.run(
['tput', 'sgr0'], stdout=subprocess.PIPE).stdout.rstrip().decode('utf-8')
print(f'{bold}=== NOTION ENHANCER CUSTOMISATION LOG ==={normal}\n') print(f'{bold}=== NOTION ENHANCER CUSTOMISATION LOG ==={normal}\n')
try: try:
filepath = '' filepath = ''
__folder__ = os.path.dirname(os.path.abspath(__file__)).replace('\\', '/')
if 'microsoft' in platform.uname()[3].lower() and sys.platform == 'linux': if 'microsoft' in platform.uname()[3].lower() and sys.platform == 'linux':
filepath = '/mnt/c/' + \ filepath = '/mnt/c/' + \
subprocess.run( subprocess.run(
['cmd.exe', '/c', 'echo', '%localappdata%'], stdout=subprocess.PIPE).stdout \ ['cmd.exe', '/c', 'echo', '%localappdata%'], stdout=subprocess.PIPE).stdout \
.rstrip().decode('utf-8')[3:].replace('\\', '/') + '/Programs/Notion/resources' .rstrip().decode('utf-8')[3:].replace('\\', '/') + '/Programs/Notion/resources'
__folder__ = 'C:/' + __folder__[6:]
elif sys.platform == 'win32': elif sys.platform == 'win32':
filepath = subprocess.run(['echo', '%localappdata%'], stdout=subprocess.PIPE).stdout \ filepath = subprocess.run(['echo', '%localappdata%'], shell=True, capture_output=True).stdout \
.rstrip().decode('utf-8').replace('\\', '/') + ' /Programs/Notion/resources' .rstrip().decode('utf-8').replace('\\', '/') + '/Programs/Notion/resources'
else: else:
print(' > script not compatible with your os!\n (report this to dragonwocky#8449 on discord)') print(' > script not compatible with your os!\n (report this to dragonwocky#8449 on discord)')
exit() exit()
@ -46,7 +46,7 @@ try:
if os.path.isfile(filepath + '/app.asar'): if os.path.isfile(filepath + '/app.asar'):
print(' ...unpacking app.asar') print(' ...unpacking app.asar')
subprocess.run(['asar', 'extract', filepath + 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') print(' ...renaming asar.app to asar.app.bak')
os.rename(filepath + '/app.asar', filepath + '/app.asar.bak') os.rename(filepath + '/app.asar', filepath + '/app.asar.bak')
else: else:
@ -78,8 +78,7 @@ try:
print(' ...linking to ./resources/user.css') print(' ...linking to ./resources/user.css')
with open('./resources/preload.js') as insert: with open('./resources/preload.js') as insert:
append.write(insert.read().replace( append.write(insert.read().replace(
'$$$user.css$$$', 'C:/' + '___user.css___', __folder__
os.getcwd().replace('\\', ' / ')[6:]
+ '/resources/user.css')) + '/resources/user.css'))
else: else:
print( print(
@ -155,7 +154,7 @@ try:
with open(filepath + '/app/main/main.js', 'a') as append: with open(filepath + '/app/main/main.js', 'a') as append:
with open('./resources/hotkey.js') as insert: with open('./resources/hotkey.js') as insert:
append.write('\n' + insert.read().replace( append.write('\n' + insert.read().replace(
'$$$hotkey$$$', hotkey)) '___hotkey___', hotkey))
print( print(
f' ...copying tray icon ./resources/notion.ico to {filepath}/app/main/') f' ...copying tray icon ./resources/notion.ico to {filepath}/app/main/')
copyfile('./resources/notion.ico', filepath + '/app/main/notion.ico') copyfile('./resources/notion.ico', filepath + '/app/main/notion.ico')

View File

@ -169,7 +169,7 @@ class Scrollnav {
const construct = () => { const construct = () => {
if ( if (
location.pathname.endsWith('index.html') && location.pathname.endsWith('index.html') &&
window.location.protocol === 'https:' window.location.protocol !== 'file:'
) )
location.replace('./' + location.hash); location.replace('./' + location.hash);

View File

@ -16,8 +16,8 @@
these can be installed via an extension like <a href="https://chrome.google.com/webstore/detail/stylus/clngdbkpkpeebahjckkjfobafhncgmne?hl=en">stylus</a> these can be installed via an extension like <a href="https://chrome.google.com/webstore/detail/stylus/clngdbkpkpeebahjckkjfobafhncgmne?hl=en">stylus</a>
or a built-in feature like <a href="https://www.userchrome.org/">userChrome.css</a>.)</p> or a built-in feature like <a href="https://www.userchrome.org/">userChrome.css</a>.)</p>
<ol> <ol>
<li>install <a href="https://nodejs.org/en/">node.js</a> (if using the wsl, it is recommended to install via <a href="https://github.com/nvm-sh/nvm#install--update-script">nvm</a>.)</li> <li>install <a href="https://nodejs.org/en/">node.js</a> (if using the wsl, it is recommended to install via <a href="https://github.com/nvm-sh/nvm#install--update-script">nvm</a>).</li>
<li>install <a href="https://www.python.org/">python</a> (if using the wsl, follow <a href="https://docs.python-guide.org/starting/install3/linux/">this guide</a>.)</li> <li>install <a href="https://www.python.org/">python</a> (if using the wsl, follow <a href="https://docs.python-guide.org/starting/install3/linux/">this guide</a>).</li>
<li>reboot.</li> <li>reboot.</li>
<li>in cmd (on windows) or bash (with wsl), run <code>npm install -g asar</code> (check installation by running <code>asar</code>).</li> <li>in cmd (on windows) or bash (with wsl), run <code>npm install -g asar</code> (check installation by running <code>asar</code>).</li>
<li><a href="https://github.com/dragonwocky/notion-enhancer/archive/master.zip">download this enhancer</a> &amp; extract to a location it can safely remain (this must be in the windows filesystem, <li><a href="https://github.com/dragonwocky/notion-enhancer/archive/master.zip">download this enhancer</a> &amp; extract to a location it can safely remain (this must be in the windows filesystem,

View File

@ -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, () => { electron_1.globalShortcut.register(hotkey, () => {
const windows = electron_1.BrowserWindow.getAllWindows(); const windows = electron_1.BrowserWindow.getAllWindows();
if (windows.some(win => !win.isVisible())) { if (windows.some(win => !win.isVisible())) {

View File

@ -14,7 +14,7 @@
require('electron').remote.getGlobal('setTimeout')(() => { require('electron').remote.getGlobal('setTimeout')(() => {
/* style injection */ /* style injection */
const fs = require('fs'), 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'), style = document.createElement('style'),
head = document.getElementsByTagName('head')[0]; head = document.getElementsByTagName('head')[0];
if (!head) return; if (!head) return;