Skip to content
This repository has been archived by the owner on Dec 1, 2017. It is now read-only.

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
tristanlins committed Jun 18, 2017
0 parents commit 7b017ba
Show file tree
Hide file tree
Showing 24 changed files with 496 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/node_modules/
/dist/
7 changes: 7 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -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.
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -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
Binary file added build/icon/128x128.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added build/icon/256x256.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added build/icon/32x32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added build/icon/48x48.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added build/icon/512x512.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added build/icon/64x64.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added build/icon/96x96.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
104 changes: 104 additions & 0 deletions icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added icon@1.25.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added icon@1.33.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added icon@1.4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added icon@1.5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added icon@1.8.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added icon@2.5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added icon@2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added icon@3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
46 changes: 46 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>WhatsApp!Web</title>
<link href="https://fonts.googleapis.com/css?family=Overpass:100,400" rel="stylesheet">
<link type="text/css" rel="stylesheet" href="style.css"/>
</head>
<body>
<script>
const {ipcRenderer} = require('electron');
</script>

<header>
<h1>WhatsApp!Web</h1>
</header>

<main>
<p>
This is an inofficial WhatsApp Desktop Client build with <a href="https://electron.atom.io/" target="_blank">Electron</a>.
This software is licensed under the <a href="https://opensource.org/licenses/MIT" target="_blank">MIT license</a>.
</p>

<blockquote id="license"><script>document.write(ipcRenderer.sendSync('get-license'))</script></blockquote>

<blockquote id="attribution">The <a href="https://www.iconfinder.com/icons/1961289/social_media_icons_whatsapp_icon#size=128" target="_blank">application icon</a> was created by <a href="https://www.iconfinder.com/Aarthi" target="_blank">Aarthi Padmanabhan</a> and licensed under the <a href="https://creativecommons.org/licenses/by/3.0/" target="_blank">CC-BY 3.0 license</a>.</blockquote>

<p class="buttons">
<button>Accept and start</button>
</p>
</main>

<footer>
WhatsApp!Web Version <em><script>document.write(ipcRenderer.sendSync('determine-version'))</script></em><br/>
Node Version <em><script>document.write(process.versions.node)</script></em><br/>
Chrome Version <em><script>document.write(process.versions.chrome)</script></em><br/>
Electron Version <em><script>document.write(process.versions.electron)</script></em><br/>
</footer>

<script>
document.querySelector('button').addEventListener('click', () => {
ipcRenderer.send('accept');
});
</script>
</body>
</html>
179 changes: 179 additions & 0 deletions main.js
Original file line number Diff line number Diff line change
@@ -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();
}
})
Loading

0 comments on commit 7b017ba

Please sign in to comment.