Lazaru5
V2EX  ›  Apple

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

  •  
  •   Lazaru5 · Oct 11, 2023 · 2519 views
    This topic created in 1118 days ago, the information mentioned may be changed or developed.
    需求:重写一个 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 文件会更新
    4 replies  •  2023-10-25 03:07:46 +08:00
    luckycatio
    luckycatio
    Oct 11, 2023 via iPhone
    1
    借楼问一下,quanx 能把 vconsole 注入到网页吗
    orcusfox
    orcusfox
    Oct 11, 2023 via iPhone
    2
    @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)
    })
    Lazaru5
    Lazaru5
    OP
    Oct 12, 2023
    3
    @napsterwu 好思路
    uTOmOuk3L6sb4MSI
    uTOmOuk3L6sb4MSI
    Oct 25, 2023 via iPhone
    4
    @napsterwu 有个问题,就是非 utf-8 编码的网页会乱码
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   1375 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 83ms · UTC 22:09 · PVG 06:09 · LAX 14:09 · JFK 17:09
    ♥ Do have faith in what you're doing.