From c3a282181a4be05d75731bd21ea26eaaf5c5186e Mon Sep 17 00:00:00 2001 From: nohopestage <67389244+nohopestage@users.noreply.github.com> Date: Sat, 30 Oct 2021 03:00:06 +0200 Subject: [PATCH 1/5] Update registryConfig.js --- main/registryConfig.js | 62 ++++++++++++++++++++++++++---------------- 1 file changed, 38 insertions(+), 24 deletions(-) diff --git a/main/registryConfig.js b/main/registryConfig.js index b90eea55a..9eb5720bf 100644 --- a/main/registryConfig.js +++ b/main/registryConfig.js @@ -3,32 +3,32 @@ var regedit = require('regedit') var installPath = process.execPath var keysToCreate = [ - 'HKCU\\Software\\Classes\\Min', - 'HKCU\\Software\\Classes\\Min\\Application', - 'HKCU\\Software\\Classes\\Min\\DefaulIcon', - 'HKCU\\Software\\Classes\\Min\\shell\\open\\command', - 'HKCU\\Software\\Clients\\StartMenuInternet\\Min\\Capabilities\\FileAssociations', - 'HKCU\\Software\\Clients\\StartMenuInternet\\Min\\Capabilities\\StartMenu', - 'HKCU\\Software\\Clients\\StartMenuInternet\\Min\\Capabilities\\URLAssociations', - 'HKCU\\Software\\Clients\\StartMenuInternet\\Min\\DefaultIcon', - 'HKCU\\Software\\Clients\\StartMenuInternet\\Min\\InstallInfo', - 'HKCU\\Software\\Clients\\StartMenuInternet\\Min\\shell\\open\\command' + 'HKCR\\Min', + 'HKCR\\Min\\Application', + 'HKCR\\Min\\DefaulIcon', + 'HKCR\\Min\\shell\\open\\command', + 'HKLM\\SOFTWARE\\Clients\\StartMenuInternet\\Min\\Capabilities\\FileAssociations', + 'HKLM\\SOFTWARE\\Clients\\StartMenuInternet\\Min\\Capabilities\\StartMenu', + 'HKLM\\SOFTWARE\\Clients\\StartMenuInternet\\Min\\Capabilities\\URLAssociations', + 'HKLM\\SOFTWARE\\Clients\\StartMenuInternet\\Min\\DefaultIcon', + 'HKLM\\SOFTWARE\\Clients\\StartMenuInternet\\Min\\InstallInfo', + 'HKLM\\SOFTWARE\\Clients\\StartMenuInternet\\Min\\shell\\open\\command' ] var registryConfig = { - 'HKCU\\Software\\RegisteredApplications': { + 'HKLM\\SOFTWARE\\RegisteredApplications': { Min: { - value: 'Software\\Clients\\StartMenuInternet\\Min\\Capabilities', + value: 'SOFTWARE\\Clients\\StartMenuInternet\\Min\\Capabilities', type: 'REG_SZ' } }, - 'HKCU\\Software\\Classes\\Min': { + 'HKCR\\Min': { default: { value: 'Min Browser Document', type: 'REG_DEFAULT' } }, - 'HKCU\\Software\\Classes\\Min\\Application': { + 'HKCR\\Min\\Application': { ApplicationIcon: { value: installPath + ',0', type: 'REG_SZ' @@ -42,31 +42,37 @@ var registryConfig = { type: 'REG_SZ' } }, - 'HKCU\\Software\\Classes\\Min\\DefaulIcon': { + 'HKCR\\Min\\DefaulIcon': { ApplicationIcon: { value: installPath + ',0', type: 'REG_SZ' } }, - 'HKCU\\Software\\Classes\\Min\\shell\\open\\command': { + 'HKCR\\Min\\shell\\open\\command': { default: { value: '"' + installPath + '" "%1"', type: 'REG_DEFAULT' } }, - 'HKCU\\Software\\Classes\\.htm\\OpenWithProgIds': { + 'HKCR\\.htm\\OpenWithProgIds': { Min: { value: 'Empty', type: 'REG_SZ' } }, - 'HKCU\\Software\\Classes\\.html\\OpenWithProgIds': { + 'HKCR\\.html\\OpenWithProgIds': { Min: { value: 'Empty', type: 'REG_SZ' } }, - 'HKCU\\Software\\Clients\\StartMenuInternet\\Min\\Capabilities\\FileAssociations': { + 'HKCR\\.pdf\\OpenWithProgIds': { + Min: { + value: 'Empty', + type: 'REG_SZ' + } + }, + 'HKLM\\SOFTWARE\\Clients\\StartMenuInternet\\Min\\Capabilities\\FileAssociations': { '.htm': { value: 'Min', type: 'REG_SZ' @@ -74,15 +80,19 @@ var registryConfig = { '.html': { value: 'Min', type: 'REG_SZ' + }, + '.pdf': { + value: 'Min', + type: 'REG_SZ' } }, - 'HKCU\\Software\\Clients\\StartMenuInternet\\Min\\Capabilities\\StartMenu': { + 'HKLM\\SOFTWARE\\Clients\\StartMenuInternet\\Min\\Capabilities\\StartMenu': { StartMenuInternet: { value: 'Min', type: 'REG_SZ' } }, - 'HKCU\\Software\\Clients\\StartMenuInternet\\Min\\Capabilities\\URLAssociations': { + 'HKLM\\SOFTWARE\\Clients\\StartMenuInternet\\Min\\Capabilities\\URLAssociations': { http: { value: 'Min', type: 'REG_SZ' @@ -90,21 +100,25 @@ var registryConfig = { https: { value: 'Min', type: 'REG_SZ' + }, + urn: { + value: 'Min', + type: 'REG_SZ' } }, - 'HKCU\\Software\\Clients\\StartMenuInternet\\Min\\DefaultIcon': { + 'HKLM\\SOFTWARE\\Clients\\StartMenuInternet\\Min\\DefaultIcon': { default: { value: installPath + ',0', type: 'REG_DEFAULT' } }, - 'HKCU\\Software\\Clients\\StartMenuInternet\\Min\\InstallInfo': { + 'HKLM\\SOFTWARE\\Clients\\StartMenuInternet\\Min\\InstallInfo': { IconsVisible: { value: 1, type: 'REG_DWORD' } }, - 'HKCU\\Software\\Clients\\StartMenuInternet\\Min\\shell\\open\\command': { + 'HKLM\\SOFTWARE\\Clients\\StartMenuInternet\\Min\\shell\\open\\command': { default: { value: installPath, type: 'REG_DEFAULT' From 7d11b8abe553c17cdefac6de661d8585866da651 Mon Sep 17 00:00:00 2001 From: nohopestage <67389244+nohopestage@users.noreply.github.com> Date: Sat, 30 Oct 2021 20:00:41 +0200 Subject: [PATCH 2/5] Update registryConfig.js --- main/registryConfig.js | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/main/registryConfig.js b/main/registryConfig.js index 9eb5720bf..56b5fb3ee 100644 --- a/main/registryConfig.js +++ b/main/registryConfig.js @@ -11,10 +11,14 @@ var keysToCreate = [ 'HKLM\\SOFTWARE\\Clients\\StartMenuInternet\\Min\\Capabilities\\StartMenu', 'HKLM\\SOFTWARE\\Clients\\StartMenuInternet\\Min\\Capabilities\\URLAssociations', 'HKLM\\SOFTWARE\\Clients\\StartMenuInternet\\Min\\DefaultIcon', - 'HKLM\\SOFTWARE\\Clients\\StartMenuInternet\\Min\\InstallInfo', 'HKLM\\SOFTWARE\\Clients\\StartMenuInternet\\Min\\shell\\open\\command' ] +var keysToDelete = [ + 'HKCR\\Min', + 'HKLM\\SOFTWARE\\Clients\\StartMenuInternet\\Min' +] + var registryConfig = { 'HKLM\\SOFTWARE\\RegisteredApplications': { Min: { @@ -112,12 +116,6 @@ var registryConfig = { type: 'REG_DEFAULT' } }, - 'HKLM\\SOFTWARE\\Clients\\StartMenuInternet\\Min\\InstallInfo': { - IconsVisible: { - value: 1, - type: 'REG_DWORD' - } - }, 'HKLM\\SOFTWARE\\Clients\\StartMenuInternet\\Min\\shell\\open\\command': { default: { value: installPath, @@ -142,7 +140,7 @@ var registryInstaller = { }, uninstall: function () { return new Promise(function (resolve, reject) { - regedit.deleteKey(keysToCreate, function (err) { + regedit.deleteKey(keysToDelete, function (err) { if (err) { reject() } else { From 81cacb3bdabdd303669b79d45278e51a0ff364c0 Mon Sep 17 00:00:00 2001 From: nohopestage <67389244+nohopestage@users.noreply.github.com> Date: Thu, 4 Nov 2021 05:00:41 +0200 Subject: [PATCH 3/5] Update registryConfig.js Fixed the keys not being deleted on uninstall. Corrected a typo. Added a function to delete the values that are not being deleted with the keys. --- main/registryConfig.js | 61 ++++++++++++++++++++++++++++-------------- 1 file changed, 41 insertions(+), 20 deletions(-) diff --git a/main/registryConfig.js b/main/registryConfig.js index 56b5fb3ee..cc8f47208 100644 --- a/main/registryConfig.js +++ b/main/registryConfig.js @@ -3,9 +3,8 @@ var regedit = require('regedit') var installPath = process.execPath var keysToCreate = [ - 'HKCR\\Min', 'HKCR\\Min\\Application', - 'HKCR\\Min\\DefaulIcon', + 'HKCR\\Min\\DefaultIcon', 'HKCR\\Min\\shell\\open\\command', 'HKLM\\SOFTWARE\\Clients\\StartMenuInternet\\Min\\Capabilities\\FileAssociations', 'HKLM\\SOFTWARE\\Clients\\StartMenuInternet\\Min\\Capabilities\\StartMenu', @@ -14,11 +13,6 @@ var keysToCreate = [ 'HKLM\\SOFTWARE\\Clients\\StartMenuInternet\\Min\\shell\\open\\command' ] -var keysToDelete = [ - 'HKCR\\Min', - 'HKLM\\SOFTWARE\\Clients\\StartMenuInternet\\Min' -] - var registryConfig = { 'HKLM\\SOFTWARE\\RegisteredApplications': { Min: { @@ -34,7 +28,7 @@ var registryConfig = { }, 'HKCR\\Min\\Application': { ApplicationIcon: { - value: installPath + ',0', + value: `${installPath},0`, type: 'REG_SZ' }, ApplicationName: { @@ -46,33 +40,33 @@ var registryConfig = { type: 'REG_SZ' } }, - 'HKCR\\Min\\DefaulIcon': { + 'HKCR\\Min\\DefaultIcon': { ApplicationIcon: { - value: installPath + ',0', + value: `${installPath},0`, type: 'REG_SZ' } }, 'HKCR\\Min\\shell\\open\\command': { default: { - value: '"' + installPath + '" "%1"', + value: `${installPath} --single-argument %1`, type: 'REG_DEFAULT' } }, 'HKCR\\.htm\\OpenWithProgIds': { Min: { - value: 'Empty', + value: '', type: 'REG_SZ' } }, 'HKCR\\.html\\OpenWithProgIds': { Min: { - value: 'Empty', + value: '', type: 'REG_SZ' } }, 'HKCR\\.pdf\\OpenWithProgIds': { Min: { - value: 'Empty', + value: '', type: 'REG_SZ' } }, @@ -112,7 +106,7 @@ var registryConfig = { }, 'HKLM\\SOFTWARE\\Clients\\StartMenuInternet\\Min\\DefaultIcon': { default: { - value: installPath + ',0', + value: `${installPath},0`, type: 'REG_DEFAULT' } }, @@ -124,6 +118,31 @@ var registryConfig = { } } +var keysToDelete = [ + 'HKCR\\Min', + 'HKCR\\Min\\Application', + 'HKCR\\Min\\DefaultIcon', + 'HKCR\\Min\\shell', + 'HKCR\\Min\\shell\\open', + 'HKCR\\Min\\shell\\open\\command', + 'HKLM\\SOFTWARE\\Clients\\StartMenuInternet\\Min', + 'HKLM\\SOFTWARE\\Clients\\StartMenuInternet\\Min\\Capabilities', + 'HKLM\\SOFTWARE\\Clients\\StartMenuInternet\\Min\\Capabilities\\FileAssociations', + 'HKLM\\SOFTWARE\\Clients\\StartMenuInternet\\Min\\Capabilities\\StartMenu', + 'HKLM\\SOFTWARE\\Clients\\StartMenuInternet\\Min\\Capabilities\\URLAssociations', + 'HKLM\\SOFTWARE\\Clients\\StartMenuInternet\\Min\\DefaultIcon', + 'HKLM\\SOFTWARE\\Clients\\StartMenuInternet\\Min\\shell', + 'HKLM\\SOFTWARE\\Clients\\StartMenuInternet\\Min\\shell\\open', + 'HKLM\\SOFTWARE\\Clients\\StartMenuInternet\\Min\\shell\\open\\command' +] + +var valuesToDelete = [ + 'HKLM\\SOFTWARE\\RegisteredApplications\\Min', + 'HKCR\\.htm\\OpenWithProgIds\\Min', + 'HKCR\\.html\\OpenWithProgIds\\Min', + 'HKCR\\.pdf\\OpenWithProgIds\\Min' +] + var registryInstaller = { install: function () { return new Promise(function (resolve, reject) { @@ -141,11 +160,13 @@ var registryInstaller = { uninstall: function () { return new Promise(function (resolve, reject) { regedit.deleteKey(keysToDelete, function (err) { - if (err) { - reject() - } else { - resolve() - } + regedit.deleteValue(valuesToDelete, function (err) { + if (err) { + reject() + } else { + resolve() + } + }) }) }) } From 1817cc53ad632d4a7ca6ab9d91d76377f76076d1 Mon Sep 17 00:00:00 2001 From: nohopestage <67389244+nohopestage@users.noreply.github.com> Date: Thu, 4 Nov 2021 23:00:51 +0200 Subject: [PATCH 4/5] Update registryConfig.js Hopefully fixed some keys not being created on install, minor changes. --- main/registryConfig.js | 68 +++++++++++++++++++++++++++--------------- 1 file changed, 44 insertions(+), 24 deletions(-) diff --git a/main/registryConfig.js b/main/registryConfig.js index cc8f47208..54fdf3008 100644 --- a/main/registryConfig.js +++ b/main/registryConfig.js @@ -13,63 +13,87 @@ var keysToCreate = [ 'HKLM\\SOFTWARE\\Clients\\StartMenuInternet\\Min\\shell\\open\\command' ] -var registryConfig = { +var valuesToPut = { 'HKLM\\SOFTWARE\\RegisteredApplications': { - Min: { + 'Min': { value: 'SOFTWARE\\Clients\\StartMenuInternet\\Min\\Capabilities', type: 'REG_SZ' } }, 'HKCR\\Min': { - default: { + 'default': { value: 'Min Browser Document', type: 'REG_DEFAULT' } }, 'HKCR\\Min\\Application': { - ApplicationIcon: { + 'ApplicationDescription': { + value: 'Access the Internet', + type: 'REG_SZ' + }, + 'ApplicationIcon': { value: `${installPath},0`, type: 'REG_SZ' }, - ApplicationName: { + 'ApplicationName': { value: 'Min', type: 'REG_SZ' }, - AppUserModelId: { + 'AppUserModelId': { value: 'Min', type: 'REG_SZ' } }, 'HKCR\\Min\\DefaultIcon': { - ApplicationIcon: { + 'default': { value: `${installPath},0`, - type: 'REG_SZ' + type: 'REG_DEFAULT' } }, 'HKCR\\Min\\shell\\open\\command': { - default: { - value: `${installPath} --single-argument %1`, + 'default': { + value: `"${installPath}" --single-argument %1`, type: 'REG_DEFAULT' } }, 'HKCR\\.htm\\OpenWithProgIds': { - Min: { + 'Min': { value: '', type: 'REG_SZ' } }, 'HKCR\\.html\\OpenWithProgIds': { - Min: { + 'Min': { value: '', type: 'REG_SZ' } }, 'HKCR\\.pdf\\OpenWithProgIds': { - Min: { + 'Min': { value: '', type: 'REG_SZ' } }, + 'HKLM\\SOFTWARE\\Clients\\StartMenuInternet\\Min': { + 'default': { + value: 'Min', + type: 'REG_DEFAULT' + } + }, + 'HKLM\\SOFTWARE\\Clients\\StartMenuInternet\\Min\\Capabilities': { + 'ApplicationDescription': { + value: 'A fast, minimal browser that protects your privacy', + type: 'REG_SZ' + }, + 'ApplicationIcon': { + value: `${installPath},0`, + type: 'REG_SZ' + }, + 'ApplicationName': { + value: 'Min', + type: 'REG_SZ' + } + }, 'HKLM\\SOFTWARE\\Clients\\StartMenuInternet\\Min\\Capabilities\\FileAssociations': { '.htm': { value: 'Min', @@ -85,34 +109,30 @@ var registryConfig = { } }, 'HKLM\\SOFTWARE\\Clients\\StartMenuInternet\\Min\\Capabilities\\StartMenu': { - StartMenuInternet: { + 'StartMenuInternet': { value: 'Min', type: 'REG_SZ' } }, 'HKLM\\SOFTWARE\\Clients\\StartMenuInternet\\Min\\Capabilities\\URLAssociations': { - http: { - value: 'Min', - type: 'REG_SZ' - }, - https: { + 'http': { value: 'Min', type: 'REG_SZ' }, - urn: { + 'https': { value: 'Min', type: 'REG_SZ' } }, 'HKLM\\SOFTWARE\\Clients\\StartMenuInternet\\Min\\DefaultIcon': { - default: { + 'default': { value: `${installPath},0`, type: 'REG_DEFAULT' } }, 'HKLM\\SOFTWARE\\Clients\\StartMenuInternet\\Min\\shell\\open\\command': { - default: { - value: installPath, + 'default': { + value: `"${installPath}"`, type: 'REG_DEFAULT' } } @@ -147,7 +167,7 @@ var registryInstaller = { install: function () { return new Promise(function (resolve, reject) { regedit.createKey(keysToCreate, function (err) { - regedit.putValue(registryConfig, function (err) { + regedit.putValue(valuesToPut, function (err) { if (err) { reject() } else { From 588a0cf7a3baf629b2912f72bf33d7584f9f6502 Mon Sep 17 00:00:00 2001 From: PalmerAL Date: Sun, 28 Nov 2021 14:33:03 -0600 Subject: [PATCH 5/5] add sudo-prompt --- main/main.js | 16 +++++++++-- main/registryConfig.js | 63 +++++++++++++++++++++++++++--------------- package.json | 3 +- 3 files changed, 55 insertions(+), 27 deletions(-) diff --git a/main/main.js b/main/main.js index 2f3966102..c7eafdf28 100644 --- a/main/main.js +++ b/main/main.js @@ -36,15 +36,25 @@ function clamp (n, min, max) { if (process.platform === 'win32') { (async function () { - var squirrelCommand = process.argv[1] + var squirrelCommand = process.argv.find(arg => arg.startsWith('--squirrel')) if (squirrelCommand === '--squirrel-install' || squirrelCommand === '--squirrel-updated') { isInstallerRunning = true - await registryInstaller.install() + + await new Promise(function(resolve, reject) { + require('sudo-prompt').exec(process.execPath + " " + process.cwd() + "\\main\\registryConfig.js" + " --install", {ELECTRON_RUN_AS_NODE: 1, name: "Min"}, function() { + resolve() + }) + }) } if (squirrelCommand === '--squirrel-uninstall') { isInstallerRunning = true - await registryInstaller.uninstall() + await new Promise(function(resolve, reject) { + require('sudo-prompt').exec(process.execPath + " " + process.cwd() + "\\main\\registryConfig.js" + " --uninstall", {ELECTRON_RUN_AS_NODE: 1, name: "Min"}, function() { + resolve() + }) + }) } + if (require('electron-squirrel-startup')) { app.quit() } diff --git a/main/registryConfig.js b/main/registryConfig.js index 54fdf3008..e46733e18 100644 --- a/main/registryConfig.js +++ b/main/registryConfig.js @@ -15,81 +15,81 @@ var keysToCreate = [ var valuesToPut = { 'HKLM\\SOFTWARE\\RegisteredApplications': { - 'Min': { + Min: { value: 'SOFTWARE\\Clients\\StartMenuInternet\\Min\\Capabilities', type: 'REG_SZ' } }, 'HKCR\\Min': { - 'default': { + default: { value: 'Min Browser Document', type: 'REG_DEFAULT' } }, 'HKCR\\Min\\Application': { - 'ApplicationDescription': { + ApplicationDescription: { value: 'Access the Internet', type: 'REG_SZ' }, - 'ApplicationIcon': { + ApplicationIcon: { value: `${installPath},0`, type: 'REG_SZ' }, - 'ApplicationName': { + ApplicationName: { value: 'Min', type: 'REG_SZ' }, - 'AppUserModelId': { + AppUserModelId: { value: 'Min', type: 'REG_SZ' } }, 'HKCR\\Min\\DefaultIcon': { - 'default': { + default: { value: `${installPath},0`, type: 'REG_DEFAULT' } }, 'HKCR\\Min\\shell\\open\\command': { - 'default': { + default: { value: `"${installPath}" --single-argument %1`, type: 'REG_DEFAULT' } }, 'HKCR\\.htm\\OpenWithProgIds': { - 'Min': { + Min: { value: '', type: 'REG_SZ' } }, 'HKCR\\.html\\OpenWithProgIds': { - 'Min': { + Min: { value: '', type: 'REG_SZ' } }, 'HKCR\\.pdf\\OpenWithProgIds': { - 'Min': { + Min: { value: '', type: 'REG_SZ' } }, 'HKLM\\SOFTWARE\\Clients\\StartMenuInternet\\Min': { - 'default': { + default: { value: 'Min', type: 'REG_DEFAULT' } }, 'HKLM\\SOFTWARE\\Clients\\StartMenuInternet\\Min\\Capabilities': { - 'ApplicationDescription': { + ApplicationDescription: { value: 'A fast, minimal browser that protects your privacy', type: 'REG_SZ' }, - 'ApplicationIcon': { + ApplicationIcon: { value: `${installPath},0`, type: 'REG_SZ' }, - 'ApplicationName': { + ApplicationName: { value: 'Min', type: 'REG_SZ' } @@ -109,29 +109,29 @@ var valuesToPut = { } }, 'HKLM\\SOFTWARE\\Clients\\StartMenuInternet\\Min\\Capabilities\\StartMenu': { - 'StartMenuInternet': { + StartMenuInternet: { value: 'Min', type: 'REG_SZ' } }, 'HKLM\\SOFTWARE\\Clients\\StartMenuInternet\\Min\\Capabilities\\URLAssociations': { - 'http': { + http: { value: 'Min', type: 'REG_SZ' }, - 'https': { + https: { value: 'Min', type: 'REG_SZ' } }, 'HKLM\\SOFTWARE\\Clients\\StartMenuInternet\\Min\\DefaultIcon': { - 'default': { + default: { value: `${installPath},0`, type: 'REG_DEFAULT' } }, 'HKLM\\SOFTWARE\\Clients\\StartMenuInternet\\Min\\shell\\open\\command': { - 'default': { + default: { value: `"${installPath}"`, type: 'REG_DEFAULT' } @@ -167,9 +167,12 @@ var registryInstaller = { install: function () { return new Promise(function (resolve, reject) { regedit.createKey(keysToCreate, function (err) { + if (err) { + reject(err) + } regedit.putValue(valuesToPut, function (err) { if (err) { - reject() + reject(err) } else { resolve() } @@ -180,9 +183,12 @@ var registryInstaller = { uninstall: function () { return new Promise(function (resolve, reject) { regedit.deleteKey(keysToDelete, function (err) { + if (err) { + reject(err) + } regedit.deleteValue(valuesToDelete, function (err) { if (err) { - reject() + reject(err) } else { resolve() } @@ -190,4 +196,15 @@ var registryInstaller = { }) }) } -} +}; + +(async function () { + if (process.argv.some(arg => arg === '--install')) { + await registryInstaller.install() + process.exit() + } + if (process.argv.some(arg => arg === '--uninstall')) { + await registryInstaller.install() + process.exit() + } +})() diff --git a/package.json b/package.json index febfcee00..9d2c7fb35 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,8 @@ "node-abi": "^3.2.0", "pdfjs-dist": "2.4.456", "regedit": "^3.0.3", - "string_score": "^0.1.22" + "string_score": "^0.1.22", + "sudo-prompt": "^9.2.1" }, "devDependencies": { "archiver": "^4.0.1",