mirror of
https://github.com/redphx/better-xcloud.git
synced 2025-06-07 08:07:18 +02:00
Add "detectBrowserRouterReady" patch
This commit is contained in:
parent
5db35cdcc9
commit
39f7ee6ddb
@ -892,6 +892,26 @@ if (this.baseStorageKey in window.BX_EXPOSED.overrideSettings) {
|
|||||||
str = str.substring(0, index) + 'BxEvent.dispatch(window, BxEvent.XCLOUD_RENDERING_COMPONENT, {component: "product-details"});' + str.substring(index);
|
str = str.substring(0, index) + 'BxEvent.dispatch(window, BxEvent.XCLOUD_RENDERING_COMPONENT, {component: "product-details"});' + str.substring(index);
|
||||||
return str;
|
return str;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
detectBrowserRouterReady(str: string) {
|
||||||
|
const text = 'BrowserRouter:()=>';
|
||||||
|
if (!str.includes(text)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
let index = str.indexOf('{history:this.history,');
|
||||||
|
if (index < 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
index = PatcherUtils.lastIndexOf(str, 'return', index, 100);
|
||||||
|
if (index < 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
str = PatcherUtils.insertAt(str, index, 'window.BxEvent.dispatch(window, window.BxEvent.XCLOUD_ROUTER_HISTORY_READY, {history: this.history});');
|
||||||
|
return str;
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
let PATCH_ORDERS: PatchArray = [
|
let PATCH_ORDERS: PatchArray = [
|
||||||
@ -902,6 +922,7 @@ let PATCH_ORDERS: PatchArray = [
|
|||||||
'exposeInputSink',
|
'exposeInputSink',
|
||||||
] : []),
|
] : []),
|
||||||
|
|
||||||
|
'detectBrowserRouterReady',
|
||||||
'patchRequestInfoCrash',
|
'patchRequestInfoCrash',
|
||||||
|
|
||||||
'disableStreamGate',
|
'disableStreamGate',
|
||||||
@ -1097,7 +1118,7 @@ export class Patcher {
|
|||||||
item[1][id] = eval(patchedFuncStr);
|
item[1][id] = eval(patchedFuncStr);
|
||||||
} catch (e: unknown) {
|
} catch (e: unknown) {
|
||||||
if (e instanceof Error) {
|
if (e instanceof Error) {
|
||||||
BxLogger.error(LOG_TAG, 'Error', appliedPatches, e.message);
|
BxLogger.error(LOG_TAG, 'Error', appliedPatches, e.message, patchedFuncStr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -53,6 +53,8 @@ export namespace BxEvent {
|
|||||||
|
|
||||||
export const XCLOUD_RENDERING_COMPONENT = 'bx-xcloud-rendering-page';
|
export const XCLOUD_RENDERING_COMPONENT = 'bx-xcloud-rendering-page';
|
||||||
|
|
||||||
|
export const XCLOUD_ROUTER_HISTORY_READY = 'bx-xcloud-router-history-ready';
|
||||||
|
|
||||||
export function dispatch(target: Element | Window | null, eventName: string, data?: any) {
|
export function dispatch(target: Element | Window | null, eventName: string, data?: any) {
|
||||||
if (!target) {
|
if (!target) {
|
||||||
return;
|
return;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user