Skip to content
This repository has been archived by the owner on Jun 4, 2023. It is now read-only.

Commit

Permalink
Install uBlock Origin by default
Browse files Browse the repository at this point in the history
Former-commit-id: 58401aa [formerly 58401aa [formerly 13cd756]]
Former-commit-id: 15ccf20dbfd069c1a12d7b29d07c01183a0adfd2
Former-commit-id: e9f0000
  • Loading branch information
sentialx committed Oct 27, 2018
1 parent 55305a2 commit 66c44a3
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 5 deletions.
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
],
"devDependencies": {
"@types/chrome": "0.0.74",
"@types/extract-zip": "1.6.2",
"@types/gsap": "1.19.2",
"@types/leveldown": "4.0.0",
"@types/levelup": "3.1.0",
Expand All @@ -72,6 +73,7 @@
"electron-builder": "20.28.4",
"electron-react-devtools": "0.5.3",
"electron-updater": "3.1.2",
"extract-zip": "1.6.7",
"gsap": "2.0.2",
"levelup": "3.1.1",
"mobx": "5.5.0",
Expand Down
13 changes: 13 additions & 0 deletions src/main/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
runExtensionsService,
runWebRequestService,
} from '@/services/main';
import extract from 'extract-zip';

ipcMain.setMaxListeners(0);

Expand Down Expand Up @@ -71,6 +72,18 @@ if (shouldQuit) {
}
}

if (!existsSync(resolve(getPath('extensions'), 'uBlock0.chromium'))) {
extract(
resolve(__dirname, 'static/extensions/ublock.zip'),
{ dir: getPath('extensions') },
err => {
if (err) console.error(err);

loadExtensions(mainWindow);
},
);
}

mainWindow = createWindow();

loadExtensions(mainWindow);
Expand Down
4 changes: 4 additions & 0 deletions src/shared/utils/main/extensions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,10 @@ export const loadExtensions = async (window: BrowserWindow) => {

const id = dir;

if (global.extensions[id]) {
return;
}

global.extensions[id] = manifest;

const extensionStoragePath = getPath(
Expand Down
8 changes: 4 additions & 4 deletions src/shared/utils/main/window.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { BrowserWindow, app } from 'electron';
import { readFileSync, writeFileSync, existsSync } from 'fs';
import { join } from 'path';
import { join, resolve } from 'path';
import os from 'os';

import { getPath } from '@/utils/paths';
import { WindowState } from '@/interfaces/main';
Expand All @@ -22,7 +23,7 @@ export const createWindow = () => {
}

let windowData: Electron.BrowserWindowConstructorOptions = {
frame: process.env.ENV === 'dev',
frame: process.env.ENV === 'dev' || os.platform() === 'darwin',
minWidth: 400,
minHeight: 450,
width: 900,
Expand All @@ -32,6 +33,7 @@ export const createWindow = () => {
webPreferences: {
plugins: true,
},
icon: resolve(__dirname, 'static/app-icons/icon.png'),
};

// Merge bounds from the last window state to the current window options.
Expand Down Expand Up @@ -67,8 +69,6 @@ export const createWindow = () => {
writeFileSync(windowDataPath, JSON.stringify(windowState));
});

window.webContents.openDevTools({ mode: 'detach' });

if (process.env.ENV === 'dev') {
window.webContents.openDevTools({ mode: 'detach' });
window.loadURL('http://localhost:8080/app.html');
Expand Down
1 change: 1 addition & 0 deletions static/extensions/ublock.zip.REMOVED.git-id
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
341023d54ef7964ebd56bc4bbd54931d432d4220
6 changes: 5 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@
version "1.2.0"
resolved "https://registry.yarnpkg.com/@types/events/-/events-1.2.0.tgz#81a6731ce4df43619e5c8c945383b3e62a89ea86"

"@types/[email protected]":
version "1.6.2"
resolved "https://registry.yarnpkg.com/@types/extract-zip/-/extract-zip-1.6.2.tgz#5c7eb441c41136167a42b88b64051e6260c29e86"

"@types/filesystem@*":
version "0.0.29"
resolved "https://registry.yarnpkg.com/@types/filesystem/-/filesystem-0.0.29.tgz#ee3748eb5be140dcf980c3bd35f11aec5f7a3748"
Expand Down Expand Up @@ -1908,7 +1912,7 @@ extglob@^2.0.4:
snapdragon "^0.8.1"
to-regex "^3.0.1"

extract-zip@^1.0.3:
extract-zip@1.6.7, extract-zip@^1.0.3:
version "1.6.7"
resolved "https://registry.yarnpkg.com/extract-zip/-/extract-zip-1.6.7.tgz#a840b4b8af6403264c8db57f4f1a74333ef81fe9"
dependencies:
Expand Down

0 comments on commit 66c44a3

Please sign in to comment.