Fix "patchStreamHud" patch

This commit is contained in:
redphx
2025-05-29 08:16:29 +07:00
parent 62cf045f05
commit c829f74dcc
4 changed files with 47 additions and 21 deletions

View File

@@ -389,20 +389,35 @@ if (titleInfo && !titleInfo.details.hasTouchSupport && !titleInfo.details.hasFak
},
patchStreamHud(str: string) {
let index = str.indexOf('let{onCollapse');
let index = str.indexOf('({onCollapse:');
if (index < 0) {
return false;
}
let newCode = codeStreamHud;
try {
const canShowTakHUDVar = PatcherUtils.getVariableNameAfter(str, PatcherUtils.indexOf(str, 'canShowTakHUD', index, 500, true) + 1);
const guideUIVar = PatcherUtils.getVariableNameAfter(str, PatcherUtils.indexOf(str, 'guideUI', index, 500, true) + 1);
const onShowStreamMenuVar = PatcherUtils.getVariableNameAfter(str, PatcherUtils.indexOf(str, 'onShowStreamMenu', index, 500, true) + 1);
const offsetVar = PatcherUtils.getVariableNameAfter(str, PatcherUtils.indexOf(str, 'offset', index, 500, true) + 1);
// Remove the TAK Edit button when the touch controller is disabled
if (getGlobalPref(GlobalPref.TOUCH_CONTROLLER_MODE) === TouchControllerMode.OFF) {
newCode += 'options.canShowTakHUD = false;';
let newCode = renderString(codeStreamHud, {
guideUI: guideUIVar,
onShowStreamMenu: onShowStreamMenuVar,
offset: offsetVar,
});
// Remove the TAK Edit button when the touch controller is disabled
if (getGlobalPref(GlobalPref.TOUCH_CONTROLLER_MODE) === TouchControllerMode.OFF) {
newCode += `${canShowTakHUDVar} = false;`;
}
const bracketIndex = PatcherUtils.indexOf(str, '}){', index, 500, true);
str = PatcherUtils.insertAt(str, bracketIndex, newCode);
return str;
} catch (e) {
return false;
}
str = PatcherUtils.insertAt(str, index, newCode);
return str;
},
broadcastPollingMode(str: string) {

View File

@@ -1,13 +1,13 @@
// @ts-ignore
declare const arguments: any;
const options = arguments[0];
declare let $guideUI$: any;
declare const $onShowStreamMenu$: any;
declare const $offset$: any;
// Expose onShowStreamMenu
window.BX_EXPOSED.showStreamMenu = options.onShowStreamMenu;
window.BX_EXPOSED.showStreamMenu = $onShowStreamMenu$;
// Restore the "..." button
options.guideUI = null;
$guideUI$ = null;
window.BX_EXPOSED.reactUseEffect(() => {
window.BxEventBus.Stream.emit('ui.streamHud.rendered', { expanded: options.offset.x === 0 });
window.BxEventBus.Stream.emit('ui.streamHud.rendered', { expanded: $offset$.x === 0 });
});