Skip to content

Commit

Permalink
Add insert sticker shortcut (#1015)
Browse files Browse the repository at this point in the history
  • Loading branch information
aude authored and sindresorhus committed Sep 9, 2019
1 parent dc11fab commit 29577c6
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ Next conversation | <kbd>Command/Control</kbd> <kbd>]</kbd> or <kbd>Control
Previous conversation | <kbd>Command/Control</kbd> <kbd>[</kbd> or <kbd>Control</kbd> <kbd>Shift</kbd> <kbd>Tab</kbd>
Jump to conversation | <kbd>Command/Control</kbd> <kbd>1</kbd>…<kbd>9</kbd>
Insert GIF | <kbd>Command/Control</kbd> <kbd>g</kbd>
Insert sticker | <kbd>Command/Control</kbd> <kbd>s</kbd>
Insert emoji | <kbd>Command/Control</kbd> <kbd>e</kbd>
Insert text | <kbd>Command/Control</kbd> <kbd>i</kbd>
Search in conversation | <kbd>Command/Control</kbd> <kbd>f</kbd>
Expand Down
12 changes: 12 additions & 0 deletions source/browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,18 @@ ipc.on('insert-emoji', async () => {
emojiElement.click();
});

ipc.on('insert-sticker', () => {
const stickerElement =
// Old UI
document.querySelector<HTMLElement>('._4rv6') ||
// New UI
[...document.querySelectorAll<HTMLElement>('._7oam')].find(element =>
element.querySelector<HTMLElement>('svg path[d^="M22.5,18.5 L27.998,18.5"]')
);

stickerElement!.click();
});

ipc.on('insert-text', () => {
document.querySelector<HTMLElement>('._5rpu')!.focus();
});
Expand Down
7 changes: 7 additions & 0 deletions source/menu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -493,6 +493,13 @@ Press Command/Ctrl+R in Caprine to see your changes.
sendAction('insert-gif');
}
},
{
label: 'Insert Sticker',
accelerator: 'CommandOrControl+S',
click() {
sendAction('insert-sticker');
}
},
{
label: 'Insert Emoji',
accelerator: 'CommandOrControl+E',
Expand Down

0 comments on commit 29577c6

Please sign in to comment.