// ==UserScript== // @name 4399下载flash游戏 // @description 下载flash游戏 // @version 1.0.0 // @author girl-dream // @license The Unlicense // @namespace https://github.com/girl-dream/ // @icon https://www.4399.com/favicon.ico // @match https://www.4399.com/flash/* // @grant GM_xmlhttpRequest // @run-at document-end // ==/UserScript== (() => { if (str1) { const url = new URL('https:' + webServer + _strGamePath) const download_btn = document.getElementById('down_a') download_btn.title = '双击下载游戏' download_btn.removeAttribute('href') download_btn.style.cursor = 'pointer' download_btn.onclick = () => { download(url) } } function download(url) { GM_xmlhttpRequest({ url: url, method: "GET", responseType: 'blob', onload: function (response) { if (response.status == 200) { const blob = new Blob([response.response]) const url = URL.createObjectURL(blob) let a = document.createElement("a") a.href = url a.download = title + '.swf' a.click() URL.revokeObjectURL(url) } else { alert("下载失败,状态码:" + response.status) } }, onerror: function (error) { alert("请求失败:", error) }, }) } })();