mirror of
https://github.com/samuelthomas2774/nxapi.git
synced 2026-03-21 18:04:10 -05:00
Add support for triggering a refresh in SplatNet 3 by pressing Cmd+R/Ctrl+R
This commit is contained in:
parent
e3b967a412
commit
b6099a7d18
|
|
@ -6,6 +6,7 @@ const debug = createDebug('app:preload-webservice');
|
|||
import './znca-js-api.js';
|
||||
import './quirks/splatnet2.js';
|
||||
import './quirks/nooklink.js';
|
||||
import './quirks/splatnet3.js';
|
||||
|
||||
const style = window.document.createElement('style');
|
||||
|
||||
|
|
|
|||
28
src/app/preload-webservice/quirks/splatnet3.ts
Normal file
28
src/app/preload-webservice/quirks/splatnet3.ts
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
import createDebug from 'debug';
|
||||
import { events, webservice } from '../ipc.js';
|
||||
|
||||
const debug = createDebug('app:preload-webservice:quirks:splatnet3');
|
||||
|
||||
const SPLATNET3_WEBSERVICE_ID = 4834290508791808;
|
||||
|
||||
if (webservice.id === SPLATNET3_WEBSERVICE_ID) {
|
||||
events.on('window:refresh', () => {
|
||||
const pulltorefresh_container = document.querySelector<HTMLElement>('[class*=PullToRefresh_container]');
|
||||
debug('PullToRefresh container HTMLElement', pulltorefresh_container);
|
||||
if (!pulltorefresh_container) return location.reload();
|
||||
|
||||
const keys = Object.keys(pulltorefresh_container) as (keyof typeof pulltorefresh_container)[];
|
||||
const react_fiber: any = pulltorefresh_container[keys.find(k => k.startsWith('__reactFiber$'))!];
|
||||
debug('PullToRefresh container React fiber', react_fiber);
|
||||
if (!react_fiber) return location.reload();
|
||||
|
||||
try {
|
||||
const props = react_fiber.return.return.memoizedProps;
|
||||
debug('PullToRefresh root props', props);
|
||||
props.onRefresh.call(null);
|
||||
} catch (err) {
|
||||
debug('Error triggering refresh, forcing full page reload', err);
|
||||
location.reload();
|
||||
}
|
||||
});
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user