Created
November 19, 2024 05:54
-
-
Save lisonge/615d05ac778880c305c1072011d3c7b5 to your computer and use it in GitHub Desktop.
test.gm.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
interface GmResponseTypeMap { | |
text: string; | |
json: any; | |
arraybuffer: ArrayBuffer; | |
blob: Blob; | |
document: Document; | |
stream: ReadableStream<Uint8Array>; | |
} | |
type GmResponseType = keyof GmResponseTypeMap; | |
export interface GmResponseEvent<R extends GmResponseType, TContext> { | |
response: GmResponseTypeMap[R]; | |
context: TContext; | |
} | |
interface GmReponseEventListener<Event> { | |
(this: Event, event: Event): void; | |
} | |
interface GmXmlhttpRequestOption<R extends GmResponseType, TContext = any> { | |
responseType?: R; | |
context?: TContext; | |
onload?: GmReponseEventListener<GmResponseEvent<R, TContext>>; | |
} | |
interface GmXmlhttpRequestType { | |
<R extends GmResponseType, TContext = any>( | |
details: GmXmlhttpRequestOption<R, TContext>, | |
): void; | |
} | |
declare const GM_xmlhttpRequest: GmXmlhttpRequestType; | |
GM_xmlhttpRequest({ | |
responseType: 'arraybuffer', | |
onload: (r) => { | |
r.response; | |
}, | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment