-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsend_like_shortcut.user.js
More file actions
37 lines (35 loc) · 1.38 KB
/
send_like_shortcut.user.js
File metadata and controls
37 lines (35 loc) · 1.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// ==UserScript==
// @name Send Like Keyboard Shortcut
// @namespace http://tampermonkey.net/
// @version 0.1
// @description adds Ctrl+Shift+L as a shortcut to send a like on Facebook Messenger
// @author Raymond Chee
// @match https://www.messenger.com/t/*
// @grant none
// ==/UserScript==
(function() {
'use strict';
// Your code here...
var sendingLike = false;
// capture keyboard shortcut
document.addEventListener("keydown", function (e) {
if (e.code == "KeyL" && e.shiftKey && e.ctrlKey && !sendingLike) {
var likeButton = document.querySelector("a[title=\"Send a Like\"]");
// start holding the like button
var mouseOverEvent = new MouseEvent("mouseover", {bubbles: true});
var mouseDownEvent = new MouseEvent("mousedown", {bubbles: true});
likeButton.dispatchEvent(mouseOverEvent);
likeButton.dispatchEvent(mouseDownEvent);
sendingLike = true;
}
}, false);
document.addEventListener("keyup", function (e) {
if (sendingLike) {
var likeButton = document.querySelector("a[title=\"Send a Like\"]");
// send the like
var mouseUpEvent = new MouseEvent("mouseup", {bubbles: true});
likeButton.dispatchEvent(mouseUpEvent);
sendingLike = false;
}
}, false);
})();