diff --git a/index.html b/index.html
index 5a1a84e..aabe09f 100644
--- a/index.html
+++ b/index.html
@@ -1,14 +1,15 @@
-
+
jQuery injection into webview preload
-
+
diff --git a/main.js b/main.js
index eb7847a..4b98ce2 100644
--- a/main.js
+++ b/main.js
@@ -1,102 +1,41 @@
const electron = require('electron')
-
+const menubar = require('menubar')
+const {Menu} = require('electron')
require('electron-reload')(__dirname);
-var ipc = electron.ipcMain;
+require('electron-debug')({showDevTools: false});
-// Module to control application life.
-const app = electron.app
-const globalShortcut = electron.globalShortcut
-// Module to create native browser window.
-// Module to create native browser window.
-const BrowserWindow = electron.BrowserWindow
-const menubar = require('menubar')
+const MenuTemplate = require('./src/clipboard.js').template
+const Keymap = require('./src/keymap.js')
+const ipc = electron.ipcMain;
-const mb = menubar(
- {
+const menuBarConfiguration = {
width: 400,
height: 600,
icon: __dirname + '/assets/keep.png',
preloadWindow: true
- }
-)
-// console.log(menubar)
-// mb.window.loadURL(`https://keep.google.com/`)
-mb.on('ready', function ready () {
- // console.log(mb)
+}
+
+const mb = menubar(menuBarConfiguration)
- // your app code here
-})
mb.on('after-create-window', function ready () {
mb.window.focus();
- // your app code here
})
-
-
mb.app.on('ready', () => {
- // Register a 'CommandOrControl+X' shortcut listener.
- const ret = globalShortcut.register('CommandOrControl+Alt+K', () => {
- mb.showWindow()
- })
-
- if (!ret) {
- console.log('registration failed')
- }
+
+ Menu.setApplicationMenu(Menu.buildFromTemplate(MenuTemplate(mb.app)));
+ Keymap.initializeKeymap(electron.globalShortcut,
+ [{shorcut: 'CommandOrControl+Alt+K', function: mb.showWindow}]
+ )
- // Check whether a shortcut is registered.
- console.log(globalShortcut.isRegistered('CommandOrControl+X'))
})
-// Keep a global reference of the window object, if you don't, the window will
-// be closed automatically when the JavaScript object is garbage collected.
-let mainWindow
-
-function createWindow () {
- // Create the browser window.
- mainWindow = new BrowserWindow({width: 200, height: 600, frame: false, icon: __dirname + '/assets/icon.ico'})
-
- // and load the index.html of the app.
- mainWindow.loadURL(`https://keep.google.com/`)
-
- // Open the DevTools.
- // mainWindow.webContents.openDevTools()
-
- // Emitted when the window is closed.
- mainWindow.on('closed', function () {
- // Dereference the window object, usually you would store windows
- // in an array if your app supports multi windows, this is the time
- // when you should delete the corresponding element.
- mainWindow = null
-
- })
-}
-
-// This method will be called when Electron has finished
-// initialization and is ready to create browser windows.
-// Some APIs can only be used after this event occurs.
-// app.on('ready', createWindow)
-
-// Quit when all windows are closed.
-app.on('window-all-closed', function () {
- // On OS X it is common for applications and their menu bar
- // to stay active until the user quits explicitly with Cmd + Q
+mb.app.on('window-all-closed', function () {
if (process.platform !== 'darwin') {
- app.quit()
+ mb.app.quit()
}
})
mb.app.on('will-quit', () => {
- // Unregister all shortcuts.
- globalShortcut.unregisterAll()
-})
-
-app.on('activate', function () {
- // On OS X it's common to re-create a window in the app when the
- // dock icon is clicked and there are no other windows open.
- if (mainWindow === null) {
- createWindow()
- }
-})
-
-// In this file you can include the rest of your app's specific main process
-// code. You can also put them in separate files and require them here.
+ electron.globalShortcut.unregisterAll()
+})
\ No newline at end of file
diff --git a/package.json b/package.json
index 028cccf..2d805f6 100644
--- a/package.json
+++ b/package.json
@@ -26,6 +26,7 @@
"electron": "^1.3.4"
},
"dependencies": {
+ "electron-debug": "1.0.1",
"electron-reload": "1.0.2",
"menubar": "5.1.0"
}
diff --git a/src/clipboard.js b/src/clipboard.js
new file mode 100644
index 0000000..f6ca94a
--- /dev/null
+++ b/src/clipboard.js
@@ -0,0 +1,19 @@
+exports.template = (app) => {
+ return [{
+ label: "Application",
+ submenu: [
+ { label: "About Application", selector: "orderFrontStandardAboutPanel:" },
+ { type: "separator" },
+ { label: "Quit", accelerator: "Command+Q", click: function() { app.quit(); }}
+ ]}, {
+ label: "Edit",
+ submenu: [
+ { label: "Undo", accelerator: "CmdOrCtrl+Z", selector: "undo:" },
+ { label: "Redo", accelerator: "Shift+CmdOrCtrl+Z", selector: "redo:" },
+ { type: "separator" },
+ { label: "Cut", accelerator: "CmdOrCtrl+X", selector: "cut:" },
+ { label: "Copy", accelerator: "CmdOrCtrl+C", selector: "copy:" },
+ { label: "Paste", accelerator: "CmdOrCtrl+V", selector: "paste:" },
+ { label: "Select All", accelerator: "CmdOrCtrl+A", selector: "selectAll:" }
+ ]}
+]};
\ No newline at end of file
diff --git a/manipulateGoogle.js b/src/injectKeep.js
similarity index 100%
rename from manipulateGoogle.js
rename to src/injectKeep.js
diff --git a/src/keymap.js b/src/keymap.js
new file mode 100644
index 0000000..174d797
--- /dev/null
+++ b/src/keymap.js
@@ -0,0 +1,18 @@
+exports.initializeKeymap = (globalShortcut, keymap) => {
+
+ keymap.forEach((x) => {
+ if (!x.shorcut || !x.function) {
+ console.log(`Keeptron: Shortcut ${x.shorcut} not registered for function ${x.function}`)
+ return;
+ }
+
+ var ret = globalShortcut.register(x.shorcut, x.function)
+
+ if (ret && globalShortcut.isRegistered('CommandOrControl+Alt+K')) {
+ console.log(`Keeptron: Shortcut ${x.shorcut} registered properly`)
+ } else {
+ console.log(`Keeptron: Shortcut ${x.shorcut} not registered`)
+ }
+
+ })
+}
\ No newline at end of file