Skip to content

Commit

Permalink
fix: responseType
Browse files Browse the repository at this point in the history
  • Loading branch information
lisonge committed Nov 11, 2024
1 parent c4ff2e8 commit 218b39a
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions src/utils/gm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,6 @@ export const GM_fetch = async (
const method = request.method.toUpperCase();
const url = fixUrl(request.url);

// temporarily fix tampermonkey bug
let responseType: 'blob' | undefined = undefined;
if (url.startsWith('https://github.com/user-attachments/files/')) {
responseType = 'blob';
}

// headers
const sendHeaders = new Headers(request.headers);
new Headers(init.headers).forEach((value, key) => {
Expand All @@ -105,7 +99,7 @@ export const GM_fetch = async (
let binary = false;
let data: URLSearchParams | FormData | Blob | string | undefined = undefined;

if (method != 'GET') {
if (method !== 'GET') {
if (init.body) {
if (
typeof init.body == 'string' ||
Expand All @@ -128,8 +122,10 @@ export const GM_fetch = async (
headers: headers2obj(sendHeaders),
data,
binary,
responseType,
// temporarily fix tampermonkey bug when post github api
responseType: method === 'GET' ? 'blob' : undefined,
async onload(e) {
console.log(e);
await delay();
let useNull = false;
if (e.response instanceof Blob) {
Expand Down

0 comments on commit 218b39a

Please sign in to comment.