Skip to content

Commit

Permalink
Merge pull request #2461 from code-charity/recreated-pr-branch
Browse files Browse the repository at this point in the history
Recreated pr branch #2429
  • Loading branch information
ImprovedTube authored Jul 8, 2024
2 parents 33d00b9 + 3bcc3b7 commit b8d73f3
Show file tree
Hide file tree
Showing 7 changed files with 153 additions and 168 deletions.
5 changes: 4 additions & 1 deletion _locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -1131,11 +1131,14 @@
"message": "Share"
},
"shortcut_chapters": {
"message": "Show chapters Sidebar"
"message": "Chapters (Sidebar) On/Off"
},
"shortcut_screenshot": {
"message": "Screenshot"
},
"shortcut_transcript": {
"message": "Transcript (Sidebar) On/Off"
},
"shortcuts": {
"message": "Shortcuts"
},
Expand Down
11 changes: 6 additions & 5 deletions js&css/web-accessible/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,15 @@ var ImprovedTube = {
listening: {},
listeners: {},
pressed: {
keys: [],
keys: new Set(),
wheel: 0,
alt: false,
ctrl: false,
shift: false,
player: false,
wheel: 0
shift: false
},
cancelled: []
cancelled: new Set(),
ignoreElements: ['EMBED', 'INPUT', 'OBJECT', 'TEXTAREA', 'IFRAME'],
modifierKeys: ['AltLeft', 'AltRight', 'ControlLeft', 'ControlRight', 'ShiftLeft', 'ShiftRight'],
},
mini_player__mode: false,
mini_player__move: false,
Expand Down
3 changes: 1 addition & 2 deletions js&css/web-accessible/functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ ImprovedTube.ytElementsHandler = function (node) {
this.playlistReverse();
}
}
this.playlistPopupUpdate();
} else if (name === 'YTD-GUIDE-SECTION-RENDERER') {
if (!this.elements.sidebar_section) {
this.elements.sidebar_section = node;
Expand All @@ -111,7 +110,7 @@ ImprovedTube.ytElementsHandler = function (node) {
// this.hideDetailButton(node.querySelector('#flexible-item-buttons').children);
// }
} else if (name === 'YTD-PLAYLIST-HEADER-RENDERER' || (name === 'YTD-MENU-RENDERER' && node.classList.contains('ytd-playlist-panel-renderer'))) {
this.playlistPopupUpdate();
this.playlistPopup();
} else if (name === 'YTD-SUBSCRIBE-BUTTON-RENDERER'
|| name === 'YT-SUBSCRIBE-BUTTON-VIEW-MODEL'
|| (name === 'YTD-BUTTON-RENDERER' && node.classList.contains('ytd-c4-tabbed-header-renderer'))) {
Expand Down
25 changes: 7 additions & 18 deletions js&css/web-accessible/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@ ImprovedTube.observer = new MutationObserver(function (mutationList) {
for (var j = 0, k = mutation.addedNodes.length; j < k; j++) {
ImprovedTube.childHandler(mutation.addedNodes[j]);
}

for (const node of mutation.removedNodes) {
if (node.nodeName === 'BUTTON' && node.id === 'it-popup-playlist-button') ImprovedTube.playlistPopupUpdate();
}
}
if (mutation.target && mutation.target.id === 'owner-sub-count') {
// Extract and store the subscriber count
Expand All @@ -39,7 +35,7 @@ ImprovedTube.observer = new MutationObserver(function (mutationList) {
//console.log("p"+i+"c"+j+":"+node.id+",class:"+node.className+","+node+"("+node.nodeName+")");
j++;}
let r = 0; for (const node of mutated.removedNodes){ //might fix our other playlist buttons equally?
if(node.nodeName === 'BUTTON' && node.id === 'it-popup-playlist-button') ImprovedTube.playlistPopupUpdate();
if(node.nodeName === 'BUTTON' && node.id === 'it-popup-playlist-button') ImprovedTube.playlistPopup();
//console.log("p"+i+"removed"+r+":"+node.id+",class:"+node.className+","+node+"("+node.nodeName+")"+"(from:"+mutated.target.id+",class:"+mutated.target.className+","+mutated.target+"("+mutated.target.nodeName+")");
r++;}
if(mutated.target.id === 'owner-sub-count')
Expand Down Expand Up @@ -83,30 +79,23 @@ if (ImprovedTube.storage.channel_default_tab && ImprovedTube.storage.channel_def
ImprovedTube.init = function () {
window.addEventListener('yt-page-data-updated', function () {
ImprovedTube.pageType();
if (document.documentElement.dataset.pageType === 'video' && /[?&]list=([^&]+).*$/.test(location.href)) {
if (location.search.match(ImprovedTube.regex.playlist_id)) {
ImprovedTube.playlistRepeat();
ImprovedTube.playlistShuffle();
ImprovedTube.playlistReverse();
ImprovedTube.playlistPopup();
}
ImprovedTube.playlistPopupUpdate();
});
ImprovedTube.pageType();
var yt_player_updated = function () {
document.dispatchEvent(new CustomEvent('improvedtube-player-loaded'));

window.removeEventListener('yt-player-updated', yt_player_updated);
};

window.addEventListener('yt-player-updated', yt_player_updated);
this.pageType();
this.playerOnPlay();
this.playerSDR();
this.shortcuts();
this.shortcutsInit();
this.onkeydown();
this.onmousedown();
this.youtubeLanguage();
this.myColors();
if (this.storage.undo_the_new_sidebar === true) {this.undoTheNewSidebar();}
if (this.storage.description === "sidebar") {this.descriptionSidebar();}
if (this.storage.undo_the_new_sidebar) this.undoTheNewSidebar();
if (this.storage.description === "sidebar") this.descriptionSidebar();
this.channelCompactTheme();

if (ImprovedTube.elements.player && ImprovedTube.elements.player.setPlaybackRate) {
Expand Down
6 changes: 2 additions & 4 deletions js&css/web-accessible/www.youtube.com/playlist.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,6 @@ ImprovedTube.playlistReverse = function () {
button.id = 'it-reverse-playlist';
button.className = 'style-scope yt-icon-button';
button.addEventListener('click', function (event) {
var playlist_manager = document.querySelector('yt-playlist-manager');

event.preventDefault();
event.stopPropagation();

Expand Down Expand Up @@ -131,7 +129,7 @@ ImprovedTube.playlistShuffle = function () {
------------------------------------------------------------------------------*/
/**
* ## Creates a playlist popup button (with ID `it-popup-playlist-button`)
* - used by/in {@linkcode ImprovedTube.playlistPopupUpdate}
* - used by/in {@linkcode ImprovedTube.playlistPopup}
* - checks {@linkcode ImprovedTube.storage.player_autoplay_disable} if to autoplay the popuped playlist/video
* - checks {@linkcode ImprovedTube.elements.player} to get video ID and current time, if available, otherwise starts first video of playlist
* - popup has video players width/height or window (inner) width/height when video player is not available
Expand Down Expand Up @@ -222,7 +220,7 @@ ImprovedTube.playlistPopupCreateButton = function (playlistID, altButtonStyle, c
* - saves each button in {@linkcode ImprovedTube.elements.buttons} as `it-popup-playlist-button-playlist`, `it-popup-playlist-button-mini`, and `it-popup-playlist-button-panel`
* - called from {@linkcode ImprovedTube.ytElementsHandler} and {@linkcode ImprovedTube.hrefObserver} when DOM changes (somewhat related to playlist renderers)
*/
ImprovedTube.playlistPopupUpdate = function () {
ImprovedTube.playlistPopup = function () {
"use strict";
if (this.storage.playlist_popup === true) {

Expand Down
Loading

0 comments on commit b8d73f3

Please sign in to comment.