2023年01月21日
批量的操作阿里云OSS中的资源,获取图片资源的链接
window.testList = [];
const timeOut = async (time, condition, action) =>
new Promise((r, j) => {
let timer = setInterval(() => {
try {
const result = condition && condition();
if (!result) {
clearInterval(timer);
r();
} else {
action && action();
}
} catch (error) {
j(error);
}
}, time);
});
const list = [
...document
.querySelector(".xcomponent-table-body")
.querySelectorAll(".xcomponent-btn-helper"),
].filter((item) => item.innerText === "详情");
for (let i = 0, len = list.length; i < len; i++) {
const item = list[i];
item.click();
console.log(`序号${i}:`, "start");
let isItemNotOver = true;
await timeOut(
500,
() => isItemNotOver,
() => {
console.log(`序号${i}:`, "action");
const result = document.querySelector(".object-preview-object-url");
if (result && result.innerText) {
window.testList.push(result.innerText);
result.innerText = "";
isItemNotOver = false;
}
}
);
document.querySelector(".xcomponent-icon-close").click();
await timeOut(3000);
console.log(`序号${i}:`, "end");
}
静态资源的随机图片链接
https://source.unsplash.com/900x900/?christmas,holiday,festive
上次更新时间: 10年18月2023日 01时57分53秒