54 lines
3.4 KiB
JavaScript
54 lines
3.4 KiB
JavaScript
const stopTranscribing = () => {
|
|
debug("call stopTranscribing"), notificationsOff(), clearInterval(closedCaptionsAttachInterval), closedCaptionsAttachInterval = null, captionContainerChildObserver.disconnect(), captionContainerAttributeObserver.disconnect()
|
|
},
|
|
startTranscribing = () => {
|
|
debug("call startTranscribing"), currentSessionIndex = null, closedCaptionsAttachInterval = setInterval(tryTo(closedCaptionsAttachLoop, "attach to captions"), 1e3), setCurrentTranscriptDetails()
|
|
},
|
|
toggleTranscribing = () => {
|
|
debug("call toggleTranscribing"), isTranscribing ? stopTranscribing() : startTranscribing(), isTranscribing = !isTranscribing
|
|
},
|
|
turnOnCaptions = () => {
|
|
const t = getElementWithXPathFallback(document, XPATH_TURN_ON_CAPTIONS_BUTTON, XPATH_TURN_ON_CAPTIONS_BUTTON_V20210602);
|
|
return debug("captionsButtonOn", t), t && (t.click(), notificationsOn()), t
|
|
},
|
|
turnOffCaptions = () => {
|
|
const t = getElementWithXPathFallback(document, XPATH_TURN_OFF_CAPTIONS_BUTTON, XPATH_TURN_OFF_CAPTIONS_BUTTON_V20210602);
|
|
return debug("captionsButtonOff", t), t && (t.click(), notificationsOff()), t
|
|
},
|
|
turnOnCaptionNotificationsOn = () => {
|
|
const t = document.getElementById("popup");
|
|
t.style.backgroundColor = "#818388", t.style.color = "#292c35", t.innerHTML = "Please turn on captions", t.classList.add("show"), clearTimeout(notificationsTimeout), notificationsTimeout = setTimeout((() => {
|
|
t.classList.remove("show")
|
|
}), 500)
|
|
},
|
|
notificationsOn = () => {
|
|
const t = document.getElementById("laxis-caption-toggle"),
|
|
n = document.getElementById("laxis-caption-toggle-mini"),
|
|
i = document.getElementById("captionIcon"),
|
|
o = document.getElementById("captionIconMini");
|
|
t.removeChild(i), n.removeChild(o);
|
|
const e = createCaptionOnIcon(),
|
|
c = createCaptionOnIcon();
|
|
e.id = "captionIcon", e.style.width = "15px", e.style.height = "15px", t.appendChild(e), c.id = "captionIconMini", c.style.width = "15px", c.style.height = "15px", n.appendChild(c);
|
|
const s = document.getElementById("popup");
|
|
s.style.backgroundColor = "#818388", s.style.color = "#292c35", s.innerHTML = "Your caption is turned on", s.classList.add("show"), clearTimeout(notificationsTimeout), notificationsTimeout = setTimeout((() => {
|
|
s.classList.remove("show")
|
|
}), notificationsTimeoutDuration)
|
|
},
|
|
notificationsOff = () => {
|
|
const t = document.getElementById("laxis-caption-toggle"),
|
|
n = document.getElementById("laxis-caption-toggle-mini"),
|
|
i = document.getElementById("captionIcon"),
|
|
o = document.getElementById("captionIconMini");
|
|
t.removeChild(i), n.removeChild(o);
|
|
const e = createCaptionOffIcon(),
|
|
c = createCaptionOffIcon();
|
|
e.id = "captionIcon", e.style.width = "15px", e.style.height = "15px", t.appendChild(e), c.id = "captionIconMini", c.style.width = "15px", c.style.height = "15px", n.appendChild(c);
|
|
const s = document.getElementById("popup");
|
|
s.style.backgroundColor = "#818388", s.style.color = "#292c35", s.innerHTML = "Your caption is turned off", s.classList.add("show"), clearTimeout(notificationsTimeout), notificationsTimeout = setTimeout((() => {
|
|
s.classList.remove("show")
|
|
}), notificationsTimeoutDuration)
|
|
},
|
|
toggleCaptions = () => {
|
|
debug("call toggleCaptions"), weTurnedCaptionsOn ? turnOffCaptions() : turnOnCaptions(), weTurnedCaptionsOn = !weTurnedCaptionsOn
|
|
}; |