GM_DL

GM_download but it actually works

目前為 2025-01-11 提交的版本,檢視 最新版本

此腳本不應該直接安裝,它是一個供其他腳本使用的函式庫。欲使用本函式庫,請在腳本 metadata 寫上: // @require https://update.gf.qytechs.cn/scripts/523457/1518870/GM_DL.js

// ==UserScript==
// @name        GM_DL
// @namespace   Violentmonkey Scripts
// @grant       GM.xmlHttpRequest
// @version     1.0
// @author      https://gf.qytechs.cn/en/users/1409235-paywalldespiser
// @description GM_download but it actually works
// @license     MIT
// @require     https://cdn.jsdelivr.net/npm/[email protected]/dist/FileSaver.min.js
// ==/UserScript==

/**
 * Description placeholder
 *
 * @param {{ url: string | URL; data?: string; headers?: { [key: string]: string }; filename: string; method?: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH' | 'HEAD' | 'TRACE' | 'OPTIONS' | 'CONNECT' = ['GET']; }}
 * @returns {Promise<void>}
 */
function GM_DL({ url, filename, method = 'GET', data, headers }) {
    return GM.xmlHttpRequest({
        url,
        method,
        responseType: 'blob',
        data,
        headers,
    }).then(({ response }) => saveAs(response, filename));
}

QingJ © 2025

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