GM_fetch

fetch pollyfill using GM_xmlhttpRequest

目前为 2021-02-07 提交的版本。查看 最新版本

此脚本不应直接安装,它是一个供其他脚本使用的外部库。如果您需要使用该库,请在脚本元属性加入:// @require https://update.gf.qytechs.cn/scripts/421384/898562/GM_fetch.js

作者
nyarau
版本
0.0.1.20210207152600
创建于
2021-02-07
更新于
2021-02-07
大小
1.2 KB
许可证
暂无

(personal uses, with no guarantee what so ever)

fetch pollyfill with resp.text/resp.json/resp.blob/resp.arrayBuffer support using GM_xmlhttpRequest, not yet 100% replication of fetch API (eg. errors)

Written for / tested with TamperMonkey, may work for GeaseMonkey or others

Don't forget to add permissions

// @grant    GM_xmlhttpRequest
// @connect  api.example.com

Example

GM_fetch("https://api.example.com/favicon.png", {
    method: 'POST',
    body: JSON.stringify({message: "hello world"}),
    headers: { 'Content-Type': 'application/json' }
}).then(resp=>resp.blob()).then(blob=>{
    open(URL.createObjectURL(blob), "_blank")
})

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址