Skip to content

Commit

Permalink
Update whatsapp.js
Browse files Browse the repository at this point in the history
1. Add zoom function on mouse wheel scroll.
2. Clicking a link will open it in an external browser.
  • Loading branch information
amanharwara committed Nov 7, 2019
1 parent 1660f96 commit d0bb331
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions src/windows/main/whatsapp.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ window.onload = () => {
window.location.reload();
}

// Message Indicator
// Using MutationObserver to check for changes in the title of the WhatsApp page and sending an IPC message to the main process
new MutationObserver(function(mutations) {
let title = mutations[0].target.innerText;
let titleRegEx = /([0-9]+)/;
Expand All @@ -35,4 +37,32 @@ window.onload = () => {
characterData: true
}
);

// Mouse wheel event listener for zoom
document.body.addEventListener('wheel', e => {
// Mouse wheel delta value. (+1 when scroll up | -1 when scroll down)
const delta = Math.sign(e.deltaY);

if (e.ctrlKey) {
switch (delta) {
case -1:
ipcRenderer.send('zoom-in');
break;

case +1:
ipcRenderer.send('zoom-out');
break;

default:
break;
}
}
});

// Open links in external browser
document.body.addEventListener('click', e => {
if (e.target.tagName === 'A') {
ipcRenderer.send('link-open', e.target.href);
}
});
}

0 comments on commit d0bb331

Please sign in to comment.