Skip to content

Commit

Permalink
🐛 处理GM.xmlHttpRequest h大写的问题 #26
Browse files Browse the repository at this point in the history
  • Loading branch information
CodFrm committed Jan 10, 2022
1 parent 2096137 commit 5ebf3aa
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/apps/grant/background.ts
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,7 @@ export class BackgroundGrant {
resolve(ret);
});
},
alias: ['GM.fetch'],
alias: ['GM.fetch', 'GM.xmlHttpRequest'],
})
protected GM_xmlhttpRequest(grant: Grant, post: IPostMessage): Promise<any> {
return new Promise((resolve, reject) => {
Expand Down
6 changes: 5 additions & 1 deletion src/apps/grant/frontend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,12 @@ export class FrontendGrant implements ScriptContext {
param: param
});
// 兼容GM.*
const dot = key.replace('_', '.');
let dot = key.replace('_', '.');
if (dot != key) {
// 特殊处理GM.xmlHttpRequest
if (dot == 'GM.xmlhttpRequest') {
dot = 'GM.xmlHttpRequest';
}
FrontendGrant.apis.set(dot, {
api: descriptor.value,
param: param
Expand Down

0 comments on commit 5ebf3aa

Please sign in to comment.