-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbrowser.js
64 lines (51 loc) · 1.67 KB
/
browser.js
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
window.__devtron = {require, process};
const Mousetrap = require('mousetrap');
const elementReady = require('element-ready');
const $ = document.querySelector.bind(document);
const homePageUrls = [
'https://m.facebook.com/',
'https://m.facebook.com/home.php'
];
function registerShortcuts() {
Mousetrap.bind('n', () => {
if (!homePageUrls.includes(document.URL)) {
$('a[href^="/home"]').click();
}
elementReady('textarea[name="xc_message"').then(element => element.focus());
return false;
});
Mousetrap.bind('m', () => {
$('a[href^="/messages"]').click();
elementReady('a[data-store*="messages"]').then(element => element.click());
elementReady('#m-messages-touch-composer-form a._5jby').then(element => element.click());
elementReady('input[data-sigil="xm-tokenizer-input"]').then(element => element.focus());
return false;
});
Mousetrap.bind('g h', () => {
$('a[href^="/home"]').click();
});
Mousetrap.bind('g f', () => {
$('a[href^="/friends"]').click();
});
Mousetrap.bind('g m', () => {
$('a[href^="/messages"]').click();
});
Mousetrap.bind('g n', () => {
$('a[href^="/notifications"]').click();
});
Mousetrap.bind('g s', () => {
$('a[href^="/search/"]').click();
});
Mousetrap.bind('g p', () => {
$('#bookmarks_jewel a').click();
});
Mousetrap.bind(['backspace', 'left'], () => {
window.history.back();
});
Mousetrap.bind('right', () => {
window.history.forward();
});
}
document.addEventListener('DOMContentLoaded', () => {
registerShortcuts();
});