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/[email protected]/dist/gm.js
// @definition   https://cdn.jsdelivr.net/npm/[email protected]/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