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

Update init.js ImprovedTube.livechat collapsed called too early #2298

Merged
merged 1 commit into from
May 23, 2024
Merged

Conversation

raszpl
Copy link
Contributor

@raszpl raszpl commented May 23, 2024

ImprovedTube.livechat = function () {
if (this.storage.livechat === "collapsed") {
if (typeof isCollapsed === 'undefined') { var isCollapsed = false; }
if(ImprovedTube.elements.livechat && !isCollapsed){
ImprovedTube.elements.livechat.button.click();
isCollapsed = true
}

called in init

this.livechat();

appearance.js:320 Uncaught TypeError: Cannot read properties of undefined (reading 'click')
at ImprovedTube.livechat (appearance.js:320:51)
at ImprovedTube.init (init.js:106:7)
at HTMLDocument. (core.js:176:17)

git blame shows it has been like this for at lest two years

ImprovedTube.elements.livechat stays initialized as empty object

until

} else if (id === 'chat-messages') {
this.elements.livechat.button = document.querySelector('[aria-label="Close"]');
// console.log(document.querySelector('[aria-label="Close"]'))
this.livechat();

@ImprovedTube ImprovedTube merged commit 6538d6a into code-charity:master May 23, 2024
@ImprovedTube
Copy link
Member

also, [aria-label="Close"] exists several times in different panels

@raszpl raszpl deleted the patch-5 branch May 23, 2024 10:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants