diff --git a/package.json b/package.json index 35071417..72230289 100644 --- a/package.json +++ b/package.json @@ -52,7 +52,7 @@ "asar": "false", "extraResources": { "from": "archives", - "to": "app/archives" + "to": "archives" }, "fileAssociations": [ { @@ -111,6 +111,7 @@ "CHANGELOG.md", "LICENCE", "manifest.json", + "replayWorker.js", "www/**", "preload.cjs", "main.cjs", diff --git a/www/js/app.js b/www/js/app.js index 969e5b65..f72aebfa 100644 --- a/www/js/app.js +++ b/www/js/app.js @@ -3155,8 +3155,10 @@ if (storages !== null && storages.length > 0 || // because a new path is established each time the image's filesystem is mounted. So we reset to default. var archiveFilePath = params.storedFilePath; if (params.storedFile === params.packagedFile) { - // If the app is packed inside an asar archive, we need to alter the archivePath to point outside the asar directory - if (/\/app.asar\//.test(document.location.href) && !/^\.\.[\\/]/.test(params.archivePath)) params.archivePath = '../' + params.archivePath; + // If the app is packed inside an asar archive, or is Electron running from localhost, we need to alter the archivePath to point outside the asar directory + if ((/\/app.asar\//.test(document.location.href) || window.fs && document.location.protocol === 'http:')) { + params.archivePath = params.archivePath.replace(/^(?:resources\/)?/, 'resources/'); + } archiveFilePath = params.archivePath + '/' + params.packagedFile; if (~params.storedFilePath.indexOf(archiveFilePath)) { params.storedFilePath = archiveFilePath; @@ -4110,8 +4112,10 @@ function loadPackagedArchive () { settingsStore.removeItem('lastSelectedArchivePath'); params.lastPageVisit = ''; if (params.packagedFile && params.storedFile !== params.packagedFile) { - // If the app is packed inside an asar archive, we need to alter the archivePath to point outside the asar directory - if (/\/app.asar\//.test(document.location.href) && !/^\.\.[\\/]/.test(params.archivePath)) params.archivePath = '../' + params.archivePath; + // If the app is packed inside an asar archive, or is Electron running from localhost we need to alter the archivePath to point outside the asar directory + if ((/\/app.asar\//.test(document.location.href) || window.fs && document.location.protocol === 'http:')) { + params.archivePath = params.archivePath.replace(/^(?:resources\/)?/, 'resources/'); + } readNodeDirectoryAndCreateNodeFileObjects(params.archivePath, params.packagedFile).then(function (fileset) { var fileObjects = fileset[0], fileNames = fileset[1]; // params.pickedFile = params.packagedFile; diff --git a/www/js/lib/uiUtil.js b/www/js/lib/uiUtil.js index e33a0116..67251f89 100644 --- a/www/js/lib/uiUtil.js +++ b/www/js/lib/uiUtil.js @@ -81,6 +81,7 @@ let scrollThrottle = false; * Luuncher for the slide-away function, including a throttle to prevent it being called too often */ function scroller (e) { + if (!e) return; if (scrollThrottle || params.hideToolbars === false) return; // We have to refresh the articleContainer when the window changes articleContainer = document.getElementById('articleContent');