diff --git a/scripts/genEventsYoutubePlayerBookmarklet.js b/scripts/genEventsYoutubePlayerBookmarklet.js index d1081fb7..e777a4da 100644 --- a/scripts/genEventsYoutubePlayerBookmarklet.js +++ b/scripts/genEventsYoutubePlayerBookmarklet.js @@ -1,6 +1,12 @@ javascript:(function() { const timestamps = []; const durations = []; + let keyBindings = { + captureTimestamp: '=', + endTimestamp: '+', + removeNearestDuration: '-', + removeNearestTimestamp: 'Backspace' + }; const overlay = createOverlay(); document.body.appendChild(overlay); @@ -12,9 +18,13 @@ javascript:(function() { position: 'fixed', top: '50px', right: '0', - backgroundColor: 'rgba(255,0,0,0.66)', + backgroundColor: 'rgba(0,0,0,0.8)', padding: '10px', zIndex: '1000', + color: 'white', + fontFamily: 'Arial, sans-serif', + maxWidth: '300px', + borderRadius: '5px' }; for (const prop in overlayStyle) { overlay.style[prop] = overlayStyle[prop]; @@ -23,14 +33,17 @@ javascript:(function() { } function handleKeyPress(event) { - if (event.key === '=') { - captureTimestamp(); - } else if (event.key === '-') { - removeNearestDuration(); - } else if (event.key === 'Backspace') { - removeNearestTimestamp(); - } else if (event.key === '+') { - endTimestamp(); + for (const action in keyBindings) { + if (event.key === keyBindings[action]) { + event.preventDefault(); + switch(action) { + case 'captureTimestamp': captureTimestamp(); break; + case 'endTimestamp': endTimestamp(); break; + case 'removeNearestDuration': removeNearestDuration(); break; + case 'removeNearestTimestamp': removeNearestTimestamp(); break; + } + break; + } } } @@ -90,7 +103,6 @@ javascript:(function() { } function getMediaPlayer() { - // Check for YouTube player first const youtubePlayer = document.getElementById('movie_player'); if (youtubePlayer && typeof youtubePlayer.getCurrentTime === 'function') { return { @@ -100,7 +112,6 @@ javascript:(function() { }; } - // Check for HTML5 audio or video player const htmlPlayer = document.querySelector('audio, video'); if (htmlPlayer) { return htmlPlayer; @@ -122,7 +133,18 @@ javascript:(function() { } function updateOverlay() { - overlay.innerHTML = ''; + overlay.innerHTML = '