Stop using MutationObserver in stream-ui

This commit is contained in:
redphx
2025-02-07 17:31:30 +07:00
parent 85339f09da
commit ac20cc51cc
6 changed files with 133 additions and 170 deletions

View File

@@ -1156,6 +1156,18 @@ ${subsVar} = subs;
str = PatcherUtils.insertAt(str, index, newCode);
return str;
},
injectStreamMenuUseEffect(str: string) {
let index = str.indexOf('"StreamMenu-module__container');
index > -1 && (index = PatcherUtils.lastIndexOf(str, 'return', index, 200));
if (index < 0) {
return false;
}
const newCode = `window.BX_EXPOSED.reactUseEffect(() => window.BxEventBus.Stream.emit('ui.streamMenu.rendered', {}));`;
str = PatcherUtils.insertAt(str, index, newCode);
return str;
},
};
let PATCH_ORDERS = PatcherUtils.filterPatches([
@@ -1265,6 +1277,8 @@ let STREAM_PAGE_PATCH_ORDERS = PatcherUtils.filterPatches([
'alwaysShowStreamHud',
'injectStreamMenuUseEffect',
// 'exposeEventTarget',
// Patch volume control for normal stream