f0ckv1/s/shit.js

23 lines
473 B
JavaScript
Raw Normal View History

2017-12-02 23:06:30 +00:00
const clickOnElementBinding = selector => {
2017-12-02 20:21:46 +00:00
return () => {
2017-12-02 22:44:21 +00:00
const elem = document.querySelector(selector);
2017-12-02 20:21:46 +00:00
if(elem)
elem.click();
};
2017-12-02 22:44:21 +00:00
};
2017-12-02 20:21:46 +00:00
2017-12-02 23:06:30 +00:00
const keybindings = {
"ArrowLeft": clickOnElementBinding("#next"),
"ArrowRight": clickOnElementBinding("#prev"),
"r": clickOnElementBinding("#random")
};
2017-12-02 22:44:21 +00:00
(() => {
document.addEventListener("keydown", e => {
2017-12-02 20:21:46 +00:00
if(e.key in keybindings) {
e.preventDefault();
keybindings[e.key]();
}
});
})();