网页上传文件 非公开

涛涛涛 更新于 1天7小时前 | 0 | (0) | 2
分类
点赞
暂无
更多信息
分享人 涛涛涛
分享时间 4天1小时前
最后更新 1天7小时前
修订版本 3
子程序大小 6.8 KB
Quicker版本 1.44.10.0

介绍

网页上传文件

将quicker浏览器插件下载到本地

把插件中quickerconnector_1.0.1\background\background.js文件的函数替换一下

再浏览器加载这是另一种文件上传方法,本质是一种方法

//文件上传函数

   async function 文件上传(e) {

        let {target: t, selector: r, files: o} = e

          , n = await Pe(t)

          , a = !1;

        try {

            a = (await chrome.debugger.getTargets()).some(u => u.tabId === n.tabId && u.attached),

            a || await chrome.debugger.attach(n, "1.3");

            let l = await chrome.debugger.sendCommand(n, "DOM.getDocument", {});

            l = await chrome.debugger.sendCommand(n,"DOM.querySelector", {"nodeId": l.root.nodeId,"selector":r});

            await chrome.debugger.sendCommand(n, "DOM.setFileInputFiles", {"nodeId":l.nodeId,"files":o});

            return a || await chrome.debugger.detach(n), l

        } catch (s) {

            if (!a)

                try {

                    await chrome.debugger.detach(n)

                } catch (l) {

                    console.error("\u5206\u79BB\u8C03\u8BD5\u5668\u65F6\u51FA\u9519:", l)

                }

            throw s

        }

    }

//参数说明

target: 调试目标

selector: 文件框css选择器

files: 需要上传文件的路径数组

//参数示例

{

  "target": {"tabId": 123},

  "selector": "#fileInput",

  "files":["C:/Users/Administrator/Desktop/js脚本.txt"]

}

子程序的参数

输入
选项 Text
tab页tabId Text
文件框selector Text
文件路径 List
输出
text 默认的文本变量 Text

最近更新

修订版本 更新时间 更新说明
3 1天7小时前 优化一下多文件路径的转化问题
2 2天21小时前 更新
1 2天22小时前 加了一个返回值

最近讨论

暂无讨论