Skip to content

0.10.x 貌似ajax有问题? #108

@hhuimie

Description

@hhuimie

你好,
同样的脚本, 在0.9.1上正常执行
但是0.10.x上不会执行then的内容, 但是看网络请求是正常的, 不知道是不是responseType:'arraybuffer'出的问题

// ==UserScript==
// @name         New Userscript
// @namespace    https://bbs.tampermonkey.net.cn/
// @version      0.1.0
// @description  try to take over the world!
// @author       You
// @require      https://cdn.jsdelivr.net/npm/scriptcat-lib@1.1.1/dist/gm.js
// @definition   https://cdn.jsdelivr.net/npm/scriptcat-lib@1.1.1/src/types/gm.d.ts
// @grant        GM_xmlhttpRequest
// @grant        GM_log
// @grant        GM_setValue
// @grant        GM_getValue
// @background
// @connect      https://s1.ax1x.com
// ==/UserScript==

let done;
gm.ajax({method:'get',url:'https://s1.ax1x.com/2022/05/26/XEW4te.png', responseType:'arraybuffer'})
    .then(resp=>{
        // 0.10.x, 这下面的代码不会执行
        let count = GM_getValue('count',0);
        GM_log(count++);
        GM_setValue('count',count);
        GM_log(JSON.stringify(resp).substr(0,1000));
        console.log(resp);
        done();
    }).catch(e=>{
        let count = GM_getValue('count',0);
        GM_log(count++);
        GM_setValue('count',count);
        done();
    });
return new Promise((resolve, reject) => {
    // Your code here...
    done = resolve;
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions