https://bbs.tampermonkey.net.cn/forum.php?mod=viewthread&tid=3079&page=2#pid39840
参照[油猴脚本开发指南]操作本地文件,可以读写本地文件了,就想试试上传文件
https://juejin.cn/post/6844904016560783374
https://zhuanlan.zhihu.com/p/31401799
搜索了下资料像是是把file交给input,但不知道怎么写
`// ==UserScript==
// @name 上传图片到百度识图
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author You
// @match https://image.baidu.com/
// ==/UserScript==
(function() {
'use strict';
const button = document.createElement('button');
button.innerText = "点我授权目录";
document.body.firstChild.after(button);
button.addEventListener('click', async function () {
async function getFile() {
// open directory picker
const dirHandle = await window.showDirectoryPicker({mode:"readwrite"});
console.log(dirHandle);
const button2 = document.createElement('button');
button2.innerText = "点我读取目录&写点东西";
document.body.firstChild.after(button2);
button2.addEventListener('click', async function () {
// 读取目录
for await (const item of dirHandle.values()) {
console.log(item)//打开的文件夹只放了一个图片
console.log(1)
$("#stfile").files=item//这里瞎写的,怎么把文件传值给input呢
}
// 写文件
// const fileHandle = await dirHandle.getFileHandle("hello-world.txt", { create: true });
// const writable = await fileHandle.createWritable();
// await writable.write("Hello World!");
// await writable.close();
});
}
getFile();
});
// Your code here...
})();`