diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b0a5c34 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +/node_modules/ +/dist/ diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..433a3bf --- /dev/null +++ b/LICENSE @@ -0,0 +1,7 @@ +Copyright 2017 Tristan Lins + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..91e102a --- /dev/null +++ b/README.md @@ -0,0 +1,19 @@ +WhatsApp!Web Desktop Client +=========================== + +An inofficial WhatsApp Desktop Client. + +Installation +------------ + +```bash +$ wget https://github.com/bit3/whatsappweb/releases/download/1.0.0-alpha/whatsappweb_1.0.0-alpha_amd64.snap +$ sudo snap install --devmode whatsappweb_1.0.0-alpha_amd64.snap +$ [/snap/bin/]whatsappweb +``` + +Attribution +----------- + +Icon by Aarthi Padmanabhan, licensed under CC-BY 3.0 +https://www.iconfinder.com/icons/1961289/social_media_icons_whatsapp_icon#size=128 diff --git a/build/icon/128x128.png b/build/icon/128x128.png new file mode 100644 index 0000000..9a58122 Binary files /dev/null and b/build/icon/128x128.png differ diff --git a/build/icon/256x256.png b/build/icon/256x256.png new file mode 100644 index 0000000..8e63b2d Binary files /dev/null and b/build/icon/256x256.png differ diff --git a/build/icon/32x32.png b/build/icon/32x32.png new file mode 100644 index 0000000..93401e3 Binary files /dev/null and b/build/icon/32x32.png differ diff --git a/build/icon/48x48.png b/build/icon/48x48.png new file mode 100644 index 0000000..c9a7dc8 Binary files /dev/null and b/build/icon/48x48.png differ diff --git a/build/icon/512x512.png b/build/icon/512x512.png new file mode 100644 index 0000000..3fb22bc Binary files /dev/null and b/build/icon/512x512.png differ diff --git a/build/icon/64x64.png b/build/icon/64x64.png new file mode 100644 index 0000000..ceb3d1c Binary files /dev/null and b/build/icon/64x64.png differ diff --git a/build/icon/96x96.png b/build/icon/96x96.png new file mode 100644 index 0000000..1f1094c Binary files /dev/null and b/build/icon/96x96.png differ diff --git a/icon.png b/icon.png new file mode 100644 index 0000000..8e63b2d Binary files /dev/null and b/icon.png differ diff --git a/icon.svg b/icon.svg new file mode 100644 index 0000000..6339835 --- /dev/null +++ b/icon.svg @@ -0,0 +1,104 @@ + +image/svg+xml \ No newline at end of file diff --git a/icon@1.25.png b/icon@1.25.png new file mode 100644 index 0000000..e5b7ac1 Binary files /dev/null and b/icon@1.25.png differ diff --git a/icon@1.33.png b/icon@1.33.png new file mode 100644 index 0000000..6b609b1 Binary files /dev/null and b/icon@1.33.png differ diff --git a/icon@1.4.png b/icon@1.4.png new file mode 100644 index 0000000..34fe8ef Binary files /dev/null and b/icon@1.4.png differ diff --git a/icon@1.5.png b/icon@1.5.png new file mode 100644 index 0000000..806dbde Binary files /dev/null and b/icon@1.5.png differ diff --git a/icon@1.8.png b/icon@1.8.png new file mode 100644 index 0000000..4b83e18 Binary files /dev/null and b/icon@1.8.png differ diff --git a/icon@2.5.png b/icon@2.5.png new file mode 100644 index 0000000..06d5a35 Binary files /dev/null and b/icon@2.5.png differ diff --git a/icon@2.png b/icon@2.png new file mode 100644 index 0000000..3fb22bc Binary files /dev/null and b/icon@2.png differ diff --git a/icon@3.png b/icon@3.png new file mode 100644 index 0000000..eb9f263 Binary files /dev/null and b/icon@3.png differ diff --git a/index.html b/index.html new file mode 100644 index 0000000..15e28ab --- /dev/null +++ b/index.html @@ -0,0 +1,46 @@ + + + + + WhatsApp!Web + + + + + + +
+

