Greasy Fork is available in English.

GM_fetch

fetch pollyfill using GM_xmlhttpRequest

Script này sẽ không được không được cài đặt trực tiếp. Nó là một thư viện cho các script khác để bao gồm các chỉ thị meta // @require https://update.greasyfork.org/scripts/421384/1134973/GM_fetch.js

Tác giả
nyarau
Phiên bản
0.0.1.20230104124032
Đã tạo
07-02-2021
Đã cập nhật
04-01-2023
Giấy phép
N/A

fetch pollyfill using GM_xmlhttpRequest, not yet 100% replication of fetch API (eg. errors)

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")
})