Closed pointydev closed 3 months ago
it turned out to be easy
add a new plugin after the line window.nova_plugins = [];
window.nova_plugins.push({
id: 'livechat-toggle-mode',
title: '"Live chat" mode instead of "Top chat"',
run_on_pages: 'live_chat, -mobile',
//restart_on_location_change: true,
section: 'sidebar',
_runtime: user_settings => {
NOVA.waitSelector('#chat-messages #menu a:nth-child(2)[aria-selected="false"]'/*, { destroy_after_page_leaving: true }*/)
.then(btn => btn.click);
},
});
and replace the iframe launch limiter
this code
!location.pathname.startsWith('/embed')
to
(!location.pathname.startsWith('/embed') && !location.pathname.startsWith('/live_chat'))
crap I don't see any other way except to add a delay so that the default yt event listener connects
replace
.then(btn => btn.click);
to
.then(async btn => {
await NOVA.delay(500);
btn.click();
});
It seems to be working just when running asynchronously, without using delay:
.then(async btn => {
await btn.click();
});
I think this is a bug and not a feature https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/click
I wonder what will happen in other browsers. I didn’t realize that click was asynchronous. Perhaps asynchronous calls have some lag which is enough to use event listener callback
For example, it was a surprise to me that this code works
Promise.resolve(document.querySelector(selector);
but it turned out that he would never return the element.
oh shit, it's broken
example video
does not work - #chat-messages #menu a:last-child[aria-selected="false"]
works correct - #chat-messages #menu a[aria-selected="false"]
ps about await btn.click();
yes this is a bug. await adds ~500ms latency.
For example here the script does not work because the delay is already 1500ms needed
A plugin that could set livestream chats to "Live chat" mode instead of "Top chat" automatically would be really useful in smaller streams in order to prevent messages in low traffic chats from being missed.
Thanks, pointy