WhatsApp!Web

+
+ +
+

+ This is an inofficial WhatsApp Desktop Client build with Electron. + This software is licensed under the MIT license. +

+ +
+ +
The application icon was created by Aarthi Padmanabhan and licensed under the CC-BY 3.0 license.
+ +

+ +

+
+ + + + + + diff --git a/main.js b/main.js new file mode 100644 index 0000000..6437238 --- /dev/null +++ b/main.js @@ -0,0 +1,179 @@ +const {app, BrowserWindow, Menu, MenuItem, Tray, ipcMain, shell} = require('electron'); +const fs = require("fs"); +const settings = require('electron-settings'); +const path = require('path'); +const url = require('url'); + +const SETTINGS_ACCEPTED_VERSIONS = 'acceptedVersions'; + +let icon = path.join(__dirname, 'icon.png'); +let disclaimerWindow, whatsappWindow, tray; + +let menu = Menu.buildFromTemplate([ + { + label: 'File', + submenu: [ + { label: 'Quit', click: quit } + ] + }, + { + role: 'window', + submenu: [ + {role: 'minimize'}, + {role: 'close'} + ] + }, +]); + +ipcMain.on('get-license', (event) => { + var data = fs.readFileSync(path.join(__dirname, 'LICENSE')); + event.returnValue = data.toString(); +}); + +ipcMain.on('determine-version', (event) => { + event.returnValue = app.getVersion(); +}); + +function createWindow() { + if (whatsappWindow) { + return whatsappWindow; + } + + if (disclaimerWindow) { + return disclaimerWindow; + } + + let acceptedVersions = settings.get(SETTINGS_ACCEPTED_VERSIONS); + + if (!(acceptedVersions instanceof Array)) { + acceptedVersions = []; + } + + let version = app.getVersion(); + + if (-1 !== acceptedVersions.indexOf(version)) { + createWhatsAppWindow(); + return whatsappWindow; + } + + createDisclaimerWindow(); + return disclaimerWindow; +} + +function createDisclaimerWindow() { + disclaimerWindow = new BrowserWindow({ + width: 800, + height: 680, + resizable: false, + autoHideMenuBar: true, + icon: icon + }); + disclaimerWindow.setMenu(menu); + disclaimerWindow.loadURL(url.format({ + pathname: path.join(__dirname, 'index.html'), + protocol: 'file:', + slashes: true + })); + + // Open the DevTools. + //disclaimerWindow.webContents.openDevTools() + + disclaimerWindow.webContents.on('new-window', (event, url) => { + event.preventDefault(); + shell.openExternal(url); + }); + + ipcMain.on('accept', () => { + let acceptedVersions = settings.get(SETTINGS_ACCEPTED_VERSIONS); + + if (!(acceptedVersions instanceof Array)) { + acceptedVersions = []; + } + + acceptedVersions.push(app.getVersion()); + settings.set(SETTINGS_ACCEPTED_VERSIONS, acceptedVersions); + + createWhatsAppWindow(); + disclaimerWindow.close(); + }); + + disclaimerWindow.on('closed', () => { + disclaimerWindow = null; + }); +} + +function createWhatsAppWindow() { + whatsappWindow = new BrowserWindow({ + width: 930, + height: 630, + autoHideMenuBar: true, + icon: icon + }); + whatsappWindow.setMenu(menu); + whatsappWindow.loadURL('https://web.whatsapp.com/'); + + // Open the DevTools. + //whatsappWindow.webContents.openDevTools() + + whatsappWindow.webContents.on('new-window', (event, url) => { + event.preventDefault(); + shell.openExternal(url); + }); + + whatsappWindow.on('minimize',function(event){ + event.preventDefault() + mainWindow.hide(); + }); + + whatsappWindow.on('close', function (event) { + if (!app.isQuiting) { + event.preventDefault() + whatsappWindow.hide(); + } + return false; + }); + + whatsappWindow.on('closed', () => { + whatsappWindow = null; + }); +} + +function createTray() { + + let contextMenu = new Menu(); + contextMenu.append(new MenuItem({ label: 'Show window', click: show })); + contextMenu.append(new MenuItem({ type: 'separator' })); + contextMenu.append(new MenuItem({ label: 'Quit', click: quit })); + + tray = new Tray(icon); + tray.setTitle("WhatsApp"); + tray.setToolTip("WhatsApp"); + + tray.setContextMenu(contextMenu); + + tray.on('click', show); +} + +function show() { + let window = createWindow(); + window.show(); + window.focus(); +} + +function quit() { + app.isQuiting = true; + app.quit(); +} + +app.on('ready', () => { + createTray(); + createWindow(); +}); + +app.on('activate', () => { + // On macOS 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 (whatsappWindow === null) { + createWindow(); + } +}) diff --git a/package.json b/package.json new file mode 100644 index 0000000..e93fa63 --- /dev/null +++ b/package.json @@ -0,0 +1,39 @@ +{ + "name": "WhatsAppWeb", + "description": "Inofficial WhatsApp Desktop Client", + "homepage": "https://github.com/bit3/whatsappweb", + "license": "MIT", + "author": { + "name" : "Tristan Lins", + "email" : "tristan@lins.io", + "url" : "http://tristan.lins.io/" + }, + "repository": { + "type": "git", + "url": "https://github.com/bit3/whatsappweb.git" + }, + "version": "1.0.0-alpha", + "main": "main.js", + "dependencies": { + "electron-settings": "^3.1.1" + }, + "scripts": { + "run": "electron .", + "pack": "build --dir", + "dist": "build" + }, + "build": { + "appId": "io.bit3.whatsappweb", + "productName": "WhatsApp!Web", + "linux": { + "target": "snap", + "icon": "icon" + }, + "snap": { + "grade": "devel" + } + }, + "devDependencies": { + "electron-builder": "^19.4.2" + } +} diff --git a/style.css b/style.css new file mode 100644 index 0000000..254c340 --- /dev/null +++ b/style.css @@ -0,0 +1,100 @@ +body { + display: flex; + flex-flow: column; + align-items: stretch; + + min-height: 100vh; + margin: 0; + padding: 0; + + font-family: 'Overpass', sans-serif; + font-size: 14px; + font-weight: 400; + line-height: 1.5; +} + +header { + margin: 0; + padding: 12px; + background: #1a805d; + + color: #fff; +} + +h1 { + margin: 0; + padding: 0; + + font-size: 24px; + font-weight: 100; +} + +main { + flex-grow: 1; + padding: 12px 0; +} + +p { + margin: 0; + padding: 0 12px; +} + +blockquote { + position: relative; + margin: 12px 0 0; + padding: 12px 24px; + border-top-width: 1px; + border-top-style: solid; + border-top-color: #1a805d; + + white-space: pre-line; +} + +blockquote:before { + position: absolute; + right: 0; + top: 0; + padding: 6px; + + border-radius: 0 0 0 6px; + background: #1a805d; + color: #fff; + line-height: 1; +} + +#license:before { + content: "License"; +} + +#attribution:before { + content: "Attribution"; +} + +.buttons { + padding: 24px 0 12px; + + border-top-width: 1px; + border-top-style: solid; + border-top-color: #1a805d; + + text-align: center; +} + +button { + -webkit-appearance: none; + padding: 12px 24px; + border: none; + border-radius: 6px; + background: #1a805d; + color: #fff; + cursor: pointer; +} + +footer { + padding: 12px 0; + background: #1a805d; + color: #fff; + text-align: center; + font-size: 10px; +} +