Skip to content

Commit 5ebf3aa

Browse files
committed
🐛 处理GM.xmlHttpRequest h大写的问题 #26
1 parent 2096137 commit 5ebf3aa

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

src/apps/grant/background.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -502,7 +502,7 @@ export class BackgroundGrant {
502502
resolve(ret);
503503
});
504504
},
505-
alias: ['GM.fetch'],
505+
alias: ['GM.fetch', 'GM.xmlHttpRequest'],
506506
})
507507
protected GM_xmlhttpRequest(grant: Grant, post: IPostMessage): Promise<any> {
508508
return new Promise((resolve, reject) => {

src/apps/grant/frontend.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,12 @@ export class FrontendGrant implements ScriptContext {
6868
param: param
6969
});
7070
// 兼容GM.*
71-
const dot = key.replace('_', '.');
71+
let dot = key.replace('_', '.');
7272
if (dot != key) {
73+
// 特殊处理GM.xmlHttpRequest
74+
if (dot == 'GM.xmlhttpRequest') {
75+
dot = 'GM.xmlHttpRequest';
76+
}
7377
FrontendGrant.apis.set(dot, {
7478
api: descriptor.value,
7579
param: param

0 commit comments

Comments
 (0)