INNER CODE UNIT · TypeScript
conversationDivObserver
sindresorhus/caprine · source/autoplay.ts:138
const conversationDivObserver = new MutationObserver(_ => {
let conversation = document.querySelector(`#${conversationId}`);
// Fetch it using `querySelector` if no luck with the `conversationId`
conversation ||= document.querySelector(selectors.conversationSelector);
// If we have a new reference
if (conversation && conversationWindow !== conversation) {
// Add `conversationId` so we know when we've lost the reference to
// the `conversationWindow` and we can restart the video observer
conversation.id = conversationId;
conversationWindow = conversation;
startVideoObserver(conversationWindow);
}
});
// Reference to mutation observer
// Only active if the user has set option to disable video autoplay