Update 'DuckDuckGo Images Slideshow.user.js'

Use 'h'/'l' for previous/next, you can't disable Left/Right in DDG settings. 
(And stopping propagation doesn't seem to work? Or I'm doing it wrong...)
This commit is contained in:
Brian Buller 2021-02-18 10:53:22 -06:00
parent bf629f95c5
commit bece740d3f

View File

@ -1,7 +1,7 @@
// ==UserScript== // ==UserScript==
// @name DuckDuckGo Images Slideshow // @name DuckDuckGo Images Slideshow
// @namespace https://bullercodeworks.com // @namespace https://bullercodeworks.com
// @version 0.1 // @version 0.2
// @description Takes a DuckDuckGo Images page and turns it into a slideshow. // @description Takes a DuckDuckGo Images page and turns it into a slideshow.
// @author You // @author You
// @match https://duckduckgo.com/* // @match https://duckduckgo.com/*
@ -162,29 +162,39 @@
showImage(currimg); showImage(currimg);
} }
document.addEventListener('keydown',(e)=>{
document.addEventListener('keyup',(e)=>{
if(!running) { return; } if(!running) { return; }
var stopProp = false;
switch(e.code) { switch(e.code) {
case 'Space': case 'Space':
pause(); pause();
return true; stopProp = true;
case 'ArrowLeft': break;
case 'KeyH':
rewind(); rewind();
return true; stopProp = true;
case 'ArrowRight': break;
case 'KeyL':
fastforward(); fastforward();
return true; stopProp = true;
break;
case 'KeyT': case 'KeyT':
promptTime(); promptTime();
return true; stopProp = true;
break;
case 'KeyG': case 'KeyG':
goto(); goto();
return true; stopProp = true;
break;
case 'Escape': case 'Escape':
clearTimeout(timer); clearTimeout(timer);
running = false; running = false;
lb.remove(); lb.remove();
stopProp = true;
} }
if(stopProp) {
e.stopPropagation();
}
return stopProp;
}); });
})(); })();