Skip to content

Commit

Permalink
Merge branch 'master' into dot-github-stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
4yman-0 authored Jan 6, 2025
2 parents 3a6fac0 + 1e9e926 commit bb6fedc
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 13 deletions.
14 changes: 3 additions & 11 deletions js&css/web-accessible/functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -405,17 +405,9 @@ ImprovedTube.playerOnPause = function (event) {

};

if (document.documentElement.dataset.pageType === 'video'
&& (ImprovedTube.storage.description === "expanded" || ImprovedTube.storage.transcript === true || ImprovedTube.storage.chapters === true )) {
ImprovedTube.forbidFocus = function (ms) {
const originalFocus = HTMLElement.prototype.focus; // Backing up default method - other methods: Element.prototype.scrollIntoView window.scrollTo window.scrollBy
// Override YouTube's scroll method:
HTMLElement.prototype.focus = function() {console.log("Preventing YouTube's scripted scrolling, when expanding the video description for you"); }
if(document.hidden) ms = 3*ms;
setTimeout(function() { HTMLElement.prototype.focus = originalFocus; }, ms); // Restoring JS's "focus()"
}
}

// if ( document.documentElement.dataset.pageType === 'video'
// && (ImprovedTube.storage.description === "expanded" || ImprovedTube.storage.transcript === true || ImprovedTube.storage.chapters === true )) {

Check warning on line 409 in js&css/web-accessible/functions.js

View workflow job for this annotation

GitHub Actions / lint-and-test

Trailing spaces not allowed
// ImprovedTube.forbidFocus = function (ms)
/*--------------------------------------------------------------
# HIDE PROGRESS BAR PREVIEW
--------------------------------------------------------------*/
Expand Down
18 changes: 18 additions & 0 deletions js&css/web-accessible/www.youtube.com/appearance.js
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,12 @@ ImprovedTube.hideTopProgressBar = function () {
ImprovedTube.transcript = function (el) { if (ImprovedTube.storage.transcript === true) {
const available = el.querySelector('[target-id*=transcript][visibility*=HIDDEN]') || el.querySelector('[target-id*=transcript]')?.clientHeight;
if (available) {
if (!ImprovedTube.originalFocus) {ImprovedTube.originalFocus = HTMLElement.prototype.focus;} // Backing up default method. Youtube doesn't use alternatives Element.prototype.scrollIntoView window.scrollTo window.scrollBy)
ImprovedTube.forbidFocus = function (ms) {
HTMLElement.prototype.focus = function() {console.log("Preventing YouTube's scripted scrolling for a moment."); }
if(document.hidden) ms = 3*ms;
setTimeout(function() { HTMLElement.prototype.focus = ImprovedTube.originalFocus; }, ms); // Restoring JS's "focus()"
}
ImprovedTube.forbidFocus(2100);
const descriptionTranscript = el.querySelector('ytd-video-description-transcript-section-renderer button[aria-label]');
descriptionTranscript ? descriptionTranscript.click() : el.querySelector('[target-id*=transcript]')?.removeAttribute('visibility');
Expand All @@ -351,6 +357,12 @@ ImprovedTube.transcript = function (el) { if (ImprovedTube.storage.transcript ==
ImprovedTube.chapters = function (el) { if (ImprovedTube.storage.chapters === true) {
const available = el.querySelector('[target-id*=chapters][visibility*=HIDDEN]') || el.querySelector('[target-id*=chapters]')?.clientHeight;
if (available) {
if (!ImprovedTube.originalFocus) { ImprovedTube.originalFocus = HTMLElement.prototype.focus;} // Backing up default method. Youtube doesn't use alternatives Element.prototype.scrollIntoView window.scrollTo window.scrollBy)
ImprovedTube.forbidFocus = function (ms) {
HTMLElement.prototype.focus = function() {console.log("Preventing YouTube's scripted scrolling for a moment."); }
if(document.hidden) ms = 3*ms;
setTimeout(function() { HTMLElement.prototype.focus = ImprovedTube.originalFocus; }, ms); // Restoring JS's "focus()"
}
ImprovedTube.forbidFocus(2100);
const modernChapters = el.querySelector('[modern-chapters] #navigation-button button[aria-label]');
modernChapters ? modernChapters.click() : el.querySelector('[target-id*=chapters]')?.removeAttribute('visibility');
Expand Down Expand Up @@ -494,6 +506,12 @@ ImprovedTube.improvedtubeYoutubeButtonsUnderPlayer = function () {
------------------------------------------------------------------------------*/
ImprovedTube.expandDescription = function (el) {
if (this.storage.description === "expanded") {
if (!ImprovedTube.originalFocus) { ImprovedTube.originalFocus = HTMLElement.prototype.focus;} // Backing up default method. Youtube doesn't use alternatives Element.prototype.scrollIntoView window.scrollTo window.scrollBy)
ImprovedTube.forbidFocus = function (ms) {
HTMLElement.prototype.focus = function() {console.log("Preventing YouTube's scripted scrolling for a moment."); }
if(document.hidden) ms = 3*ms;
setTimeout(function() { HTMLElement.prototype.focus = ImprovedTube.originalFocus; }, ms); // Restoring JS's "focus()"
}
if (el) {
ImprovedTube.forbidFocus(2100); // setTimeout(function () {ImprovedTube.elements.player.focus();}, 2500);
el.click();
Expand Down
4 changes: 3 additions & 1 deletion js&css/web-accessible/www.youtube.com/shortcuts.js
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,9 @@ ImprovedTube.shortcutResetPlaybackSpeed = function () {
4.7.19 GO TO SEARCH BOX
------------------------------------------------------------------------------*/
ImprovedTube.shortcutGoToSearchBox = function () {
document.querySelector('input#search')?.focus();
document.querySelector('input#search')?.click();
if (ImprovedTube.originalFocus) { HTMLElement.prototype.focus = originalFocus }
document.querySelector('input#search')?.focus();
};
/*------------------------------------------------------------------------------
4.7.20 ACTIVATE FULLSCREEN
Expand Down
2 changes: 1 addition & 1 deletion menu/skeleton-parts/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -1174,7 +1174,7 @@ extension.skeleton.main.layers.section.player.on.click = {
copy_video_id: {
component: 'switch',
text: 'copyVideoId',
value: true
value: false
}
},
player_hide_controls_options: {
Expand Down

0 comments on commit bb6fedc

Please sign in to comment.