-
-
Notifications
You must be signed in to change notification settings - Fork 126
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add "View All YouTube Videos (Experimental)" context-menu action to U…
…nread category Right click on Unread and choose "View All YouTube Videos" and it will open up a custom/local html file that plays all of the videos back to back.
- Loading branch information
d3fault
committed
Sep 26, 2024
1 parent
a672609
commit e88ba27
Showing
8 changed files
with
178 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>YouTube Sequential Player</title> | ||
<style> | ||
body { | ||
background-color: black; | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
flex-direction: column; | ||
height: 100vh; | ||
margin: 0; | ||
color: white; | ||
} | ||
#controls { | ||
margin-top: 20px; | ||
} | ||
.disabled { | ||
color: grey; | ||
pointer-events: none; | ||
} | ||
a { | ||
color: white; | ||
margin: 0 15px; | ||
cursor: pointer; | ||
text-decoration: none; | ||
} | ||
</style> | ||
<script> | ||
var tag = document.createElement('script'); | ||
tag.src = "https://www.youtube.com/iframe_api"; | ||
var firstScriptTag = document.getElementsByTagName('script')[0]; | ||
firstScriptTag.parentNode.insertBefore(tag, firstScriptTag); | ||
|
||
var videoIds = [%1]; | ||
|
||
var currentIndex = 0; | ||
var player; | ||
|
||
function onYouTubeIframeAPIReady() { | ||
player = new YT.Player('player', { | ||
height: '390', | ||
width: '640', | ||
videoId: videoIds[currentIndex], | ||
playerVars: { | ||
'autoplay': 1, | ||
'controls': 1, | ||
'rel': 0, // Prevents showing related videos at the end | ||
'modestbranding': 1 // Minimizes YouTube branding | ||
}, | ||
events: { | ||
'onReady': onPlayerReady, | ||
'onStateChange': onPlayerStateChange | ||
} | ||
}); | ||
} | ||
|
||
function onPlayerReady() { | ||
refocusPlayer(); | ||
updateControls(); | ||
} | ||
|
||
function onPlayerStateChange(event) { | ||
if (event.data === YT.PlayerState.ENDED) { | ||
loadNextVideo(); | ||
} | ||
} | ||
|
||
function loadPreviousVideo() { | ||
if (currentIndex > 0) { | ||
currentIndex--; | ||
player.loadVideoById(videoIds[currentIndex]); | ||
updateControls(); | ||
refocusPlayer(); | ||
} | ||
} | ||
|
||
function loadNextVideo() { | ||
if (currentIndex < videoIds.length - 1) { | ||
currentIndex++; | ||
player.loadVideoById(videoIds[currentIndex]); | ||
updateControls(); | ||
refocusPlayer(); | ||
} | ||
} | ||
|
||
function refocusPlayer() { | ||
var iframe = document.getElementById('player'); | ||
if (iframe) { | ||
iframe.focus(); | ||
} | ||
} | ||
|
||
function updateControls() { | ||
var prevLink = document.getElementById('prev'); | ||
var nextLink = document.getElementById('next'); | ||
|
||
prevLink.classList.toggle('disabled', currentIndex === 0); | ||
nextLink.classList.toggle('disabled', currentIndex === videoIds.length - 1); | ||
} | ||
</script> | ||
</head> | ||
<body> | ||
<div id="player"></div> | ||
|
||
<div id="controls"> | ||
<a id="prev" class="disabled" onclick="loadPreviousVideo()">Previous</a> | ||
<a id="next" onclick="loadNextVideo()">Next</a> | ||
</div> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters