Quantumult X 重写脚本 可以引用第三方包吗

210 天前
 emtry
需求:重写一个 xlsx 里的数据
发现不能直接像在 node 中 require('xlsx')


曲线救国,只能把整一个改好的 xlsx 重写

const url = "https://github.com/xxx/xxx.xlsx";
const myRequest = {
url: url
};

$task.fetch(myRequest).then(response => {
$done({bodyBytes: response.bodyBytes});
}, reason => {
$done();
});

不知道还有没有更好的方法,毕竟 xlsx 文件会更新
770 次点击
所在节点    Apple
4 条回复
luckycatio
210 天前
借楼问一下,quanx 能把 vconsole 注入到网页吗
napsterwu
210 天前
@luckycatio 把 html 页的请求拦截掉,然后替换

$task.fetch($request).then($response => {
let body = $response.body
body = body.replace('<head>', '<head><script src="https://unpkg.com/vconsole@latest/dist/vconsole.min.js"></script><script>var vConsole = new window.VConsole();</script>')
delete $response.headers['Content-Length']
$done(body)
})
emtry
209 天前
@napsterwu 好思路
ODD10
196 天前
@napsterwu 有个问题,就是非 utf-8 编码的网页会乱码

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/981048

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX