diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9268a19 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +.DS_Store +dist +node_modules/* +electron-* \ No newline at end of file diff --git a/app/app.js b/app/app.js new file mode 100644 index 0000000..523cb94 --- /dev/null +++ b/app/app.js @@ -0,0 +1,160 @@ +var app = require('app'); // Module to control application life. +var Menu = require('menu'); +var Tray = require('tray'); +var BrowserWindow = require('browser-window'); // Module to create native browser window. +var mainWindow = null; +var appIcon = null; +var win = null; + +var template = [ + { + label: 'Whatsapp', + submenu: [ + { + label: 'About Whatsapp', + selector: 'orderFrontStandardAboutPanel:' + }, + { type: 'separator' }, + { + label: 'Hide Whatsapp', + accelerator: 'Command+H', + selector: 'hide:' + }, + { + label: 'Hide Others', + accelerator: 'Command+Shift+H', + selector: 'hideOtherApplications:' + }, + { + label: 'Show All', + selector: 'unhideAllApplications:' + }, + { type: 'separator' }, + { + label: 'Quit', + accelerator: 'Command+Q', + selector: 'terminate:' + }, + ] + }, + { + label: 'Edit', + submenu: [ + { + label: 'Undo', + accelerator: 'Command+Z', + selector: 'undo:' + }, + { + label: 'Redo', + accelerator: 'Shift+Command+Z', + selector: 'redo:' + }, + { type: 'separator' }, + { + label: 'Cut', + accelerator: 'Command+X', + selector: 'cut:' + }, + { + label: 'Copy', + accelerator: 'Command+C', + selector: 'copy:' + }, + { + label: 'Paste', + accelerator: 'Command+V', + selector: 'paste:' + }, + { + label: 'Select All', + accelerator: 'Command+A', + selector: 'selectAll:' + } + ] + }, + { + label: 'View', + submenu: [ + { + label: 'Reload', + accelerator: 'Command+R', + click: function() { remote.getCurrentWindow().reload(); } + }, + { + label: 'Toggle DevTools', + accelerator: 'Alt+Command+I', + click: function() { remote.getCurrentWindow().toggleDevTools(); } + }, + ] + }, + { + label: 'Window', + submenu: [ + { + label: 'Minimize', + accelerator: 'Command+M', + selector: 'performMiniaturize:' + }, + { + label: 'Close', + accelerator: 'Command+W', + selector: 'hide:' + }, + { type: 'separator' }, + { + label: 'Bring All to Front', + selector: 'arrangeInFront:' + } + ] + } +]; + +// Quit when all windows are closed. +app.on('window-all-closed', function() { + app.quit(); +}); + +// Initialization. +app.on('ready', function() { + // Configuration + appIcon = new Tray(__dirname+'/assets/trayTemplate.png'); + appIcon.on("clicked", function(){ + win.show(); + }); + appIcon.setToolTip('Whatsapp'); + + var menu = Menu.buildFromTemplate(template); + Menu.setApplicationMenu(menu); + + // Create the browser window. + win = new BrowserWindow({ + "width": 900, + "height": 720, + "type": "toolbar", + "title": "Whatsapp", + "node-integration": false, + }); + + // Load the app page + win.loadUrl('https://web.whatsapp.com', { + userAgent: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.52 Safari/537.36' + }); + + // Open links externally + win.webContents.on("new-window", function(event, url, frameName, disposition){ + require('shell').openExternal(url) + event.preventDefault(); + }); + + // Open the devtools. + // win.openDevTools(); + + // Emitted when the window is closed. + win.on('closed', function() { + win = null; + }); + + // app.dock.hide(); + win.show(); +}); \ No newline at end of file diff --git a/app/assets/trayTemplate.png b/app/assets/trayTemplate.png new file mode 100644 index 0000000..4529aae Binary files /dev/null and b/app/assets/trayTemplate.png differ diff --git a/app/assets/trayTemplate@2x.png b/app/assets/trayTemplate@2x.png new file mode 100644 index 0000000..c6f47ec Binary files /dev/null and b/app/assets/trayTemplate@2x.png differ diff --git a/app/package.json b/app/package.json new file mode 100644 index 0000000..d7b8a77 --- /dev/null +++ b/app/package.json @@ -0,0 +1,5 @@ +{ + "name" : "whatsapp", + "version" : "0.1.1", + "main" : "app.js" +} \ No newline at end of file diff --git a/assets/osx/whatsapp.icns b/assets/osx/whatsapp.icns new file mode 100644 index 0000000..cc0256a Binary files /dev/null and b/assets/osx/whatsapp.icns differ diff --git a/package.json b/package.json new file mode 100644 index 0000000..bb07953 --- /dev/null +++ b/package.json @@ -0,0 +1,20 @@ +{ + "name": "whatsapp-desktop", + "version": "0.1.1", + "description": "Unofficial Whatsapp Desktop Client. Build with Electron.", + "main": "app.js", + "scripts": { + "dev": "electron ./app", + "clean": "rm -rf ./dist", + "clean:osx": "rm -rf ./dist/osx", + "build": "npm run clean && npm run build:osx", + "build:osx": "npm run clean:osx && electron-packager ./app \"Whatsapp\" --out=dist/osx --platform=darwin --arch=x64 --version=0.28.3 --icon=assets/osx/whatsapp.icns", + "pack": "npm run pack:osx", + "pack:osx": "npm run build:osx && electron-builder \"dist/osx/Whatsapp.app\" --platform=osx --out=\"dist/osx\" --config=packager.json" + }, + "devDependencies": { + "electron-packager": "^4.1.3", + "electron-prebuilt": "^0.28.3", + "electron-builder": "^2.0.0" + } +} diff --git a/packager.json b/packager.json new file mode 100644 index 0000000..722c78e --- /dev/null +++ b/packager.json @@ -0,0 +1,11 @@ +{ + "osx" : { + "title": "Whatsapp", + "icon": "assets/osx/whatsapp.icns", + "icon-size": 80, + "contents": [ + { "x": 438, "y": 344, "type": "link", "path": "/Applications" }, + { "x": 192, "y": 344, "type": "file" } + ] + } +} \ No newline at end of file diff --git a/readme.md b/readme.md new file mode 100644 index 0000000..58bf114 --- /dev/null +++ b/readme.md @@ -0,0 +1,26 @@ +# Whatsapp Desktop + +Whatsapp desktop client for OSX, based on the official whatsapp web app. Build with [Electron](http://electron.atom.io/). + + +This is **NOT** an official product. This project does not attempt to reverse engineer the WhatsApp API or attempt to reimplement any part of the WhatsApp client. Any communication between the user and WhatsApp servers is handled by official WhatsApp Web itself; this is just a native wrapper for WhatsApp Web, like a browser. + +## Features + +* Native notifications. +* System tray icon. +* Open links in browser. + +**Planned features:** + +* Badge with the number of notifications in the dock/taskbar. +* Auto-launch on OS startup. + +## Contributions + +Contributions are welcome! For feature requests and bug reports please submit an [issue](https://github.com/bcalik/whatsapp-desktop/issues). + +## Build + +`npm install` +`npm run build` \ No newline at end of file