Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: GM.xmlHttpRequest is not a function #26

Closed
ChitaGideon opened this issue Jan 9, 2022 · 6 comments
Closed

TypeError: GM.xmlHttpRequest is not a function #26

ChitaGideon opened this issue Jan 9, 2022 · 6 comments

Comments

@ChitaGideon
Copy link

很多脚本都是GM.xmlHttpRequest,目前看起来scriptcat 还不太支持?

@CodFrm
Copy link
Member

CodFrm commented Jan 9, 2022

怎么说。。。用的是GM_xmlhttpRequest 这些别名没有弄,gm函数的规则太乱了,很想给他统一和优化,但是现在没那个量级,打算先写一个lib用来优化:https://github.com/scriptscat/lib/blob/main/src/gm/README.md

哥哥可以发一个脚本看看

@ChitaGideon
Copy link
Author

https://github.com/Trim21/axios-userscript-adapter

我是在用别人的库发现的。

@CodFrm
Copy link
Member

CodFrm commented Jan 10, 2022

https://github.com/Trim21/axios-userscript-adapter#requirements

看起来也可以声明GM_xmlhttpRequest

@ChitaGideon
Copy link
Author

实际上却不行,至少她的例子是跑不通的

// ==UserScript==
// @name        new user script
// @namespace   https://trim21.me/
// @description hello
// @version     0.0.1
// @author      Trim21 <trim21me@gmail.com>
// @match       http*://*/*
// @require     https://cdn.jsdelivr.net/npm/axios@^0.22.0/dist/axios.min.js
// @require     https://cdn.jsdelivr.net/npm/axios-userscript-adapter@~0.1.7/dist/axiosGmxhrAdapter.min.js
// @grant       GM.xmlHttpRequest
// @run-at      document-end
// @connect     httpbin.org
// ==/UserScript==

console.log(axios.defaults.adapter);
axios.defaults.adapter = axiosGmxhrAdapter;

axios.get("https://httpbin.org/headers").then((res) => console.log(res.data));

@CodFrm
Copy link
Member

CodFrm commented Jan 10, 2022

好吧,下个版本兼容一下

@CodFrm
Copy link
Member

CodFrm commented Jan 10, 2022

`7Q@%W{UC6@9)DNJ %OQ~AS

修复 5ebf3aa

@CodFrm CodFrm closed this as completed Jan 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants