electron-extension-installer
Advanced tools
Comparing version 1.0.3 to 1.0.4
@@ -40,2 +40,15 @@ "use strict"; | ||
const fs_jetpack_1 = __importDefault(require("fs-jetpack")); | ||
// These overrides are for extensions whose official CRX file hosted on google uses Chrome APIs unsupported by electron | ||
// Thankfully collected by @xupea | ||
const OVERRIDES = [ | ||
"bhljhndlimiafopmmhjlgfpnnchjjbhd", | ||
"bmdblncegkenkacieihfhpjfppoconhi", | ||
"dbhhnnnpaeobfddmlalhnehgclcmjimi", | ||
"fmkadmapgofadopljbjfkapdkoienihi", | ||
"ienfalfjdbdpebioblfackkekamfmbnh", | ||
"jdkknkkbebbapilgoeccciglkfbmbnfm", | ||
"lmhkpmbekcpmknklioeibfkpmmfibljd", | ||
"nhdogjmejiglipccpnnnanhbledajbpd", | ||
"pfgnfdagidkfgccljigdamigbcnndkod", | ||
]; | ||
async function downloadChromeExtension(chromeStoreID, forceDownload, attempts = 5) { | ||
@@ -51,5 +64,9 @@ try { | ||
} | ||
const fileURL = `https://clients2.google.com/service/update2/crx?response=redirect&acceptformat=crx2,crx3&x=id%3D${chromeStoreID}%26uc&prodversion=32`; | ||
const chromeVersion = process.versions.chrome || 32; | ||
let fileURL = `https://clients2.google.com/service/update2/crx?response=redirect&acceptformat=crx2,crx3&x=id%3D${chromeStoreID}%26uc&prodversion=${chromeVersion}`; | ||
if (OVERRIDES.includes(chromeStoreID)) { | ||
fileURL = `https://github.com/jonluca/electron-extension-installer/raw/main/overrides/${chromeStoreID}.crx`; | ||
} | ||
const filePath = path.resolve(`${extensionFolder}.crx`); | ||
await (0, utils_1.downloadFile)(fileURL, filePath); | ||
await (0, utils_1.fetchCrxFile)(fileURL, filePath); | ||
try { | ||
@@ -56,0 +73,0 @@ await (0, unzip_1.default)(filePath, extensionFolder); |
export declare const getExtensionPath: () => string; | ||
export declare const downloadFile: (from: string, to: string) => Promise<void>; | ||
export declare const fetchCrxFile: (from: string, to: string) => Promise<void>; | ||
export declare const changePermissions: (dir: string, mode: string | number) => void; | ||
export declare const getIdMap: () => any; |
@@ -6,3 +6,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getIdMap = exports.changePermissions = exports.downloadFile = exports.getExtensionPath = void 0; | ||
exports.getIdMap = exports.changePermissions = exports.fetchCrxFile = exports.getExtensionPath = void 0; | ||
const fs_1 = __importDefault(require("fs")); | ||
@@ -16,3 +16,3 @@ const path_1 = __importDefault(require("path")); | ||
exports.getExtensionPath = getExtensionPath; | ||
const downloadFile = async (from, to) => { | ||
const fetchCrxFile = async (from, to) => { | ||
return new Promise((resolve, reject) => { | ||
@@ -45,3 +45,3 @@ const request = electron_1.net.request(from); | ||
}; | ||
exports.downloadFile = downloadFile; | ||
exports.fetchCrxFile = fetchCrxFile; | ||
const changePermissions = (dir, mode) => { | ||
@@ -48,0 +48,0 @@ const files = fs_1.default.readdirSync(dir); |
{ | ||
"name": "electron-extension-installer", | ||
"version": "1.0.3", | ||
"version": "1.0.4", | ||
"license": "MIT", | ||
@@ -5,0 +5,0 @@ "author": "Jonluca DeCaro <electronextension@jonlu.ca>", |
@@ -7,5 +7,18 @@ import type { LoadExtensionOptions } from "electron"; | ||
import unzip from "./unzip"; | ||
import { changePermissions, downloadFile, getExtensionPath, getIdMap } from "./utils"; | ||
import { changePermissions, fetchCrxFile, getExtensionPath, getIdMap } from "./utils"; | ||
import jetpack from "fs-jetpack"; | ||
// These overrides are for extensions whose official CRX file hosted on google uses Chrome APIs unsupported by electron | ||
// Thankfully collected by @xupea | ||
const OVERRIDES = [ | ||
"bhljhndlimiafopmmhjlgfpnnchjjbhd", | ||
"bmdblncegkenkacieihfhpjfppoconhi", | ||
"dbhhnnnpaeobfddmlalhnehgclcmjimi", | ||
"fmkadmapgofadopljbjfkapdkoienihi", | ||
"ienfalfjdbdpebioblfackkekamfmbnh", | ||
"jdkknkkbebbapilgoeccciglkfbmbnfm", | ||
"lmhkpmbekcpmknklioeibfkpmmfibljd", | ||
"nhdogjmejiglipccpnnnanhbledajbpd", | ||
"pfgnfdagidkfgccljigdamigbcnndkod", | ||
]; | ||
async function downloadChromeExtension(chromeStoreID: string, forceDownload: boolean, attempts = 5): Promise<string> { | ||
@@ -21,5 +34,10 @@ try { | ||
} | ||
const fileURL = `https://clients2.google.com/service/update2/crx?response=redirect&acceptformat=crx2,crx3&x=id%3D${chromeStoreID}%26uc&prodversion=32`; | ||
const chromeVersion = process.versions.chrome || 32; | ||
let fileURL = `https://clients2.google.com/service/update2/crx?response=redirect&acceptformat=crx2,crx3&x=id%3D${chromeStoreID}%26uc&prodversion=${chromeVersion}`; | ||
if (OVERRIDES.includes(chromeStoreID)) { | ||
fileURL = `https://github.com/jonluca/electron-extension-installer/raw/main/overrides/${chromeStoreID}.crx`; | ||
} | ||
const filePath = path.resolve(`${extensionFolder}.crx`); | ||
await downloadFile(fileURL, filePath); | ||
await fetchCrxFile(fileURL, filePath); | ||
@@ -26,0 +44,0 @@ try { |
@@ -10,3 +10,3 @@ import fs from "fs"; | ||
export const downloadFile = async (from: string, to: string): Promise<void> => { | ||
export const fetchCrxFile = async (from: string, to: string): Promise<void> => { | ||
return new Promise<void>((resolve, reject) => { | ||
@@ -13,0 +13,0 @@ const request = net.request(from); |
29923
700