diff --git a/main/main.js b/main/main.js index 2534d5326..1c480eee9 100644 --- a/main/main.js +++ b/main/main.js @@ -1,6 +1,8 @@ const electron = require('electron') const fs = require('fs') const path = require('path') +//const process = require('process') +require("v8-compile-cache"); const { app, // Module to control application life. @@ -14,6 +16,10 @@ const { dialog, nativeTheme } = electron +const getDirectories = source => + readdirSync(source, { withFileTypes: true }) + .filter(dirent => dirent.isDirectory()) + .map(dirent => dirent.name) crashReporter.start({ submitURL: 'https://minbrowser.org/', @@ -21,6 +27,67 @@ crashReporter.start({ compress: true }) +// WideVine DRM support for: Windows, MacOS and Linux for x86(32 and 64 bit) +console.log("Searching Widevine DRM..."); //DEBUGGING +var WIDEVINE_SUPPORT = false; +var WIDEVINE_PATH = ""; +console.log("Platform: "+process.platform); +console.log("Arch: "+process.arch); +if (process.platform === "win32") { + if (fs.existsSync("C:/Program Files(x86)/Google/Chrome/")) { + let all_dirs = getDirectories("C:/Program Files(x86)/Google/Chrome/Application/"); + let chrome_dir = all_dirs[all_dirs.length()-1]; + if (process.arch === "x32") { + WIDEVINE_SUPPORT = true; + WIDEVINE_PATH = "C:/Program Files(x86)/Google/Chrome/Application/{CHROME_VERSION}/WidevineCdm/_platform_specific/win_x86/widevinecdm.dll"; + WIDEVINE_PATH = WIDEVINE_PATH.replace("{CHROME_VERSION}", chrome_dir); + console.log("Widevine ready!"); + } else if (process.arch === "x64") { + WIDEVINE_SUPPORT = true; + WIDEVINE_PATH = "C:/Program Files(x86)/Google/Chrome/Application/{CHROME_VERSION}/WidevineCdm/_platform_specific/win_x64/widevinecdm.dll"; + WIDEVINE_PATH = WIDEVINE_PATH.replace("{CHROME_VERSION}", chrome_dir); + console.log("Widevine ready!"); + } + } +} else if (process.platform === "darwin") { + if (fs.existsSync("/Applications/Google Chrome.app/")) { + let all_dirs = getDirectories("/Applications/Google Chrome.app/Contents/Versions/"); + let chrome_dir = all_dirs[all_dirs.length()-1] + if (chrome_dir != '') { + if (process.arch === "x32") { + WIDEVINE_SUPPORT = true; + WIDEVINE_PATH = "/Applications/Google Chrome.app/Contents/Versions/{CHROME_VERSION}/Google Chrome Framework.framework/Versions/A/Libraries/WidevineCdm/_platform_specific/mac_x86/libwidevinecdm.dylib"; + WIDEVINE_PATH = WIDEVINE_PATH.replace("{CHROME_VERSION}", chrome_dir); + console.log("Widevine ready!"); + } else if (process.arch === "x64") { + WIDEVINE_SUPPORT = true; + WIDEVINE_PATH = "/Applications/Google Chrome.app/Contents/Versions/{CHROME_VERSION}/Google Chrome Framework.framework/Versions/A/Libraries/WidevineCdm/_platform_specific/mac_x86/libwidevinecdm.dylib"; + WIDEVINE_PATH = WIDEVINE_PATH.replace("{CHROME_VERSION}", chrome_dir); + console.log("Widevine ready!"); + } + } + } +} else if ((process.platform === "linux") || (process.platform === "cygwin")) { + if (fs.existsSync("/opt/google/chrome/WidevineCdm")) { + if (process.arch === "x32") { + WIDEVINE_SUPPORT = true; + WIDEVINE_PATH = "/opt/google/chrome/WidevineCdm/_platform_specific/linux_x86/libwidevinecdm.so"; + console.log("Widevine ready!"); + } else if (process.arch === "x64") { + WIDEVINE_SUPPORT = true; + WIDEVINE_PATH = "/opt/google/chrome/WidevineCdm/_platform_specific/linux_x64/libwidevinecdm.so"; + console.log("Widevine ready!"); + } + } +} +if (WIDEVINE_SUPPORT) { + app.commandLine.appendSwitch('widevine-cdm-path', WIDEVINE_PATH) + app.commandLine.appendSwitch('widevine-cdm-version', '1.4.8.866') // * - Experimental: This version should work fine for Electron, even if it is not the real WideVine version + console.log("Widevine loaded!"); +} else { + console.log("Widevine not loaded!"); +} + if (process.argv.some(arg => arg === '-v' || arg === '--version')) { console.log('Min: ' + app.getVersion()) console.log('Chromium: ' + process.versions.chrome) diff --git a/main/registryConfig.js b/main/registryConfig.js index b90eea55a..9f5bd037e 100644 --- a/main/registryConfig.js +++ b/main/registryConfig.js @@ -1,4 +1,5 @@ var regedit = require('regedit') +var process = require('process') var installPath = process.execPath diff --git a/package.json b/package.json index 41356a542..35f32770f 100644 --- a/package.json +++ b/package.json @@ -29,7 +29,7 @@ ] }, "dependencies": { - "dexie": "^3.0.3", + "dexie": "^3.2.2", "dragula": "github:minbrowser/dragula", "electron-squirrel-startup": "^1.0.0", "expr-eval": "^2.0.2", @@ -39,24 +39,25 @@ "pdfjs-dist": "2.12.313", "regedit": "^3.0.3", "stemmer": "^1.0.5", - "string_score": "^0.1.22" + "string_score": "^0.1.22", + "v8-compile-cache": "^2.3.0" }, "devDependencies": { - "archiver": "^4.0.1", - "browserify": "^16.5.1", - "chokidar": "^3.4.0", - "concurrently": "^5.2.0", - "decomment": "^0.9.0", - "electron": "19.0.5", - "electron-builder": "^22.14.13", + "archiver": "^5.3.1", + "browserify": "^17.0.0", + "chokidar": "^3.5.3", + "concurrently": "^7.2.2", + "decomment": "^0.9.5", + "electron": "^19.0.7", + "electron-builder": "^23.1.0", "electron-installer-windows": "^3.0.0", - "electron-packager": "^15.1.0", + "electron-packager": "^15.5.1", "electron-rebuild": "^3.2.7", "electron-renderify": "0.0.2", - "prebuild-install": "^7.0.1", - "prettier": "^2.2.1", + "prebuild-install": "^7.1.1", + "prettier": "^2.7.1", "snazzy": "^9.0.0", - "standard": "^14.3.4" + "standard": "^17.0.0" }, "license": "Apache-2.0", "scripts": {