Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

shortcuts.js continue #2421 rewrite #2429

Closed
wants to merge 29 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
9177566
shortcuts.js continue #2421 rewrite
raszpl Jul 1, 2024
d318806
Update init.js shortcuts->shortcutsInit, formatting, playlist functio…
raszpl Jul 1, 2024
fc46d21
Update core.js shortcuts work
raszpl Jul 1, 2024
65b5dc7
Update messages.json let user know those are Toggles
raszpl Jul 1, 2024
6c4a69b
Update messages.json shortcut_transcript
raszpl Jul 1, 2024
1c8e71d
Update shortcuts.js shortcut_transcript
raszpl Jul 1, 2024
75d08f2
shortcuts.js language independent shortcutChapters shortcutTranscript
raszpl Jul 2, 2024
59438d5
shortcuts.js simplified shortcutNextVideo shortcutPrevVideo
raszpl Jul 2, 2024
2889a9c
Update shortcuts.js potentially more reliable like/dislike
raszpl Jul 4, 2024
b84f897
Update shortcuts.js missing ;
raszpl Jul 4, 2024
88254f5
shortcuts.js cancel keydown/wheel event before we call target handler
raszpl Jul 4, 2024
6532abf
Update shortcuts.js pressed.keys turned into Set for more reliability
raszpl Jul 4, 2024
78dfb74
core.js pressed.keys cancelled turned into Set() for reliability
raszpl Jul 4, 2024
edf2b9a
Merge branch 'master' into patch-8
raszpl Jul 4, 2024
58c2f51
Update init.js playlistPopup, removed no longer needed invocation
raszpl Jul 4, 2024
319d79a
Update playlist.js playlistPopupUpdate > playlistPopup
raszpl Jul 4, 2024
8d0b7e1
functions.js playlistPopupUpdate > playlistPopup, removed redundant i…
raszpl Jul 4, 2024
386c18a
Update messages.json Chapter (Sidebar) On/Off
raszpl Jul 4, 2024
df5e552
Update shortcuts.js missed Set().size
raszpl Jul 4, 2024
cb9b810
Merge branch 'master' into patch-8
raszpl Jul 4, 2024
9ad481f
core.js setPlaybackRate > playbackSpeed, ESLint Errors
raszpl Jul 4, 2024
dee8f3b
Update init.js dangling space
raszpl Jul 4, 2024
57e544a
Update shortcuts.js ESLint errors
raszpl Jul 4, 2024
8b1ff53
Update playlist.js eslint
raszpl Jul 4, 2024
e036f17
shortcuts.js shortcutChapters shortcutTranscript btureforce fallback
raszpl Jul 5, 2024
966f3fb
Update shortcuts.js error messages
raszpl Jul 5, 2024
e369e60
Update shortcuts.js typos
raszpl Jul 5, 2024
e828ff6
Update shortcuts.js cut&paste error
raszpl Jul 5, 2024
5eccbc9
Update shortcuts.js safety
raszpl Jul 7, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion _locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -1128,11 +1128,14 @@
"message": "Share"
},
"shortcut_chapters": {
"message": "Show chapters Sidebar"
"message": "Chapter (Sidebar) On/Off"
},
"shortcut_screenshot": {
"message": "Screenshot"
},
"shortcut_transcript": {
"message": "Transcript (Sidebar) On/Off"
},
"shortcuts": {
"message": "Shortcuts"
},
Expand Down
27 changes: 12 additions & 15 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 Expand Up @@ -434,18 +435,14 @@ document.addEventListener('it-message-from-extension', function () {
ImprovedTube.played_before_blur = ImprovedTube.elements.player.getPlayerState() === 1;
ImprovedTube.elements.player.pauseVideo();
}
} else if (message.hasOwnProperty('setVolume')) {
if (ImprovedTube.elements.player) {
ImprovedTube.elements.player.setVolume(message.setVolume);
}
} else if (message.hasOwnProperty('setPlaybackSpeed')) {
if (ImprovedTube.elements.player) {
ImprovedTube.elements.player.setPlaybackRate(message.setPlaybackSpeed);
}
} else if (message.setVolume) {
ImprovedTube.elements.player?.setVolume(message.setVolume);
} else if (message.setPlaybackSpeed) {
ImprovedTube.playbackSpeed(message.setPlaybackSpeed);
} else if (message.deleteCookies === true) {
ImprovedTube.deleteYoutubeCookies();
} else if (message.hasOwnProperty('responseOptionsUrl')) {
var iframe = document.querySelector('.it-button__iframe');
} else if (message.responseOptionsUrl) {
const iframe = document.querySelector('.it-button__iframe');

if (iframe) {
iframe.src = message.responseOptionsUrl;
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 @@ -107,7 +107,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 @@ -134,7 +133,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
29 changes: 7 additions & 22 deletions js&css/web-accessible/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,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 @@ -41,7 +37,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 @@ -85,34 +81,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 @@ -58,8 +58,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 @@ -134,7 +132,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 @@ -234,7 +232,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
Loading