mirror of
https://github.com/notion-enhancer/notion-enhancer.git
synced 2025-04-12 00:09:03 +00:00
(removed platform support requests, replaced getNotion() with __notion)
This commit is contained in:
parent
211b24d2d7
commit
2303783319
27
.github/ISSUE_TEMPLATE/platform-support.md
vendored
27
.github/ISSUE_TEMPLATE/platform-support.md
vendored
@ -1,27 +0,0 @@
|
|||||||
---
|
|
||||||
name: platform support
|
|
||||||
about: the enhancer doesn't know how to modify your notion installation?
|
|
||||||
title: ''
|
|
||||||
labels: enhancement
|
|
||||||
assignees: ''
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
FILL OUT THIS TEMPLATE, REMOVING/REPLACING EVERYTHING HERE WITH YOUR OWN INFORMATION.
|
|
||||||
BE AS CLEAR AND CONCISE AS POSSIBLE.
|
|
||||||
|
|
||||||
**platform**
|
|
||||||
what system are you on? (e.g. windows, macOS, raspbian, xfce)
|
|
||||||
|
|
||||||
**installation steps**
|
|
||||||
how did you install notion?
|
|
||||||
please link me to the download/installer/wrapper you used.
|
|
||||||
|
|
||||||
**filepaths**
|
|
||||||
- where is notion installed
|
|
||||||
- what file structure does it have
|
|
||||||
- in particular, where is the `app.asar` file
|
|
||||||
|
|
||||||
**why?**
|
|
||||||
what's so special about this way of installing notion?
|
|
||||||
is there any particular reason why you can't use one of the already-supported clients?
|
|
@ -20,6 +20,8 @@ a feature and cleanup update.
|
|||||||
- improved: extensions menu filters shown either a ✓ or × to help understand the current state.
|
- improved: extensions menu filters shown either a ✓ or × to help understand the current state.
|
||||||
- improved: added individual text-colour rules for different background colours.
|
- improved: added individual text-colour rules for different background colours.
|
||||||
- improved: added variables for callout colouring.
|
- improved: added variables for callout colouring.
|
||||||
|
- improved: replaced with `helpers.getNotion()` with the constant `helpers.__notion` to reduce
|
||||||
|
repeated function calls.
|
||||||
- bugfix: enhancer settings should no longer reset on update (though this will not have
|
- bugfix: enhancer settings should no longer reset on update (though this will not have
|
||||||
effect until the release after this one).
|
effect until the release after this one).
|
||||||
- bugfix: blue select tags are no longer purple.
|
- bugfix: blue select tags are no longer purple.
|
||||||
@ -30,12 +32,14 @@ a feature and cleanup update.
|
|||||||
- bugfix: update property-layout to match notion changes again.
|
- bugfix: update property-layout to match notion changes again.
|
||||||
- bugfix: updated some of the tweak styling to match notion changes.
|
- bugfix: updated some of the tweak styling to match notion changes.
|
||||||
- bugfix: block-level text colours are now changed properly.
|
- bugfix: block-level text colours are now changed properly.
|
||||||
|
- bugfix: do not require data folder during installation, to prevent `sudo` attempting to
|
||||||
|
create it in `/var/root/`.
|
||||||
- themes: "littlepig" (light + dark) = monospaced themes using emojis and colourful text.
|
- themes: "littlepig" (light + dark) = monospaced themes using emojis and colourful text.
|
||||||
- extension: "font chooser" = customize fonts. for each option, type in the name of the font you would like to use,
|
- extension: "font chooser" = customize fonts. for each option, type in the name of the font you would like to use,
|
||||||
or leave it blank to not change anything.
|
or leave it blank to not change anything.
|
||||||
- extension: "always on top" = add an arrow/button to show the notion window on top of other windows
|
- extension: "always on top" = add an arrow/button to show the notion window on top of other windows
|
||||||
even if it's not focused.
|
even if it's not focused.
|
||||||
- extension: "calendar scroll" = add a button to scroll down to the current week for you.
|
- extension: "calendar scroll" = add a button to scroll down to the current week in fullpage/infinite-scroll calendars.
|
||||||
- extension: "hide help button" = hide the help button if you don't need it.
|
- extension: "hide help button" = hide the help button if you don't need it.
|
||||||
- extension: "bypass preview" = go straight to the normal full view when opening a page.
|
- extension: "bypass preview" = go straight to the normal full view when opening a page.
|
||||||
|
|
||||||
@ -100,7 +104,7 @@ complete rewrite with node.js.
|
|||||||
- bugfix: non-reproducable errors with python.
|
- bugfix: non-reproducable errors with python.
|
||||||
- bugfix: better launcher patching on linux.
|
- bugfix: better launcher patching on linux.
|
||||||
- bugfix: fix frameless window issue introduced by notion desktop 2.0.9.
|
- bugfix: fix frameless window issue introduced by notion desktop 2.0.9.
|
||||||
- extension: "custom inserts" = link files for small client-side tweaks..
|
- extension: "custom inserts" = link files for small client-side tweaks.
|
||||||
- extension: "bracketed links" = render links surrounded with \[\[brackets]] instead of underlined.
|
- extension: "bracketed links" = render links surrounded with \[\[brackets]] instead of underlined.
|
||||||
- extension: "focus mode" = hide the titlebar/menubar if the sidebar is closed (will be shown on hover).
|
- extension: "focus mode" = hide the titlebar/menubar if the sidebar is closed (will be shown on hover).
|
||||||
- theme: "dark+" = a vivid-colour near-black theme.
|
- theme: "dark+" = a vivid-colour near-black theme.
|
||||||
|
@ -20,9 +20,6 @@ for support, join the [discord server](https://discord.gg/sFWPXtA).
|
|||||||
|
|
||||||
(it can also be run from the wsl to apply enhancements to the windows app.)
|
(it can also be run from the wsl to apply enhancements to the windows app.)
|
||||||
|
|
||||||
**using a not-yet-supported operating system or notion installation?** ask for
|
|
||||||
[platform support](https://github.com/dragonwocky/notion-enhancer/issues/new?labels=enhancement&template=platform-support.md).
|
|
||||||
|
|
||||||
mobile clients are not supported and due to system limitations/restrictions cannot be.
|
mobile clients are not supported and due to system limitations/restrictions cannot be.
|
||||||
|
|
||||||
a chrome extension may be coming soon for web client support.
|
a chrome extension may be coming soon for web client support.
|
||||||
|
@ -33,7 +33,8 @@ if you are attempting to customise the web client, the css previously used for t
|
|||||||
### hide discussions (the comment threads at the top of each page)
|
### hide discussions (the comment threads at the top of each page)
|
||||||
|
|
||||||
```css
|
```css
|
||||||
[style*='env(safe-area-inset-left)'] [style*='width: 100%; height: 1px;'],
|
[style*='env(safe-area-inset-left)']:not(.notion-page-content)
|
||||||
|
[style*='width: 100%; height: 1px;'],
|
||||||
.notion-page-view-discussion {
|
.notion-page-view-discussion {
|
||||||
display: none !important;
|
display: none !important;
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,7 @@ module.exports = {
|
|||||||
tags: ['extension'],
|
tags: ['extension'],
|
||||||
name: 'calendar scroll',
|
name: 'calendar scroll',
|
||||||
desc:
|
desc:
|
||||||
'add a button to scroll down to the current week of a calendar for you.',
|
'add a button to scroll down to the current week in fullpage/infinite-scroll calendars',
|
||||||
version: '0.1.0',
|
version: '0.1.0',
|
||||||
author: 'dragonwocky',
|
author: 'dragonwocky',
|
||||||
hacks: {
|
hacks: {
|
||||||
|
@ -10,8 +10,7 @@
|
|||||||
module.exports = (store, __exports) => {
|
module.exports = (store, __exports) => {
|
||||||
const electron = require('electron'),
|
const electron = require('electron'),
|
||||||
helpers = require('../../pkg/helpers.js'),
|
helpers = require('../../pkg/helpers.js'),
|
||||||
__notion = helpers.getNotion(),
|
notionIpc = require(`${helpers.__notion.replace(
|
||||||
notionIpc = require(`${__notion.replace(
|
|
||||||
/\\/g,
|
/\\/g,
|
||||||
'/'
|
'/'
|
||||||
)}/app/helpers/notionIpc.js`);
|
)}/app/helpers/notionIpc.js`);
|
||||||
|
@ -15,12 +15,11 @@ module.exports = (store, __exports) => {
|
|||||||
),
|
),
|
||||||
// createWindow = __exports.createWindow,
|
// createWindow = __exports.createWindow,
|
||||||
path = require('path'),
|
path = require('path'),
|
||||||
helpers = require('../../pkg/helpers.js'),
|
helpers = require('../../pkg/helpers.js');
|
||||||
__notion = helpers.getNotion();
|
|
||||||
|
|
||||||
__exports.createWindow = function (relativeUrl, focused_window) {
|
__exports.createWindow = function (relativeUrl, focused_window) {
|
||||||
if (!relativeUrl) relativeUrl = '';
|
if (!relativeUrl) relativeUrl = '';
|
||||||
const window_state = require(`${__notion.replace(
|
const window_state = require(`${helpers.__notion.replace(
|
||||||
/\\/g,
|
/\\/g,
|
||||||
'/'
|
'/'
|
||||||
)}/app/node_modules/electron-window-state/index.js`)({
|
)}/app/node_modules/electron-window-state/index.js`)({
|
||||||
@ -47,7 +46,7 @@ module.exports = (store, __exports) => {
|
|||||||
titleBarStyle: 'hiddenInset',
|
titleBarStyle: 'hiddenInset',
|
||||||
frame: !store().frameless,
|
frame: !store().frameless,
|
||||||
webPreferences: {
|
webPreferences: {
|
||||||
preload: path.resolve(`${__notion}/app/renderer/index.js`),
|
preload: path.resolve(`${helpers.__notion}/app/renderer/index.js`),
|
||||||
webviewTag: true,
|
webviewTag: true,
|
||||||
session: electron.session.fromPartition('persist:notion'),
|
session: electron.session.fromPartition('persist:notion'),
|
||||||
},
|
},
|
||||||
|
@ -14,8 +14,7 @@ module.exports = (store, __exports) => {
|
|||||||
path = require('path'),
|
path = require('path'),
|
||||||
is_mac = process.platform === 'darwin',
|
is_mac = process.platform === 'darwin',
|
||||||
is_win = process.platform === 'win32',
|
is_win = process.platform === 'win32',
|
||||||
helpers = require('../../pkg/helpers.js'),
|
helpers = require('../../pkg/helpers.js');
|
||||||
__notion = helpers.getNotion();
|
|
||||||
|
|
||||||
electron.app.on('ready', () => {
|
electron.app.on('ready', () => {
|
||||||
tray = new electron.Tray(
|
tray = new electron.Tray(
|
||||||
@ -77,12 +76,12 @@ module.exports = (store, __exports) => {
|
|||||||
|
|
||||||
function openExtensionMenu() {
|
function openExtensionMenu() {
|
||||||
if (enhancer_menu) return enhancer_menu.show();
|
if (enhancer_menu) return enhancer_menu.show();
|
||||||
const window_state = require(`${__notion.replace(
|
const window_state = require(`${helpers.__notion.replace(
|
||||||
/\\/g,
|
/\\/g,
|
||||||
'/'
|
'/'
|
||||||
)}/app/node_modules/electron-window-state/index.js`)({
|
)}/app/node_modules/electron-window-state/index.js`)({
|
||||||
file: 'menu-windowstate.json',
|
file: 'menu-windowstate.json',
|
||||||
path: helpers.data_folder,
|
path: helpers.__data,
|
||||||
defaultWidth: 275,
|
defaultWidth: 275,
|
||||||
defaultHeight: 600,
|
defaultHeight: 600,
|
||||||
});
|
});
|
||||||
@ -165,7 +164,9 @@ module.exports = (store, __exports) => {
|
|||||||
click: () => {
|
click: () => {
|
||||||
require('./create.js')(
|
require('./create.js')(
|
||||||
store,
|
store,
|
||||||
require(path.resolve(`${__notion}/app/main/createWindow.js`))
|
require(path.resolve(
|
||||||
|
`${helpers.__notion}/app/main/createWindow.js`
|
||||||
|
))
|
||||||
)(
|
)(
|
||||||
'',
|
'',
|
||||||
electron.BrowserWindow.getAllWindows().find(
|
electron.BrowserWindow.getAllWindows().find(
|
||||||
|
@ -16,8 +16,7 @@ module.exports = {
|
|||||||
author: {
|
author: {
|
||||||
name: 'zenith_illinois',
|
name: 'zenith_illinois',
|
||||||
link: 'https://www.reddit.com/user/zenith_illinois/',
|
link: 'https://www.reddit.com/user/zenith_illinois/',
|
||||||
avatar:
|
avatar: 'https://www.redditstatic.com/avatars/avatar_default_18_46A508.png',
|
||||||
'https://cdn.discordapp.com/avatars/565182533940150283/54f36546ab586298a5df5c238cbaaa4b.png?size=128',
|
|
||||||
},
|
},
|
||||||
fonts: ['https://rsms.me/inter/inter.css'],
|
fonts: ['https://rsms.me/inter/inter.css'],
|
||||||
};
|
};
|
||||||
|
26
pkg/apply.js
26
pkg/apply.js
@ -21,11 +21,8 @@ const fs = require('fs-extra'),
|
|||||||
// ~~ exit
|
// ~~ exit
|
||||||
// ### error ###
|
// ### error ###
|
||||||
|
|
||||||
let __notion = helpers.getNotion();
|
|
||||||
module.exports = async function ({ overwrite_version, friendly_errors } = {}) {
|
module.exports = async function ({ overwrite_version, friendly_errors } = {}) {
|
||||||
try {
|
try {
|
||||||
await fs.ensureDir(helpers.data_folder);
|
|
||||||
|
|
||||||
// handle pre-existing installations: app.asar present? version set in data folder? overwrite?
|
// handle pre-existing installations: app.asar present? version set in data folder? overwrite?
|
||||||
const check_app = await require('./check.js')();
|
const check_app = await require('./check.js')();
|
||||||
switch (check_app.code) {
|
switch (check_app.code) {
|
||||||
@ -55,24 +52,24 @@ module.exports = async function ({ overwrite_version, friendly_errors } = {}) {
|
|||||||
delete_data: false,
|
delete_data: false,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
console.info(' ...unpacking app.asar');
|
console.info(' ...unpacking app.asar.');
|
||||||
const asar_app = path.resolve(`${__notion}/app.asar`);
|
const asar_app = path.resolve(`${helpers.__notion}/app.asar`);
|
||||||
extractAll(asar_app, `${path.resolve(`${__notion}/app`)}`);
|
extractAll(asar_app, `${path.resolve(`${helpers.__notion}/app`)}`);
|
||||||
fs.move(asar_app, path.resolve(`${__notion}/app.asar.bak`));
|
fs.move(asar_app, path.resolve(`${helpers.__notion}/app.asar.bak`));
|
||||||
|
|
||||||
// patching launch script target of custom wrappers
|
// patching launch script target of custom wrappers
|
||||||
if (
|
if (
|
||||||
[
|
[
|
||||||
'/opt/notion-app', // https://aur.archlinux.org/packages/notion-app/
|
'/opt/notion-app', // https://aur.archlinux.org/packages/notion-app/
|
||||||
'/opt/notion', // https://github.com/jaredallard/notion-app
|
'/opt/notion', // https://github.com/jaredallard/notion-app
|
||||||
].includes(__notion)
|
].includes(helpers.__notion)
|
||||||
) {
|
) {
|
||||||
console.info(
|
console.info(
|
||||||
' ...patching app launcher (notion-app linux wrappers only).'
|
' ...patching app launcher (notion-app linux wrappers only).'
|
||||||
);
|
);
|
||||||
for (let bin_path of [
|
for (let bin_path of [
|
||||||
`/usr/bin/${__notion.split('/')[2]}`,
|
`/usr/bin/${helpers.__notion.split('/')[2]}`,
|
||||||
`${__notion}/${__notion.split('/')[2]}`,
|
`${helpers.__notion}/${helpers.__notion.split('/')[2]}`,
|
||||||
]) {
|
]) {
|
||||||
const bin_script = await fs.readFile(bin_path, 'utf8');
|
const bin_script = await fs.readFile(bin_path, 'utf8');
|
||||||
if (bin_script.includes('app.asar')) {
|
if (bin_script.includes('app.asar')) {
|
||||||
@ -87,13 +84,15 @@ module.exports = async function ({ overwrite_version, friendly_errors } = {}) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for await (let insertion_target of readdirIterator(
|
for await (let insertion_target of readdirIterator(
|
||||||
path.resolve(`${__notion}/app`),
|
path.resolve(`${helpers.__notion}/app`),
|
||||||
{
|
{
|
||||||
deep: (stats) => stats.path.indexOf('node_modules') === -1,
|
deep: (stats) => stats.path.indexOf('node_modules') === -1,
|
||||||
filter: (stats) => stats.isFile() && stats.path.endsWith('.js'),
|
filter: (stats) => stats.isFile() && stats.path.endsWith('.js'),
|
||||||
}
|
}
|
||||||
)) {
|
)) {
|
||||||
insertion_target = path.resolve(`${__notion}/app/${insertion_target}`);
|
insertion_target = path.resolve(
|
||||||
|
`${helpers.__notion}/app/${insertion_target}`
|
||||||
|
);
|
||||||
fs.appendFile(
|
fs.appendFile(
|
||||||
insertion_target,
|
insertion_target,
|
||||||
`\n\n//notion-enhancer\nrequire('${helpers.realpath(
|
`\n\n//notion-enhancer\nrequire('${helpers.realpath(
|
||||||
@ -105,10 +104,9 @@ module.exports = async function ({ overwrite_version, friendly_errors } = {}) {
|
|||||||
// not resolved, nothing depends on it so it's just a "let it do its thing"
|
// not resolved, nothing depends on it so it's just a "let it do its thing"
|
||||||
console.info(' ...recording enhancement version.');
|
console.info(' ...recording enhancement version.');
|
||||||
fs.outputFile(
|
fs.outputFile(
|
||||||
path.resolve(`${__notion}/app/ENHANCER_VERSION.txt`),
|
path.resolve(`${helpers.__notion}/app/ENHANCER_VERSION.txt`),
|
||||||
version
|
version
|
||||||
);
|
);
|
||||||
fs.outputFile(path.resolve(`${helpers.data_folder}/version.txt`), version);
|
|
||||||
|
|
||||||
console.info(' ~~ success.');
|
console.info(' ~~ success.');
|
||||||
return true;
|
return true;
|
||||||
|
@ -12,14 +12,14 @@ const fs = require('fs-extra'),
|
|||||||
{ version } = require('../package.json');
|
{ version } = require('../package.json');
|
||||||
|
|
||||||
// handle pre-existing installations: app.asar modded? with which enhancer version?
|
// handle pre-existing installations: app.asar modded? with which enhancer version?
|
||||||
|
|
||||||
let __notion = helpers.getNotion();
|
|
||||||
module.exports = async function () {
|
module.exports = async function () {
|
||||||
const version_path = path.resolve(`${__notion}/app/ENHANCER_VERSION.txt`),
|
const version_path = path.resolve(
|
||||||
|
`${helpers.__notion}/app/ENHANCER_VERSION.txt`
|
||||||
|
),
|
||||||
installed_version = (await fs.pathExists(version_path))
|
installed_version = (await fs.pathExists(version_path))
|
||||||
? await fs.readFile(version_path, 'utf8')
|
? await fs.readFile(version_path, 'utf8')
|
||||||
: '?.?.?';
|
: '?.?.?';
|
||||||
if (await fs.pathExists(path.resolve(`${__notion}/app.asar`))) {
|
if (await fs.pathExists(path.resolve(`${helpers.__notion}/app.asar`))) {
|
||||||
return {
|
return {
|
||||||
msg: `notion-enhancer has not been applied.`,
|
msg: `notion-enhancer has not been applied.`,
|
||||||
code: 0,
|
code: 0,
|
||||||
|
116
pkg/helpers.js
116
pkg/helpers.js
@ -25,7 +25,7 @@ const is_wsl =
|
|||||||
process.platform === 'linux' &&
|
process.platform === 'linux' &&
|
||||||
os.release().toLowerCase().includes('microsoft'),
|
os.release().toLowerCase().includes('microsoft'),
|
||||||
// ~/.notion-enhancer absolute path.
|
// ~/.notion-enhancer absolute path.
|
||||||
data_folder = path.resolve(
|
__data = path.resolve(
|
||||||
`${
|
`${
|
||||||
is_wsl
|
is_wsl
|
||||||
? (() => {
|
? (() => {
|
||||||
@ -40,7 +40,59 @@ const is_wsl =
|
|||||||
})()
|
})()
|
||||||
: os.homedir()
|
: os.homedir()
|
||||||
}/.notion-enhancer`
|
}/.notion-enhancer`
|
||||||
);
|
),
|
||||||
|
// gets possible system notion app filepaths.
|
||||||
|
__notion = (() => {
|
||||||
|
let folder = '';
|
||||||
|
switch (process.platform) {
|
||||||
|
case 'darwin':
|
||||||
|
folder = '/Applications/Notion.app/Contents/Resources';
|
||||||
|
break;
|
||||||
|
case 'win32':
|
||||||
|
folder = process.env.LOCALAPPDATA + '\\Programs\\Notion\\resources';
|
||||||
|
break;
|
||||||
|
case 'linux':
|
||||||
|
if (is_wsl) {
|
||||||
|
const stdout = execSync('cmd.exe /c echo %localappdata%', {
|
||||||
|
encoding: 'utf8',
|
||||||
|
}),
|
||||||
|
drive = stdout[0];
|
||||||
|
folder = `/mnt/${drive.toLowerCase()}${stdout
|
||||||
|
.replace(/\\/g, '/')
|
||||||
|
.slice(2)
|
||||||
|
.trim()}/Programs/Notion/resources`;
|
||||||
|
} else {
|
||||||
|
for (let loc of [
|
||||||
|
'/usr/lib/notion-desktop/resources', // https://github.com/davidbailey00/notion-deb-builder/
|
||||||
|
'/opt/notion-app', // https://aur.archlinux.org/packages/notion-app/
|
||||||
|
'/opt/notion', // https://github.com/jaredallard/notion-app
|
||||||
|
]) {
|
||||||
|
if (fs.pathExistsSync(loc)) folder = loc;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!folder)
|
||||||
|
throw new EnhancerError('nothing found: platform not supported.');
|
||||||
|
// check if actual app files are present.
|
||||||
|
// if app/app.asar are missing but app.asar.bak present it will be moved to app.asar
|
||||||
|
const app_asar = path.resolve(`${folder}/app.asar`);
|
||||||
|
if (
|
||||||
|
!(
|
||||||
|
fs.pathExistsSync(folder) &&
|
||||||
|
(fs.pathExistsSync(app_asar) ||
|
||||||
|
fs.pathExistsSync(path.resolve(`${folder}/app`)))
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
const asar_bak = path.resolve(`${folder}/app.asar.bak`);
|
||||||
|
if (fs.pathExistsSync(asar_bak)) {
|
||||||
|
fs.moveSync(asar_bak, app_asar);
|
||||||
|
} else
|
||||||
|
throw new EnhancerError(
|
||||||
|
'nothing found: notion installation is either corrupted or non-existent.'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return folder;
|
||||||
|
})();
|
||||||
|
|
||||||
// transform a wsl filepath to its relative windows filepath if necessary.
|
// transform a wsl filepath to its relative windows filepath if necessary.
|
||||||
function realpath(hack_path) {
|
function realpath(hack_path) {
|
||||||
@ -52,62 +104,6 @@ function realpath(hack_path) {
|
|||||||
return hack_path;
|
return hack_path;
|
||||||
}
|
}
|
||||||
|
|
||||||
// gets possible system notion app filepaths.
|
|
||||||
function getNotion() {
|
|
||||||
let folder = '';
|
|
||||||
switch (process.platform) {
|
|
||||||
case 'darwin':
|
|
||||||
folder = '/Applications/Notion.app/Contents/Resources';
|
|
||||||
break;
|
|
||||||
case 'win32':
|
|
||||||
folder = process.env.LOCALAPPDATA + '\\Programs\\Notion\\resources';
|
|
||||||
break;
|
|
||||||
case 'linux':
|
|
||||||
if (is_wsl) {
|
|
||||||
const stdout = execSync('cmd.exe /c echo %localappdata%', {
|
|
||||||
encoding: 'utf8',
|
|
||||||
}),
|
|
||||||
drive = stdout[0];
|
|
||||||
folder = `/mnt/${drive.toLowerCase()}${stdout
|
|
||||||
.replace(/\\/g, '/')
|
|
||||||
.slice(2)
|
|
||||||
.trim()}/Programs/Notion/resources`;
|
|
||||||
} else {
|
|
||||||
for (let loc of [
|
|
||||||
'/usr/lib/notion-desktop/resources', // https://github.com/davidbailey00/notion-deb-builder/
|
|
||||||
'/opt/notion-app', // https://aur.archlinux.org/packages/notion-app/
|
|
||||||
'/opt/notion', // https://github.com/jaredallard/notion-app
|
|
||||||
]) {
|
|
||||||
if (fs.pathExistsSync(loc)) folder = loc;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!folder)
|
|
||||||
throw new EnhancerError(
|
|
||||||
'platform not supported: open a request in the github repo:\n' +
|
|
||||||
'https://github.com/dragonwocky/notion-enhancer/issues/new?labels=enhancement&template=platform-support.md'
|
|
||||||
);
|
|
||||||
// check if actual app files are present.
|
|
||||||
// if app/app.asar are missing but app.asar.bak present it will be moved to app.asar
|
|
||||||
const app_asar = path.resolve(`${folder}/app.asar`);
|
|
||||||
if (
|
|
||||||
!(
|
|
||||||
fs.pathExistsSync(folder) &&
|
|
||||||
(fs.pathExistsSync(app_asar) ||
|
|
||||||
fs.pathExistsSync(path.resolve(`${folder}/app`)))
|
|
||||||
)
|
|
||||||
) {
|
|
||||||
const asar_bak = path.resolve(`${folder}/app.asar.bak`);
|
|
||||||
if (fs.pathExistsSync(asar_bak)) {
|
|
||||||
fs.moveSync(asar_bak, app_asar);
|
|
||||||
} else
|
|
||||||
throw new EnhancerError(
|
|
||||||
'nothing found: notion installation is either corrupted or non-existent.'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return folder;
|
|
||||||
}
|
|
||||||
|
|
||||||
// lists/fetches all available extensions + themes
|
// lists/fetches all available extensions + themes
|
||||||
function getEnhancements() {
|
function getEnhancements() {
|
||||||
const modules = {
|
const modules = {
|
||||||
@ -179,9 +175,9 @@ function createElement(html) {
|
|||||||
module.exports = {
|
module.exports = {
|
||||||
EnhancerError,
|
EnhancerError,
|
||||||
is_wsl,
|
is_wsl,
|
||||||
data_folder,
|
__data,
|
||||||
|
__notion,
|
||||||
realpath,
|
realpath,
|
||||||
getNotion,
|
|
||||||
getEnhancements,
|
getEnhancements,
|
||||||
getJSON,
|
getJSON,
|
||||||
readline,
|
readline,
|
||||||
|
@ -25,15 +25,15 @@ const is_wsl;
|
|||||||
|
|
||||||
use `helpers.is_wsl` to check if the enhancer was run from the windows subsystem for linux.
|
use `helpers.is_wsl` to check if the enhancer was run from the windows subsystem for linux.
|
||||||
|
|
||||||
primarily used for internal handling of filepaths (e.g. in the `helpers.realpath` and `helpers.getNotion` functions).
|
primarily used for internal handling of filepaths (e.g. in the `helpers.realpath` function).
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
```js
|
```js
|
||||||
const data_folder;
|
const __data;
|
||||||
```
|
```
|
||||||
|
|
||||||
use `helpers.data_folder` to get the absolute path of the directory configuration/version
|
use `helpers.__data` to get the absolute path of the directory configuration
|
||||||
data is saved to by the enhancer.
|
data is saved to by the enhancer.
|
||||||
|
|
||||||
if used immediately after being accessed, it should always work. however, if fetching its value during enhancement
|
if used immediately after being accessed, it should always work. however, if fetching its value during enhancement
|
||||||
@ -42,6 +42,20 @@ and then inserting it into something that will not be executed until the app is
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
```js
|
||||||
|
const __notion;
|
||||||
|
```
|
||||||
|
|
||||||
|
use `helpers.__notion` to get the absolute path of the notion app parent folder.
|
||||||
|
|
||||||
|
primarily used for internal modding of the app (e.g. to apply the modloader and patch launch scripts).
|
||||||
|
|
||||||
|
if used immediately after being accessed, it should always work. however, if fetching its value during enhancement
|
||||||
|
and then inserting it into something that will not be executed until the app is opened, it must be put through
|
||||||
|
`helpers.realpath` before insertion.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
```js
|
```js
|
||||||
function realpath(hack_path) {
|
function realpath(hack_path) {
|
||||||
return runtime_path;
|
return runtime_path;
|
||||||
@ -56,18 +70,6 @@ primarily used for internal handling of filepaths (e.g. for the modloader).
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
```js
|
|
||||||
function getNotion() {
|
|
||||||
return notion_app_path;
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
use `await helpers.getNotion()` to get the notion app parent folder path.
|
|
||||||
|
|
||||||
primarily used for internal modding of the app (e.g. to apply the modloader and patch launch scripts).
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
```js
|
```js
|
||||||
function getEnhancements() {
|
function getEnhancements() {
|
||||||
return { loaded, invalid, dirs, IDs };
|
return { loaded, invalid, dirs, IDs };
|
||||||
|
@ -11,10 +11,9 @@ const fs = require('fs-extra'),
|
|||||||
helpers = require('./helpers.js'),
|
helpers = require('./helpers.js'),
|
||||||
store = require('./store.js');
|
store = require('./store.js');
|
||||||
|
|
||||||
let __notion = helpers.getNotion();
|
|
||||||
module.exports = function (__file, __exports) {
|
module.exports = function (__file, __exports) {
|
||||||
__file = __file
|
__file = __file
|
||||||
.slice(path.resolve(`${__notion}/app`).length + 1)
|
.slice(path.resolve(`${helpers.__notion}/app`).length + 1)
|
||||||
.replace(/\\/g, '/');
|
.replace(/\\/g, '/');
|
||||||
|
|
||||||
if (__file === 'main/security.js') {
|
if (__file === 'main/security.js') {
|
||||||
|
@ -18,28 +18,25 @@ const fs = require('fs-extra'),
|
|||||||
// ~~ exit
|
// ~~ exit
|
||||||
// ### error ###
|
// ### error ###
|
||||||
|
|
||||||
let __notion = helpers.getNotion();
|
|
||||||
module.exports = async function ({
|
module.exports = async function ({
|
||||||
overwrite_asar,
|
overwrite_asar,
|
||||||
delete_data,
|
delete_data,
|
||||||
friendly_errors,
|
friendly_errors,
|
||||||
} = {}) {
|
} = {}) {
|
||||||
try {
|
try {
|
||||||
const file_operations = [];
|
|
||||||
|
|
||||||
// extracted asar: modded
|
// extracted asar: modded
|
||||||
const app_folder = path.resolve(`${__notion}/app`);
|
const app_folder = path.resolve(`${helpers.__notion}/app`);
|
||||||
if (await fs.pathExists(app_folder)) {
|
if (await fs.pathExists(app_folder)) {
|
||||||
console.info(` ...removing folder ${app_folder}`);
|
console.info(` ...removing folder ${app_folder}`);
|
||||||
await fs.remove(app_folder);
|
await fs.remove(app_folder);
|
||||||
} else console.warn(` * ${app_folder} not found: step skipped.`);
|
} else console.warn(` * ${app_folder} not found: step skipped.`);
|
||||||
|
|
||||||
// restoring original asar
|
// restoring original asar
|
||||||
const asar_bak = path.resolve(`${__notion}/app.asar.bak`);
|
const asar_bak = path.resolve(`${helpers.__notion}/app.asar.bak`);
|
||||||
if (await fs.pathExists(asar_bak)) {
|
if (await fs.pathExists(asar_bak)) {
|
||||||
console.info(' ...moving asar.app.bak to app.asar');
|
console.info(' ...moving asar.app.bak to app.asar');
|
||||||
|
|
||||||
if (await fs.pathExists(path.resolve(`${__notion}/app.asar`))) {
|
if (await fs.pathExists(path.resolve(`${helpers.__notion}/app.asar`))) {
|
||||||
console.warn(' * app.asar already exists!');
|
console.warn(' * app.asar already exists!');
|
||||||
if (overwrite_asar === undefined) {
|
if (overwrite_asar === undefined) {
|
||||||
do {
|
do {
|
||||||
@ -60,15 +57,15 @@ module.exports = async function ({
|
|||||||
}
|
}
|
||||||
|
|
||||||
await (overwrite_asar || overwrite_asar === undefined
|
await (overwrite_asar || overwrite_asar === undefined
|
||||||
? fs.move(asar_bak, path.resolve(`${__notion}/app.asar`), {
|
? fs.move(asar_bak, path.resolve(`${helpers.__notion}/app.asar`), {
|
||||||
overwrite: true,
|
overwrite: true,
|
||||||
})
|
})
|
||||||
: fs.remove(asar_bak));
|
: fs.remove(asar_bak));
|
||||||
} else console.warn(` * ${asar_bak} not found: step skipped.`);
|
} else console.warn(` * ${asar_bak} not found: step skipped.`);
|
||||||
|
|
||||||
// cleaning data folder: ~/.notion-enhancer
|
// cleaning data folder: ~/.notion-enhancer
|
||||||
if (await fs.pathExists(helpers.data_folder)) {
|
if (await fs.pathExists(helpers.__data)) {
|
||||||
console.info(` ...data folder ${helpers.data_folder} found.`);
|
console.info(` ...data folder ${helpers.__data} found.`);
|
||||||
if (delete_data === undefined) {
|
if (delete_data === undefined) {
|
||||||
do {
|
do {
|
||||||
process.stdout.write(' > delete? [Y/n]: ');
|
process.stdout.write(' > delete? [Y/n]: ');
|
||||||
@ -81,27 +78,25 @@ module.exports = async function ({
|
|||||||
}
|
}
|
||||||
console.info(
|
console.info(
|
||||||
delete_data
|
delete_data
|
||||||
? ` -- deleting ${helpers.data_folder}`
|
? ` -- deleting ${helpers.__data}`
|
||||||
: ` -- keeping ${helpers.data_folder}`
|
: ` -- keeping ${helpers.__data}`
|
||||||
);
|
);
|
||||||
if (delete_data) {
|
if (delete_data) await fs.remove(helpers.__data);
|
||||||
await fs.remove(helpers.data_folder);
|
} else console.warn(` * ${helpers.__data} not found: step skipped.`);
|
||||||
} else fs.remove(path.resolve(`${helpers.data_folder}/version.txt`));
|
|
||||||
} else console.warn(` * ${helpers.data_folder} not found: step skipped.`);
|
|
||||||
|
|
||||||
// patching launch script target of custom wrappers
|
// patching launch script target of custom wrappers
|
||||||
if (
|
if (
|
||||||
[
|
[
|
||||||
'/opt/notion-app', // https://aur.archlinux.org/packages/notion-app/
|
'/opt/notion-app', // https://aur.archlinux.org/packages/notion-app/
|
||||||
'/opt/notion', // https://github.com/jaredallard/notion-app
|
'/opt/notion', // https://github.com/jaredallard/notion-app
|
||||||
].includes(__notion)
|
].includes(helpers.__notion)
|
||||||
) {
|
) {
|
||||||
console.info(
|
console.info(
|
||||||
' ...patching app launcher (notion-app linux wrappers only).'
|
' ...patching app launcher (notion-app linux wrappers only).'
|
||||||
);
|
);
|
||||||
for (let bin_path of [
|
for (let bin_path of [
|
||||||
`/usr/bin/${__notion.split('/')[2]}`,
|
`/usr/bin/${helpers.__notion.split('/')[2]}`,
|
||||||
`${__notion}/${__notion.split('/')[2]}`,
|
`${helpers.__notion}/${helpers.__notion.split('/')[2]}`,
|
||||||
]) {
|
]) {
|
||||||
const bin_script = await fs.readFile(bin_path, 'utf8');
|
const bin_script = await fs.readFile(bin_path, 'utf8');
|
||||||
if (!bin_script.includes('app.asar')) {
|
if (!bin_script.includes('app.asar')) {
|
||||||
|
@ -8,12 +8,12 @@
|
|||||||
|
|
||||||
const path = require('path'),
|
const path = require('path'),
|
||||||
fs = require('fs-extra'),
|
fs = require('fs-extra'),
|
||||||
{ getJSON, data_folder } = require('./helpers.js');
|
{ getJSON, __data } = require('./helpers.js');
|
||||||
|
|
||||||
// a wrapper for accessing data stored in a JSON file.
|
// a wrapper for accessing data stored in a JSON file.
|
||||||
module.exports = (namespace, defaults = {}) => {
|
module.exports = (namespace, defaults = {}) => {
|
||||||
namespace = path.resolve(`${data_folder}/${namespace}.json`);
|
namespace = path.resolve(`${__data}/${namespace}.json`);
|
||||||
fs.ensureDirSync(data_folder);
|
fs.ensureDirSync(__data);
|
||||||
|
|
||||||
let data;
|
let data;
|
||||||
const saveData = () => fs.writeJsonSync(namespace, data),
|
const saveData = () => fs.writeJsonSync(namespace, data),
|
||||||
|
Loading…
Reference in New Issue
Block a user