-
-
Notifications
You must be signed in to change notification settings - Fork 53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Displays a white screen Loading and reports an error [Cannot read properties of undefined (reading 'getHighEntropyValues')] #116
Comments
Fix SolutionI solved it, it's essentially the same problem as Can't type colon ":" and forward slash "/" · Issue #112 · notion-enhancer/notion-repackaged. Thank you @[@dario-99] for this brother’s contribution. root cause:After Notion is updated to the latest version, it references the API of [navigator.userAgentData.getHighEntropyValues]. And this [navigator.userAgentData] does not exist in the current Electron version of Notion-Repackeged. solution:I looked for the polyfill of [navigator.userAgentData.getHighEntropyValues] and found this article: User Agent Client Hints API (navigator.userAgentData) polyfill and ponyfill Especially in the [user-agent-data.js] file It should be noted that I modified the following places according to my own needs:
Below is my code file: pay attention!!!
(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(m2[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();
})(); |
Can someone kindly explain in detail what we are to do. What am I to do with that code? |
I try them all. like asar or paste code at the browser console. |
Just followed the complex solution steps and managed to get it working. Thanks for the tips @hanshou101! 🎉 |
Follow "The Complex One" and put the code in the Notice: there may be a typo in the code , line 57: Then it may work |
thanks @Z-nkk! i couldn't get it to work due to the typo in this exact line. now it's working again. also thanks @hanshou101 for providing the solution! |
Oh, it works! That's awesome. Thank you. In the past, my problem was that I left the app directory in |
This solution does not work for me on Manjaro. I followed the same steps as for the "can't type :" issue some month ago. Still i'm only seeing a blank screen with a loading circle in the middle.
platformVersion is empty for Linux, could this be the reason for why it is not working for me on Manjaro? |
Adding a |
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. |
This script worked in Arch Linux! Saved my day! Thank you so much! |
@acerspyro thanks, the script worked on ubuntu as well |
Thank you brother, I have not fully audited this js code, it is mainly based on my search results on google. It works in my environment, but I haven't tested it in other environments; thank you for your suggestions and fixes! ! ! I have incorporated your modification suggestions into the previous (to some extent not perfect) Solution . Thanks for your addition! It will definitely help a lot of people. |
Thanks for the script, thanks to the OP for the fix and everyone for the corrections. For me I also had to change the hardcoded path from EDIT: I also had to perform the following changes to the script:
Here is a gist with my modifications. |
The script also worked for me on Ubuntu, by installing |
Was anyone able to fix this issue on macOS? |
hey @shachar-ash, i got it to work on macOS. however, do note the issue i listed in #117 after patching… i suggest you enable "tray menu" now in the NE menu if you haven't, then start patching. |
按照老哥的建议遵循操作把问题解决了! PS: Thanks @hanshou101 @Z-nkk once more! |
Problem was solved on win11 using this method. Here are instructions to help Chinese users who cannot read English well to solve this problem. 我是win11用户,折腾了半个小时,使用该方法已解决问题,帮和我一样的英文很菜的电脑小白解释一下: 【思路】 【操作方法】 2.其次要安装解压.asar格式文件的工具。 然后安装asar,我参考这篇文章:https://www.cnblogs.com/cutewrp/p/14723913.html 3.最后解压asar,修改preload.js文件。 备份之后解压,然后修改preload文件,就是把贴主提供的代码粘贴到最后两行的前面,也就是下面这段代码的前面 然后贴主提供的代码的57行有个错误,你要手动把这一行的m2[2]改成m[2] 修改后重新打包,替换掉原路径里的app.asar文件,就大功告成了。 不过……修复之后你会发现你之前在notion-enhanced里的设置都丢失了,如果有备份的话直接上传就行,如果没备份……那只能手动重新设置了。建议以后还是勤快备份为好。 —————————— 感谢楼上所有人提供的参考信息。祝大家都能顺利修改~ Thanks to everyone above for the reference information. Good luck to all! |
I'm thankful for this post for making the app work on my ubuntu install, however I do notice the multiple account feature no longer works (which before this error worked fine I believe). Now it's only 1 account that it allows me to use, when trying to add the second account. |
@GRACEBL
I updated my comment with a few extra edits I needed to make and a link to a new gist. Without these fixes, I could not open external links and the "find in page" function did not work. |
Can you make a windows version if you have free time? I think many people need it. |
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
<#116 (comment)>,
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. |
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 |
I actually posted it as part of my original GitLab snippet (last file): https://gitlab.com/-/snippets/3615945 |
require('notion-enhancer')('renderer/preload', exports, (js) => eval(js)) |
Solution for ubunto/POP OS.Have notion-enhancer installed
Done, run notion-enhancer now and it should work! Thank you @MaximTh |
For anyone here on Ubuntu 23.10 or further with the error
Ubuntu recommends an alternative as
which worked just fine with the rest of the above script and my |
@colinschwegmann |
@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 |
Thank y'all |
Thanks! That saved my day. |
fixes upstream issues that cause the app to be unable to load, see notion-enhancer/notion-enhancer#812 notion-enhancer/notion-repackaged#116
thank you so much!! it worked. |
Worked for me in Ubuntu 22.04 modifying the paths in the script from:
to
Thank you! |
Works on manjaro also, thank you so much! |
Wonderful! Worked on Ubuntu 20!Thank you so much!!! |
Thanks! It worked on Fedora 41. But there is one correction. Change line 41 to
|
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.
The text was updated successfully, but these errors were encountered: