From bece740d3fbd5007df34ed6f2fd9f6dbea9ff2a6 Mon Sep 17 00:00:00 2001 From: Brian Buller Date: Thu, 18 Feb 2021 10:53:22 -0600 Subject: [PATCH 1/2] 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...) --- DuckDuckGo Images Slideshow.user.js | 30 +++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/DuckDuckGo Images Slideshow.user.js b/DuckDuckGo Images Slideshow.user.js index 2dca45a..0564d50 100644 --- a/DuckDuckGo Images Slideshow.user.js +++ b/DuckDuckGo Images Slideshow.user.js @@ -1,7 +1,7 @@ // ==UserScript== // @name DuckDuckGo Images Slideshow // @namespace https://bullercodeworks.com -// @version 0.1 +// @version 0.2 // @description Takes a DuckDuckGo Images page and turns it into a slideshow. // @author You // @match https://duckduckgo.com/* @@ -162,29 +162,39 @@ showImage(currimg); } - - document.addEventListener('keyup',(e)=>{ + document.addEventListener('keydown',(e)=>{ if(!running) { return; } + var stopProp = false; switch(e.code) { case 'Space': pause(); - return true; - case 'ArrowLeft': + stopProp = true; + break; + case 'KeyH': rewind(); - return true; - case 'ArrowRight': + stopProp = true; + break; + case 'KeyL': fastforward(); - return true; + stopProp = true; + break; case 'KeyT': promptTime(); - return true; + stopProp = true; + break; case 'KeyG': goto(); - return true; + stopProp = true; + break; case 'Escape': clearTimeout(timer); running = false; lb.remove(); + stopProp = true; } + if(stopProp) { + e.stopPropagation(); + } + return stopProp; }); })(); \ No newline at end of file From 141cde3cf2b7cdb157ece1ec025381ad0c8c3d03 Mon Sep 17 00:00:00 2001 From: Brian Buller Date: Fri, 19 Feb 2021 09:50:29 -0600 Subject: [PATCH 2/2] Update 'DuckDuckGo Images Slideshow.user.js' Add Image Counter Display --- DuckDuckGo Images Slideshow.user.js | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/DuckDuckGo Images Slideshow.user.js b/DuckDuckGo Images Slideshow.user.js index 0564d50..92c8c52 100644 --- a/DuckDuckGo Images Slideshow.user.js +++ b/DuckDuckGo Images Slideshow.user.js @@ -1,9 +1,9 @@ // ==UserScript== // @name DuckDuckGo Images Slideshow // @namespace https://bullercodeworks.com -// @version 0.2 +// @version 0.3 // @description Takes a DuckDuckGo Images page and turns it into a slideshow. -// @author You +// @author brian@bullercodeworks.com // @match https://duckduckgo.com/* // @grant none // ==/UserScript== @@ -12,7 +12,6 @@ 'use strict'; var init = function() { - console.log("Starting Slideshow"); lb.style.textAlign = 'center'; lb.style.height = '100%'; lb.style.width = '100%'; @@ -24,6 +23,12 @@ document.body.prepend(lb); lbimg.style.objectFit = 'cover'; lb.append(lbimg); + imgCounter.style.backgroundColor = 'rgba(0, 0, 0, 0.85)'; + imgCounter.style.color = 'white'; + imgCounter.style.position = 'fixed'; + imgCounter.style.top = '0px'; + imgCounter.style.left = '0px'; + lb.append(imgCounter); running = true; showImage(0); } @@ -53,6 +58,7 @@ var imgcount=allimages.length; var lb = document.createElement('div'); var lbimg = document.createElement('img'); + var imgCounter = document.createElement('span'); var lastScroll = 0; @@ -65,7 +71,7 @@ var testimages = document.querySelectorAll('img'); var testcount = testimages.length; if(testcount > imgcount) { - console.log("Image Count Changed:"+testcount+" > "+imgcount); + console.log("Loading more images..."); imgcount = testcount; allimages = testimages; } @@ -83,8 +89,9 @@ timer = setTimeout(() => showImage(++idx), 100); return; } + allimages[idx].click(); allimages[idx].scrollIntoView(); - console.log("Showing Image "+idx+" :: "+allimages[idx]); + console.log("Showing Image "+idx+" ("+allimages[idx]+")"); var useHeight=allimages[idx].height > allimages[idx].width; if(useHeight){ lbimg.style.height = '100%'; @@ -94,6 +101,7 @@ lbimg.style.width = '100%' } lbimg.src = allimages[idx].src; + imgCounter.innerText = "Image " + idx + " / " + imgcount; timer = setTimeout(() => showImage(++idx), imageTime); } @@ -137,10 +145,10 @@ function pause(){ if(paused){ - console.log("resume"); + console.log("Resuming Slideshow"); showImage(currimg); } else { - console.log("pause"); + console.log("Pausing Slideshow"); clearTimeout(timer); } paused = !paused; @@ -148,7 +156,7 @@ function rewind() { - console.log("rewind"); + console.log("Rewinding Slideshow"); clearTimeout(timer); currimg = currimg-1; showImage(currimg); @@ -156,7 +164,7 @@ function fastforward() { - console.log("fast forward"); + console.log("Fast Forwarding Slideshow"); clearTimeout(timer); currimg = currimg+1; showImage(currimg);