Skip to content

Commit

Permalink
-
Browse files Browse the repository at this point in the history
  • Loading branch information
ImprovedTube committed Jul 28, 2024
1 parent d53d996 commit 5d4961f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 16 deletions.
4 changes: 2 additions & 2 deletions js&css/web-accessible/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -246,9 +246,9 @@ document.addEventListener('it-message-from-extension', function () {
break

case 'description':
if (ImprovedTube.storage.description === "expanded" || ImprovedTube.storage.description === "classic_expanded") {
if (ImprovedTube.storage.description === "expanded") {
try {document.querySelector("#more").click() || document.querySelector("#expand").click();} catch {}
} else if (ImprovedTube.storage.description === "normal" || ImprovedTube.storage.description === "classic") {
} else if (ImprovedTube.storage.description === "normal") {
try {document.querySelector("#less").click() || document.querySelector("#collapse").click();} catch {}
}
break
Expand Down
14 changes: 4 additions & 10 deletions js&css/web-accessible/functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -226,21 +226,15 @@ ImprovedTube.ytElementsHandler = function (node) {
if (id === 'description-inline-expander' || id === 'description-inner') {
setTimeout(function () {ImprovedTube.expandDescription(node);}, 300);
} else if (id === 'meta') {setTimeout(function () {ImprovedTube.expandDescription(node.querySelector('#more'));}, 200);
} else if (id === 'below') {
setTimeout(function () {}, 0);
} else if (id === 'panels') {
setTimeout(function () {
ImprovedTube.transcript(node);
ImprovedTube.chapters(node);
}, 200);
} /* else if (name === 'TP-YT-PAPER-BUTTON') {
// } else if (id === 'below') { setTimeout(function () {}, 0);
} else if (id === 'panels') { setTimeout(function () { ImprovedTube.transcript(node); ImprovedTube.chapters(node);}, 200);
} /* else if (name === 'TP-YT-PAPER-BUTTON') {
if ( (id === 'expand-sizer' || id === 'expand') && node.parentNode.id === 'description-inline-expander') {
setTimeout(function () {
ImprovedTube.expandDescription(node); console.log("EXPAND DESCRIPTION, OLD WAY")
ImprovedTube.expandDescription(node); console.log("EXPAND DESCRIPTION, OLD WAY")
}, 750);
}} */
}

};

ImprovedTube.pageType = function () {
Expand Down
9 changes: 5 additions & 4 deletions js&css/web-accessible/www.youtube.com/appearance.js
Original file line number Diff line number Diff line change
Expand Up @@ -427,23 +427,24 @@ ImprovedTube.expandDescription = function (el) {
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"); }

Check warning on line 429 in js&css/web-accessible/www.youtube.com/appearance.js

View workflow job for this annotation

GitHub Actions / lint-and-test

Missing space before function parentheses
setTimeout(() => { HTMLElement.prototype.focus = originalFocus;}, ms); // Restoring JS's "focus()"
setTimeout(function() { HTMLElement.prototype.focus = originalFocus; }, ms); // Restoring JS's "focus()"

Check warning on line 430 in js&css/web-accessible/www.youtube.com/appearance.js

View workflow job for this annotation

GitHub Actions / lint-and-test

Missing space before function parentheses

Check warning on line 430 in js&css/web-accessible/www.youtube.com/appearance.js

View workflow job for this annotation

GitHub Actions / lint-and-test

Trailing spaces not allowed
}
if (el) {

Check warning on line 432 in js&css/web-accessible/www.youtube.com/appearance.js

View workflow job for this annotation

GitHub Actions / lint-and-test

Trailing spaces not allowed
try { ImprovedTube.forbidFocus(2000); } catch { setTimeout(function () {ImprovedTube.elements.player.focus();}, 1200); }
ImprovedTube.forbidFocus(1200); // setTimeout(function () {ImprovedTube.elements.player.focus();}, 1200);

Check warning on line 433 in js&css/web-accessible/www.youtube.com/appearance.js

View workflow job for this annotation

GitHub Actions / lint-and-test

Trailing spaces not allowed
el.click();
}
else { // this rest will be unnecessary with proper timing:
var tries = 0; var intervalMs = 210; if (location.href.indexOf('/watch?') !== -1) {var maxTries = 10;} else {var maxTries = 0;} // ...except when it is an embedded player?
var waitForDescription = setInterval(() => {
if (++tries >= maxTries) {
if (el) {
try { ImprovedTube.forbidFocus(2000); } catch { setTimeout(function () {ImprovedTube.elements.player.focus();}, 1000); }
ImprovedTube.forbidFocus(1200); // setTimeout(function () {ImprovedTube.elements.player.focus();}, 1000);

Check warning on line 441 in js&css/web-accessible/www.youtube.com/appearance.js

View workflow job for this annotation

GitHub Actions / lint-and-test

Multiple spaces found before '// setTimeout(...'
el.click();
clearInterval(waitForDescription);
}
el = document.querySelector('#description-inline-expander')
intervalMs *= 1.11; }}, intervalMs);
}
}
}
}
/*------------------------------------------------------------------------------
Expand Down

0 comments on commit 5d4961f

Please sign in to comment.