1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
| /* * @?: ********************************************************************* * @Author: Weidows * @Date: 2021-07-07 20:30:59 * @LastEditors: Weidows * @LastEditTime: 2021-07-09 00:05:15 * @FilePath: \awesome-image-collector\implements\SM.MS-collector.js * @Description: * @!: ********************************************************************* */
(async () => { // 引入库函数 const jsZip = document.createElement("script"), collector = document.createElement("script"); jsZip.src = "https://cdn.bootcdn.net/ajax/libs/jszip/3.5.0/jszip.min.js"; collector.src = "https://cdn.jsdelivr.net/gh/Weidows-projects/awesome-image-collector@master/dist/collector.min.js"; document .getElementsByTagName("head")[0] .appendChild(jsZip) .appendChild(collector);
await Promise.all([ new Promise(resolve => jsZip.onload = () => window.JSZip && resolve()), new Promise(resolve => collector.onload = () => window.start && resolve()), ]); smmsCollector(); })();
// ======================== 添加样式 ======================== function smmsCollector() { // 下载图片按钮 (不主动下载,按按钮时才下载) let downloadButton = document.createElement("button"); downloadButton.type = "button"; downloadButton.innerText = "下载本页面图片"; downloadButton.style.width = "100%"; downloadButton.addEventListener("click", function () { // 调用入口函数 start(document.getElementsByClassName("fancybox")); });
// 全选CheckBox按钮 let deleteButton = document.createElement("button"); deleteButton.type = "button"; deleteButton.innerHTML = "全选CheckBox按钮"; deleteButton.style.width = "100%"; deleteButton.addEventListener("click", function () { let checkBoxes = document.getElementsByClassName("filedelete"); for (const checkbox of checkBoxes) { checkbox.checked = !checkbox.checked; } });
// 创建标签 let downloadLi = document.createElement("li"); let deleteLi = document.createElement("li"); downloadLi.id = "downloader"; deleteLi.id = "deleter"; downloadLi.appendChild(downloadButton); deleteLi.appendChild(deleteButton);
// 追加标签 if (document.getElementById("downloader") == null) { document .getElementsByClassName("sidebar-menu tree")[0] .appendChild(downloadLi); document .getElementsByClassName("sidebar-menu tree")[0] .appendChild(deleteLi); } }
|