Open hanshou101 opened 10 months ago
Any chance this can be fixed for the appimage packaged versions?
UPD: fixed it myself. Here's what I did in case anyone needs:
./Notion-Enhanced-2.0.18-1.AppImage --appimage-extract
npm install -g asar
asar extract app.asar app
(inside the resources of the extracted appimage dir)asar pack ./app app.asar
./appimagetool-x86_64.AppImage squashfs-root notion.appimage
Actually I managed to get it working…. But I don’t exactly remember how !
Le jeu. 22 févr. 2024 à 10:56, Serhii P. @.***> a écrit :
Any chance this can be fixed for the appimage packaged versions?
— Reply to this email directly, view it on GitHub https://github.com/notion-enhancer/notion-repackaged/issues/116#issuecomment-1959085831, or unsubscribe https://github.com/notifications/unsubscribe-auth/AQCXNIMUVCITPA7LBBQPVVDYU4I47AVCNFSM6AAAAAA6SFPNW2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNJZGA4DKOBTGE . You are receiving this because you commented.Message ID: @.***>
If you're on Linux, I've wrapped it nicely into a Script.
Review the script's contents, mark as +x and run as root. This should patch your Notion Enhanced.
Tested to work on Fedora 39 with NE installed via RPM.
Can you make a windows version if you have free time? I think many people need it.
If you're on Linux, I've wrapped it nicely into a Script.
Review the script's contents, mark as +x and run as root. This should patch your Notion Enhanced.
Tested to work on Fedora 39 with NE installed via RPM.
It worked here on Ubuntu 22.04
Actually now I remember 😅. I’ve used your script. I would have loved to but unfortunately I do not have the skills required to do so…
On Mon, 26 Feb 2024 at 17:20, Samuel @.***> wrote:
If you're on Linux, I've wrapped it nicely into a Script.
Review the script's contents, mark as +x and run as root. This should patch your Notion Enhanced.
Tested to work on Fedora 39 with NE installed via RPM.
patch-notion-enhanced.sh https://gitlab.com/-/snippets/3615945
Can you make a windows version if you have free time? I think many people need it.
— Reply to this email directly, view it on GitHub https://github.com/notion-enhancer/notion-repackaged/issues/116#issuecomment-1964557642, or unsubscribe https://github.com/notifications/unsubscribe-auth/AQCXNII6RD7FWCP42N52IC3YVSY53AVCNFSM6AAAAAA6SFPNW2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNRUGU2TONRUGI . You are receiving this because you commented.Message ID: @.***>
A script for windows was posted in the Discord here, if you'd like to give it a try @fengmao31.
A script for windows was posted in the Discord here, if you'd like to give it a try @fengmao31.
something wrong with the Discord link.
@fengmao31 you will need to join the server first, before you are able to jump to specific messages from a link
A script for windows was posted in the Discord here, if you'd like to give it a try @fengmao31.
I actually posted it as part of my original GitLab snippet (last file): https://gitlab.com/-/snippets/3615945
解决方案有点乱,所以这里将解决方案合并到一条评论中:
- 安装
asar
sudo pacman -S asar
或者
npm i -g asar
- 去
/opt/Notion/resources/app.asar
- 提取内容
sudo asar extract app.asar app
- 将以下代码粘贴到 的末尾
./app/renderer/preload.js
:(function __polyfill_2() { function getClientHints(navigator) { let { userAgent } = navigator; let mobile, platform = '', platformVersion = '', architecture = '', bitness = '', model = '', uaFullVersion = '', fullVersionList = []; let platformInfo = userAgent; let found = false; let versionInfo = userAgent.replace(/\(([^)]+)\)?/g, ($0, $1) => { if (!found) { platformInfo = $1; found = true; } return ''; }); let items = versionInfo.match(/(\S+)\/(\S+)/g); let webview = false; // detect mobile mobile = userAgent.indexOf('Mobile') !== -1; let m; let m2; // detect platform if ((m = /Windows NT (\d+(\.\d+)*)/.exec(platformInfo)) !== null) { platform = 'Windows'; // see https://docs.microsoft.com/en-us/microsoft-edge/web-platform/how-to-detect-win11 let nt2win = { '6.1': '0.1', // win-7 '6.2': '0.2', // win-8 '6.3': '0.3', // win-8.1 '10.0': '10.0', // win-10 '11.0': '13.0', // win-11 }; let ver = nt2win[m[1]]; if (ver) platformVersion = padVersion(ver, 3); if ((m2 = /\b(WOW64|Win64|x64)\b/.exec(platformInfo)) !== null) { architecture = 'x86'; bitness = '64'; } } else if ((m = /Android (\d+(\.\d+)*)/.exec(platformInfo)) !== null) { platform = 'Android'; platformVersion = padVersion(m[1]); if ((m2 = /Linux (\w+)/.exec(navigator.platform)) !== null) { if (m2[1]) { m2 = parseArch(m2[1]); architecture = m2[0]; bitness = m2[1]; } } } else if ((m = /(iPhone|iPod touch); CPU iPhone OS (\d+(_\d+)*)/.exec(platformInfo)) !== null) { // see special notes at https://www.whatismybrowser.com/guides/the-latest-user-agent/safari platform = 'iOS'; platformVersion = padVersion(m[2].replace(/_/g, '.')); } else if ((m = /(iPad); CPU OS (\d+(_\d+)*)/.exec(platformInfo)) !== null) { platform = 'iOS'; platformVersion = padVersion(m[2].replace(/_/g, '.')); } else if ((m = /Macintosh; (Intel|\w+) Mac OS X (\d+(_\d+)*)/.exec(platformInfo)) !== null) { platform = 'macOS'; platformVersion = padVersion(m[2].replace(/_/g, '.')); } else if ((m = /Linux/.exec(platformInfo)) !== null) { platform = 'Linux'; platformVersion = ''; // TODO } else if ((m = /CrOS (\w+) (\d+(\.\d+)*)/.exec(platformInfo)) !== null) { platform = 'Chrome OS'; platformVersion = padVersion(m[2]); m2 = parseArch(m[1]); architecture = m2[0]; bitness = m2[1]; } if (!platform) { platform = 'Unknown'; } // detect fullVersionList / brands let notABrand = { brand: ' Not;A Brand', version: '99.0.0.0' }; if ((m = /Chrome\/(\d+(\.\d+)*)/.exec(versionInfo)) !== null && navigator.vendor === 'Google Inc.') { fullVersionList.push({ brand: 'Chromium', version: padVersion(m[1], 4) }); if ((m2 = /(Edge?)\/(\d+(\.\d+)*)/.exec(versionInfo)) !== null) { let identBrandMap = { 'Edge': 'Microsoft Edge', 'Edg': 'Microsoft Edge', }; let brand = identBrandMap[m[1]]; fullVersionList.push({ brand: brand, version: padVersion(m2[2], 4) }); } else { fullVersionList.push({ brand: 'Google Chrome', version: padVersion(m[1], 4) }); } if (/\bwv\b/.exec(platformInfo)) { webview = true; } } else if ((m = /AppleWebKit\/(\d+(\.\d+)*)/.exec(versionInfo)) !== null && navigator.vendor === 'Apple Computer, Inc.') { fullVersionList.push({ brand: 'WebKit', version: padVersion(m[1]) }); if (platform === 'iOS' && (m2 = /(CriOS|EdgiOS|FxiOS|Version)\/(\d+(\.\d+)*)/.exec(versionInfo)) != null) { let identBrandMap = { // no 'CriOS': 'Google Chrome', 'EdgiOS': 'Microsoft Edge', 'FxiOS': 'Mozilla Firefox', 'Version': 'Apple Safari', }; let brand = identBrandMap[m2[1]]; fullVersionList.push({ brand, version: padVersion(m2[2]) }); if (items.findIndex((s) => s.startsWith('Safari/')) === -1) { webview = true; } } } else if ((m = /Firefox\/(\d+(\.\d+)*)/.exec(versionInfo)) !== null) { fullVersionList.push({ brand: 'Firefox', version: padVersion(m[1]) }); } else if ((m = /(MSIE |rv:)(\d+\.\d+)/.exec(platformInfo)) !== null) { fullVersionList.push({ brand: 'Internet Explorer', version: padVersion(m[2]) }); } else { fullVersionList.push(notABrand); } uaFullVersion = fullVersionList.length > 0 ? fullVersionList[fullVersionList.length - 1] : ''; let brands = fullVersionList.map((b) => { let pos = b.version.indexOf('.'); let version = pos === -1 ? b.version : b.version.slice(0, pos); return { brand: b.brand, version }; }); // TODO detect architecture, bitness and model return { mobile, platform, brands, platformVersion, architecture, bitness, model, uaFullVersion, fullVersionList, webview }; } function parseArch(arch) { switch (arch) { case 'x86_64': case 'x64': return ['x86', '64']; case 'x86_32': case 'x86': return ['x86', '']; case 'armv6l': case 'armv7l': case 'armv8l': return [arch, '']; case 'aarch64': return ['arm', '64']; default: return ['', '']; } } function padVersion(ver, minSegs = 3) { let parts = ver.split('.'); let len = parts.length; if (len < minSegs) { for (let i = 0, lenToPad = minSegs - len; i < lenToPad; i += 1) { parts.push('0'); } return parts.join('.'); } return ver; } class NavigatorUAData { constructor() { this._ch = getClientHints(navigator); Object.defineProperties(this, { _ch: { enumerable: false }, }); } get mobile() { return this._ch.mobile; } get platform() { return this._ch.platform; } get brands() { return this._ch.brands; } getHighEntropyValues(hints) { return new Promise((resolve, reject) => { if (!Array.isArray(hints)) { throw new TypeError('argument hints is not an array'); } let hintSet = new Set(hints); let data = this._ch; let obj = { mobile: data.mobile, platform: data.platform, brands: data.brands, }; if (hintSet.has('architecture')) obj.architecture = data.architecture; if (hintSet.has('bitness')) obj.bitness = data.bitness; if (hintSet.has('model')) obj.model = data.model; if (hintSet.has('platformVersion')) obj.platformVersion = data.platformVersion; if (hintSet.has('uaFullVersion')) obj.uaFullVersion = data.uaFullVersion; if (hintSet.has('fullVersionList')) obj.fullVersionList = data.fullVersionList; resolve(obj); }); } toJSON() { let data = this._ch; return { mobile: data.mobile, brands: data.brands, }; } } Object.defineProperty(NavigatorUAData.prototype, Symbol.toStringTag, { enumerable: false, configurable: true, writable: false, value: 'NavigatorUAData' }); function ponyfill() { return new NavigatorUAData(navigator); } function polyfill() { console.log("Try polyfill . . ."); // When Notion , no need https? const ____use_https = false; if ( (!____use_https || location.protocol === 'https:') && !navigator.userAgentData ) { console.log("Here,begin userAgentData polyfill . . .") let userAgentData = new NavigatorUAData(navigator); Object.defineProperty(Navigator.prototype, 'userAgentData', { enumerable: true, configurable: true, get: function getUseAgentData() { return userAgentData; } }); Object.defineProperty(window, 'NavigatorUAData', { enumerable: false, configurable: true, writable: true, value: NavigatorUAData }); return true; } return false; } // Simple Apply this code. ponyfill(); polyfill(); })();
- 重新包装
sudo asar pack app app.asar
谢谢@dario-99,@Z-nkk和@hanshou101❤️
来源
require('notion-enhancer')('renderer/preload', exports, (js) => eval(js)) last line need add ";" require('notion-enhancer')('renderer/preload', exports, (js) => eval(js));
Have notion-enhancer installed Using the script mentioned above.
git clone https://gitlab.com/-/snippets/3615945
cd 3615945/
chmod +x
sudo ./patch-notion-enhanced.linux.sh
Done, run notion-enhancer now and it should work!
Thank you @MaximTh
For anyone here on Ubuntu 23.10 or further with the error
E: Unable to locate package asar
asar
isn't available in the usual apt packages. I think you could add it as a package repository in Ubuntu 23.10 but I couldn't be bothered to figure it out.
Ubuntu recommends an alternative as
snap install asar --classic
which worked just fine with the rest of the above script and my notion-app-enhanced
is working just fine now.
@colinschwegmann asar
is distributed as an npm module, so the recommended way to call it is to via: npx @electron/asar extract ...
(assuming Node,js is installed, this does not require asar
itself to be specifically installed).
@dragonwocky no use telling me that. The script tries to install it via apt. That won't work on stock Ubuntu so I've provided a solution. You or someone else is welcome to change that script to adhere to your recommendations - I'm simply stating what I needed to do get it to work.
for arch based distros, install this package instead: https://aur.archlinux.org/packages/notion-app-electron
I don't know what I can do ?
Thank y'all
If you're on Linux, I've wrapped it nicely into a Script. Review the script's contents, rename the extension to just
.sh
, mark as +x and run as root. This should patch your Notion Enhanced. Tested to work on Fedora 39 with NE installed via RPM.patch-notion-enhanced.sh.txtDO NOT USE THAT!!!Thanks for the script, thanks to the OP for the fix and everyone for the corrections.
For me
asar
was not available in the package manager, so I installed globally withsudo npm install -g --engine-strict @electron/asar
.I also had to change the hardcoded path from
/opt/Notion\ Enhanced/resources/
to/opt/Notion/resources
(lines 41 and 331).EDIT: I also had to perform the following changes to the script:
- change
EOL
in line:62 to'EOL'
(see https://stackoverflow.com/a/22698106/1305020) because otherwise the($0, $1)
expression in line 69 were replaced with the name of the script and the first argument (unquoted) causing exceptions in preload.js and breaking other features in Notion.- add an empty new line before
(function __polyfill_2() {
(otherwise the first line was appended to an existing line in the preload.js script which was a comment, therefore breakin the script).Here is a gist with my modifications.
Thanks! That saved my day. A little sugesstion, could you update the link to newest version of script in your quote? I downloaded the older txt file in quote by mistake. The older script complaint "It looks like your browser is currently blocking popups. Please allow pop-ups to continue". It's hard to realize where the bug is :(
Scene
When I open NotionRepackged, it displays a white screen Loading and reports an error [Cannot read properties of undefined (reading 'getHighEntropyValues')] on the command line.