Transcript: Ignore scroll to change volume

This commit is contained in:
Jade Macho 2024-05-14 22:54:04 +02:00
parent e7b42dbbf1
commit d838e2fa1b
Signed by: 0x0ade
GPG Key ID: E1960710FE4FBEEF

View File

@ -89,6 +89,9 @@ export default JadefinIntegrity("Transcript", import.meta.url, () => new (class
const worker = detail.worker;
worker.addEventListener("message", this.onSsaAssWorkerMessage.bind(this));
});
this.initHookDocumentAddEventListener();
this.initHookDocumentRemoveEventListener();
}
get isEnabled() {
@ -241,6 +244,45 @@ export default JadefinIntegrity("Transcript", import.meta.url, () => new (class
};
}
initHookDocumentAddEventListener() {
const orig = this._addEventListener = document.addEventListener.bind(document);
document.addEventListener = (type, listener, options) => {
if (type == "wheel") {
const listenerStr = listener.toString();
// Anonymous function in playback-video
if (listenerStr.indexOf("volumeUp") != -1 &&
listenerStr.indexOf("volumeDown") != -1 &&
listenerStr.indexOf("deltaY") != -1) {
this.log.i("Wrapping playback-video wrap listener");
this.log.dir(listener);
const origListener = this._playbackWheel = listener;
listener = this._playbackWheelWrap = (e) => {
if (JadefinUtils.hasParent(e.target, this._osdTranscript)) {
return;
}
return origListener(e);
};
}
}
return orig(type, listener, options);
};
}
initHookDocumentRemoveEventListener() {
const orig = this._removeEventListener = document.removeEventListener.bind(document);
document.removeEventListener = (type, listener, options) => {
if (listener == this._playbackWheel) {
listener = this._playbackWheelWrap;
}
return orig(type, listener, options);
};
}
onSsaAssCanvasAdded() {
const htmlVideoPlayer = this._ssaAssFetching;