+++ /dev/null
-{
- "presets": [
- [
- "env",
- {
- "targets": {
- "node": "current"
- }
- }
- ]
- ]
-}
\ No newline at end of file
const url = require('url');
const os = require('os');
-const localShortcut = require("electron-localshortcut");
-
-const Config = require('electron-store');
-const config = new Config({
- defaults: {
- design: {
- homeButton: false,
- darkTheme: false,
- theme: 'default'
- },
- homePage: {
- defaultPage: 'my://newtab',
- defaultEngine: 'Google',
- searchEngines: [
- {
- name: 'Google',
- url: 'https://www.google.com/search?q=%s'
- },
- {
- name: 'Bing',
- url: 'https://www.bing.com/search?q=%s'
- },
- {
- name: 'Yahoo! Japan',
- url: 'https://search.yahoo.co.jp/search?p=%s'
- },
- {
- name: 'goo',
- url: 'https://search.goo.ne.jp/web.jsp?MT=%s'
- },
- {
- name: 'Google Translate',
- url: 'https://translate.google.com/?text=%s'
- },
- {
- name: 'Youtube',
- url: 'https://www.youtube.com/results?search_query=%s'
- },
- {
- name: 'Twitter',
- url: 'https://www.twitter.com/search?q=%s'
- },
- {
- name: 'GitHub',
- url: 'https://github.com/search?q=%s'
- }
- ]
- },
- adBlocker: true,
- window: {
- isCustomTitlebar: true,
- isMaximized: false,
- bounds: {
- width: 1100,
- height: 680
- }
- }
- },
-});
-
-const Datastore = require('nedb');
-let db = {};
-
-db.history = new Datastore({
- filename: path.join(app.getPath('userData'), 'Files', 'History.db'),
- autoload: true,
- timestampData: true
-});
-
-const { loadFilters, updateFilters, removeAds } = require('./AdBlocker');
const WindowManager = require('./WindowManager');
const windowManager = new WindowManager();
});
}
-/*
-showFilterDialog = () => {
- if (!hasFile()) {
- const dialogResult = dialog.showMessageBox({
- type: 'info',
- buttons: ['Ok'],
- title: '本当にデータをリセットしてよろしいですか?',
- message: '"続行"を押した場合データのリセット後アプリが再起動します。',
- defaultId: 0,
- cancelId: 1
- });
-
- if (dialogResult === 0) {
- showFilterDialog();
- }
- }
-}
-*/
-
registerProtocols = () => {
protocol.registerFileProtocol('my', (request, callback) => {
const parsed = url.parse(request.url);
]);
app.on('ready', () => {
- loadFilters();
registerProtocols();
Menu.setApplicationMenu(null);
pathname: path.join(__dirname, '/../build/index.html'), // 警告:このファイルを移動する場合ここの相対パスの指定に注意してください
protocol: 'file:',
slashes: true,
- hash: '/auth',
+ hash: '/authentication',
});
subWindow.loadURL(startUrl);
loginCallback(arg.username, arg.password);
subWindow.close();
});
-
- ipcMain.on('data-history-get', (e, args) => {
- db.history.find({}).sort({ createdAt: -1 }).exec((err, docs) => {
- e.sender.send('data-history-get', { historys: docs });
- });
- });
-
- ipcMain.on('data-history-clear', (e, args) => {
- db.history.remove({}, { multi: true });
- });
-
- ipcMain.on('clear-browsing-data', () => {
- const ses = session.defaultSession;
- ses.clearCache((err) => {
- if (err) log.error(err);
- });
-
- ses.clearStorageData({
- storages: [
- 'appcache',
- 'cookies',
- 'filesystem',
- 'indexdb',
- 'localstorage',
- 'shadercache',
- 'websql',
- 'serviceworkers',
- 'cachestorage',
- ],
- });
-
- config.clear();
- db.history.remove({}, { multi: true });
- });
}
loadExtension = (id) => {
const Config = require('electron-store');
const config = new Config({
- defaults: {
- design: {
- homeButton: false,
- darkTheme: false,
- theme: 'default'
- },
- homePage: {
- defaultPage: 'my://newtab',
- defaultEngine: 'Google',
- searchEngines: [
- {
- name: 'Google',
- url: 'https://www.google.com/search?q=%s'
- },
- {
- name: 'Bing',
- url: 'https://www.bing.com/search?q=%s'
- },
- {
- name: 'Yahoo! Japan',
- url: 'https://search.yahoo.co.jp/search?p=%s'
- },
- {
- name: 'goo',
- url: 'https://search.goo.ne.jp/web.jsp?MT=%s'
- },
- {
- name: 'Google Translate',
- url: 'https://translate.google.com/?text=%s'
- },
- {
- name: 'Youtube',
- url: 'https://www.youtube.com/results?search_query=%s'
- },
- {
- name: 'Twitter',
- url: 'https://www.twitter.com/search?q=%s'
- },
- {
- name: 'GitHub',
- url: 'https://github.com/search?q=%s'
- }
- ]
- },
- adBlocker: true,
- window: {
- isCustomTitlebar: true,
- isMaximized: false,
- bounds: {
- width: 1100,
- height: 680
- }
- }
- },
+ defaults: {
+ design: {
+ homeButton: false,
+ darkTheme: false,
+ theme: 'default'
+ },
+ homePage: {
+ defaultPage: 'my://newtab',
+ defaultEngine: 'Google',
+ searchEngines: [
+ {
+ name: 'Google',
+ url: 'https://www.google.com/search?q=%s'
+ },
+ {
+ name: 'Bing',
+ url: 'https://www.bing.com/search?q=%s'
+ },
+ {
+ name: 'Yahoo! Japan',
+ url: 'https://search.yahoo.co.jp/search?p=%s'
+ },
+ {
+ name: 'goo',
+ url: 'https://search.goo.ne.jp/web.jsp?MT=%s'
+ },
+ {
+ name: 'Google Translate',
+ url: 'https://translate.google.com/?text=%s'
+ },
+ {
+ name: 'Youtube',
+ url: 'https://www.youtube.com/results?search_query=%s'
+ },
+ {
+ name: 'Twitter',
+ url: 'https://www.twitter.com/search?q=%s'
+ },
+ {
+ name: 'GitHub',
+ url: 'https://github.com/search?q=%s'
+ }
+ ]
+ },
+ adBlocker: true,
+ window: {
+ isCustomTitlebar: true,
+ isMaximized: false,
+ bounds: {
+ width: 1100,
+ height: 680
+ }
+ }
+ },
});
// ファイルタイプの列挙体(のつもり)
};
onload = function () {
+ // console.log(document.documentElement.innerText);
if (location.protocol == 'my:') return;
delete global.getConfigPath;
delete global.setCustomTitlebar;
delete global.restart;
delete global.isURL;
+}
+
+onmousedown = (e) => {
+ if (remote.getCurrentWindow().getBrowserView() == undefined) return;
+ const view = remote.getCurrentWindow().getBrowserView();
+
+ if (e.button == 3) {
+ if (view.webContents.canGoBack())
+ view.webContents.goBack();
+ } else if (e.button == 4) {
+ if (view.webContents.canGoForward())
+ view.webContents.goForward();
+ }
}
\ No newline at end of file
const { loadFilters, updateFilters, removeAds } = require('./AdBlocker');
+let floatingWindows = [];
let views = [];
let tabCount = 0;
-getBaseWindow = (width = 1100, height = 680, minWidth = 320, minHeight = 600, x, y, frame = false) => {
+getBaseWindow = (width = 1100, height = 680, minWidth = 320, minHeight = 200, x, y, frame = false) => {
return new BrowserWindow({
width, height, minWidth, minHeight, x, y, 'titleBarStyle': 'hidden', frame, fullscreenable: true,
webPreferences: {
ipcMain.on('window-add', (e, args) => {
this.addWindow(args.isPrivate);
});
+
+ ipcMain.on('data-history-get', (e, args) => {
+ db.history.find({}).sort({ createdAt: -1 }).exec((err, docs) => {
+ e.sender.send('data-history-get', { historys: docs });
+ });
+ });
+
+ ipcMain.on('data-history-clear', (e, args) => {
+ db.history.remove({}, { multi: true });
+ });
+
+ ipcMain.on('clear-browsing-data', () => {
+ const ses = session.defaultSession;
+ ses.clearCache((err) => {
+ if (err) log.error(err);
+ });
+
+ ses.clearStorageData({
+ storages: [
+ 'appcache',
+ 'cookies',
+ 'filesystem',
+ 'indexdb',
+ 'localstorage',
+ 'shadercache',
+ 'websql',
+ 'serviceworkers',
+ 'cachestorage',
+ ],
+ });
+
+ config.clear();
+ db.history.remove({}, { multi: true });
+ });
}
addWindow = (isPrivate = false) => {
loadFilters();
const { width, height, x, y } = config.get('window.bounds');
- const window = getBaseWindow(config.get('window.isMaximized') ? 1110 : width, config.get('window.isMaximized') ? 680 : height, 320, 600, x, y, !config.get('window.isCustomTitlebar'));
+ const window = getBaseWindow(config.get('window.isMaximized') ? 1110 : width, config.get('window.isMaximized') ? 680 : height, 320, 200, x, y, !config.get('window.isCustomTitlebar'));
const id = (!isPrivate ? window.id : `private-${window.id}`);
pathname: path.join(__dirname, '/../build/index.html'), // 警告:このファイルを移動する場合ここの相対パスの指定に注意してください
protocol: 'file:',
slashes: true,
- hash: `/${id}`,
+ hash: `/window/${id}`,
});
window.loadURL(startUrl);
localShortcut.register(window, 'CmdOrCtrl+Shift+I', () => {
if (window.getBrowserView() == undefined) return;
-
const view = window.getBrowserView();
+
if (view.webContents.isDevToolsOpened()) {
view.webContents.devToolsWebContents.focus();
} else {
localShortcut.register(window, 'CmdOrCtrl+R', () => {
if (window.getBrowserView() == undefined) return;
-
const view = window.getBrowserView();
+
view.webContents.reload();
});
localShortcut.register(window, 'CmdOrCtrl+Shift+R', () => {
if (window.getBrowserView() == undefined) return;
-
const view = window.getBrowserView();
+
view.webContents.reloadIgnoringCache();
});
}
});
- window.on('maximize', this.fixBounds.bind(this, id));
- window.on('unmaximize', this.fixBounds.bind(this, id));
- window.on('enter-full-screen', this.fixBounds.bind(this, id));
- window.on('leave-full-screen', this.fixBounds.bind(this, id));
- window.on('enter-html-full-screen', this.fixBounds.bind(this, id));
- window.on('leave-html-full-screen', this.fixBounds.bind(this, id));
+ window.on('maximize', this.fixBounds.bind(this, id, (floatingWindows.indexOf(id) != -1)));
+ window.on('unmaximize', this.fixBounds.bind(this, id, (floatingWindows.indexOf(id) != -1)));
+ window.on('enter-full-screen', this.fixBounds.bind(this, id, (floatingWindows.indexOf(id) != -1)));
+ window.on('leave-full-screen', this.fixBounds.bind(this, id, (floatingWindows.indexOf(id) != -1)));
+ window.on('enter-html-full-screen', this.fixBounds.bind(this, id, (floatingWindows.indexOf(id) != -1)));
+ window.on('leave-html-full-screen', this.fixBounds.bind(this, id, (floatingWindows.indexOf(id) != -1)));
// registerProtocols();
this.registerListeners(id);
});
}
- fixBounds = (windowId) => {
+ fixBounds = (windowId, isFloating = false) => {
const window = this.windows.get(windowId);
- if (window.getBrowserView() == undefined) return;
+ if (window.getBrowserView() == undefined) return;
const view = window.getBrowserView();
+
const { width, height } = window.getContentBounds();
view.setAutoResize({ width: true, height: true });
- if (window.isFullScreen()) {
- view.setBounds({
- x: 0,
- y: 0,
- width: width,
- height: height,
- });
- } else {
+ if (isFloating) {
+ window.setMinimizable(false);
+ window.setMaximizable(false);
+ window.setAlwaysOnTop(true);
+ window.setVisibleOnAllWorkspaces(true);
view.setBounds({
x: 1,
- y: 73 + 1,
+ y: 1,
width: width - 2,
- height: window.isMaximized() ? height - 73 : (height - 73) - 2,
+ height: height - 2,
});
+ } else {
+ window.setMinimizable(true);
+ window.setMaximizable(true);
+ window.setAlwaysOnTop(false);
+ window.setVisibleOnAllWorkspaces(false);
+ if (window.isFullScreen()) {
+ view.setBounds({
+ x: 0,
+ y: 0,
+ width: width,
+ height: height,
+ });
+ } else {
+ view.setBounds({
+ x: 1,
+ y: 73 + 1,
+ width: width - 2,
+ height: window.isMaximized() ? height - 73 : (height - 73) - 2,
+ });
+ }
}
view.setAutoResize({ width: true, height: true });
}
window.setBrowserView(views[i].view);
window.setTitle(views[i].view.webContents.getTitle());
window.webContents.send(`browserview-set-${windowId}`, { id: id });
- this.fixBounds(windowId);
+ this.fixBounds(windowId, (floatingWindows.indexOf(windowId) != -1));
}
});
}
},
{ type: 'separator' },
{
+ label: 'Floating Window (Beta)',
+ type: 'checkbox',
+ checked: (floatingWindows.indexOf(windowId) != -1),
+ enabled: (!window.isFullScreen() && !window.isMaximized()),
+ click: () => {
+ if (floatingWindows.indexOf(windowId) != -1) {
+ floatingWindows.filter((win, i) => {
+ if (windowId == win) {
+ floatingWindows.splice(i, 1);
+ }
+ });
+ } else {
+ floatingWindows.push(windowId);
+ }
+ this.fixBounds(windowId, (floatingWindows.indexOf(windowId) != -1));
+ }
+ },
+ { type: 'separator' },
+ {
label: 'ページの保存',
accelerator: 'CmdOrCtrl+S',
enabled: !view.webContents.getURL().startsWith('my://'),
window.webContents.send(`browserview-set-${windowId}`, { id: id });
window.setBrowserView(view);
}
- this.fixBounds(windowId);
+ this.fixBounds(windowId, (floatingWindows.indexOf(windowId) != -1));
this.getViews(windowId);
}
}
\ No newline at end of file
{
"name": "MyBrowser-Stable",
- "version": "1.2.4",
+ "version": "1.3.1",
"private": true,
"main": "electron/Starter.js",
"homepage": "./",
return (
<HashRouter>
<div>
- <Route exact path='/:windowId' component={Browser} />
- <Route path='/auth' component={Authentication} />
+ <Route exact path='/window/:windowId' component={Browser} />
+ <Route path='/authentication' component={Authentication} />
</div>
</HashRouter>
);
import WindowButton from './Components/WindowButton';
import WindowContent from './Components/WindowContent';
import TitleBar from './Components/TitleBar';
-import Tabs from './Components/Tabs';
-import { Tab, TabTitle, TabCloseButton } from './Components/Tab';
-import TabButton from './Components/TabButton';
-import TabContent from './Components/TabContent';
-import ToolBar from './Components/ToolBar';
-import ToolBarButton from './Components/ToolBarButton';
-import ToolBarTextBox from './Components/ToolBarTextBox';
-import ContentWrapper from './Components/ContentWrapper';
-
-import WindowMinimizeIcon from './Resources/windows/minimize.svg';
-import WindowMaximizeIcon from './Resources/windows/maximize.svg';
-import WindowCloseIcon from './Resources/windows/close.svg';
-
-import BackIcon from './Resources/arrow_back.svg';
-import ForwardIcon from './Resources/arrow_forward.svg';
-import ReloadIcon from './Resources/reload.svg';
-import HomeIcon from './Resources/home.svg';
-import MoreIcon from './Resources/more.svg';
-import AddIcon from './Resources/add.svg';
-import CloseIcon from './Resources/close.svg';
const { remote, ipcRenderer, shell } = window.require('electron');
const systemPreferences = remote.systemPreferences;
const platform = require('electron-platform');
+const Config = window.require('electron-store');
+const config = new Config({
+ defaults: {
+ design: {
+ homeButton: false,
+ darkTheme: false,
+ theme: 'default'
+ },
+ homePage: {
+ defaultPage: 'my://newtab',
+ defaultEngine: 'Google',
+ searchEngines: [
+ {
+ name: 'Google',
+ url: 'https://www.google.com/search?q=%s'
+ },
+ {
+ name: 'Bing',
+ url: 'https://www.bing.com/search?q=%s'
+ },
+ {
+ name: 'Yahoo! Japan',
+ url: 'https://search.yahoo.co.jp/search?p=%s'
+ },
+ {
+ name: 'goo',
+ url: 'https://search.goo.ne.jp/web.jsp?MT=%s'
+ },
+ {
+ name: 'Google Translate',
+ url: 'https://translate.google.com/?text=%s'
+ },
+ {
+ name: 'Youtube',
+ url: 'https://www.youtube.com/results?search_query=%s'
+ },
+ {
+ name: 'Twitter',
+ url: 'https://www.twitter.com/search?q=%s'
+ },
+ {
+ name: 'GitHub',
+ url: 'https://github.com/search?q=%s'
+ }
+ ]
+ },
+ adBlocker: true,
+ window: {
+ isCustomTitlebar: true,
+ isMaximized: false,
+ bounds: {
+ width: 1100,
+ height: 680
+ }
+ }
+ },
+});
+
class Authentication extends Component {
constructor(props) {
super(props);
submit = () => {
const username = this.state.userName;
const password = this.state.passWord;
- ipcRenderer.send("authorization", { username, password });
+ ipcRenderer.send('authorization', { username, password });
+ }
+
+ getForegroundColor = (hexColor) => {
+ var r = parseInt(hexColor.substr(1, 2), 16);
+ var g = parseInt(hexColor.substr(3, 2), 16);
+ var b = parseInt(hexColor.substr(5, 2), 16);
+
+ return ((((r * 299) + (g * 587) + (b * 114)) / 1000) < 128) ? '#ffffff' : '#000000';
}
render() {
return (
- <Window color={platform.isWin32 || platform.isDarwin ? `#${systemPreferences.getAccentColor()}` : `#353535`}>
- <TitleBar color={platform.isWin32 || platform.isDarwin ? `#${systemPreferences.getAccentColor()}` : `#353535`}>
- <WindowButtons>
- <WindowButton isClose={true} onClick={() => { remote.getCurrentWindow().close(); }}>
+ <Window isCustomTitlebar={config.get('window.isCustomTitlebar')}>
+ <TitleBar color={platform.isWin32 || platform.isDarwin ? `#${systemPreferences.getAccentColor()}` : '#353535'}>
+ <WindowButtons isCustomTitlebar={config.get('window.isCustomTitlebar')}>
+ <WindowButton isClose={true} title="閉じる" onClick={() => { remote.getCurrentWindow().close(); }}>
<svg name="TitleBarClose" width="12" height="12" viewBox="0 0 12 12">
- <polygon fill="#ffffff" fill-rule="evenodd" points="11 1.576 6.583 6 11 10.424 10.424 11 6 6.583 1.576 11 1 10.424 5.417 6 1 1.576 1.576 1 6 5.417 10.424 1"></polygon>
+ <polygon fill={this.getForegroundColor(platform.isWin32 || platform.isDarwin ? `#${systemPreferences.getAccentColor()}` : '#353535')} fill-rule="evenodd" points="11 1.576 6.583 6 11 10.424 10.424 11 6 6.583 1.576 11 1 10.424 5.417 6 1 1.576 1.576 1 6 5.417 10.424 1" />
</svg>
</WindowButton>
</WindowButtons>
}
addTab = (url = config.get('homePage.defaultPage')) => {
- console.log(this.props)
ipcRenderer.send(`browserview-add-${this.props.match.params.windowId}`, { url, isActive: true });
ipcRenderer.send(`browserview-get-${this.props.match.params.windowId}`, {});
this.setState({ current: this.state.tabs.length });