Skip to content

Commit

Permalink
Added fix for "WhatsApp Works For Chrome 36+" issue i.e. Issue #7
Browse files Browse the repository at this point in the history
  • Loading branch information
amanharwara committed Dec 17, 2018
1 parent 151057c commit 6481be3
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
23 changes: 22 additions & 1 deletion src/js/whatsapp.init.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,32 @@
const { ipcRenderer } = require('electron');
const {
ipcRenderer,
remote
} = require('electron');
const Mousetrap = require('mousetrap');
window.onclick = function(e) {
if (e.target.tagName == "A") {
ipcRenderer.send('linkOpen', e.target.href);
}
}

var ses = remote.session.defaultSession;

ses.flushStorageData();
ses.clearStorageData({
storages: ['appcache', 'serviceworkers', 'cachestorage', 'websql', 'indexdb'],
});

window.navigator.serviceWorker.getRegistrations().then(registrations => {
for (let registration of registrations) {
registration.unregister();
}
});

const titleEl = document.querySelector('.window-title');
if (titleEl && titleEl.innerHTML.includes('Google Chrome 36+')) {
window.location.reload();
}

/* Mac Copy/Paste Fix */
Mousetrap.bind(['command+c', 'ctrl+c'], function(e) {
document.execCommand('copy');
Expand Down
2 changes: 1 addition & 1 deletion src/windows/mainWindow.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
</head>

<body>
<webview preload="../js/whatsapp.init.js" id="whatsapp" src="https://web.whatsapp.com/"></webview>
<webview preload="../js/whatsapp.init.js" id="whatsapp" src="https://web.whatsapp.com/" useragent="Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36"></webview>
<script src="../js/mainWindow.js"></script>
</body>

Expand Down

0 comments on commit 6481be3

Please sign in to comment.