-
Notifications
You must be signed in to change notification settings - Fork 117
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
[BUG]后台脚本无法使用xlsx导出数据文件? #25
Comments
这和后台脚本的运行环境有关系,后台脚本运行在一个沙盒里面,没有document对象,导致无法打开下载请求,准备新增一个API以供这些文件的下载 |
// ==UserScript==
// @name New Userscript
// @namespace https://bbs.tampermonkey.net.cn/
// @version 0.1.0
// @description try to take over the world!
// @author You
// @background
// @require https://cdn.bootcdn.net/ajax/libs/xlsx/0.17.4/xlsx.full.min.js
// @grant GM_download
// ==/UserScript==
return new Promise((resolve, reject) => {
let output = [
{ name: 'John', Age: 18 },
{ name: 'Mike', Age: 20 }
];
let o = XLSX.utils.json_to_sheet(output);
let wb = XLSX.utils.book_new();
XLSX.utils.book_append_sheet(wb, o, 'Sheet1');
GM_download({
url: XLSX.write(wb, { type: 'file' }),
name: '1.xlsx',
onload() {
resolve();
}
});
}); 0.8.0新增 可以先手动下载安装,也可等待商店更新(一周左右) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
chrome版本: 97.0.4692.71(正式版本) (64 位)
脚本猫版本: 0.7.7
以下测试脚本, 在脚本猫的
后台脚本
中无法生成文件, 在普通脚本
中可以脚本:
The text was updated successfully, but these errors were encountered: