// ==UserScript== // @name 阿里云盘-批量修改文件名 // @namespace http://tampermonkey.net/ // @version 2.04.01 // @description 用于阿里云盘批量修改文件名,主要为剧集刮削准备 // @author wdwy // @modify_user alone // @match https://www.aliyundrive.com/drive/folder/* // @match https://www.aliyundrive.com/drive/* // @match https://www.aliyundrive.com/drive/legacy/folder/* // @match https://www.aliyundrive.com/drive/legacy/ // @match https://www.aliyundrive.com/drive/file/backup/* // @match https://www.aliyundrive.com/drive/file/backup/ // @icon https://gw.alicdn.com/imgextra/i3/O1CN01aj9rdD1GS0E8io11t_!!6000000000620-73-tps-16-16.ico // @require https://cdn.staticfile.org/jquery/3.6.0/jquery.min.js // @run-at document-body // @license GPLv3 // @downloadURL https://update.greasyfork.icu/scripts/483306/%E9%98%BF%E9%87%8C%E4%BA%91%E7%9B%98-%E6%89%B9%E9%87%8F%E4%BF%AE%E6%94%B9%E6%96%87%E4%BB%B6%E5%90%8D.user.js // @updateURL https://update.greasyfork.icu/scripts/483306/%E9%98%BF%E9%87%8C%E4%BA%91%E7%9B%98-%E6%89%B9%E9%87%8F%E4%BF%AE%E6%94%B9%E6%96%87%E4%BB%B6%E5%90%8D.meta.js // ==/UserScript== (function() { 'use strict'; var $ = $ || window.$; var obj = { files: [], randomFillParam: -1, url: location.href, panel: 1 }; var base = { dom : { grid: "[class^=\"node-list-grid-view--\"]", list: "[class^=\"node-list-table-view--\"]", switch: "[class^=\"switch-wrapper--\"]" }, getSelectedList() { try { let selectedList = []; let reactDom = document.querySelector(base.dom.list); let reactObj = base.findReact(reactDom, 1); let props = reactObj.pendingProps; if (props) { let fileList = props.dataSource || []; let selectedKeys = props.selectedKeys.split(','); fileList.forEach((val) => { if (selectedKeys.includes(val.fileId)) { selectedList.push(val); } }); } return selectedList; } catch (e) { console.error('查找选中文件失败'); return []; } }, isOnlyFolder(selectList) { for (let i = 0; i < selectList.length; i++) { if (selectList[i].type === 'file') return false; } return true; }, findReact(dom, traverseUp = 0) { const key = Object.keys(dom).find(key => { return key.startsWith("__reactFiber$") || key.startsWith("__reactInternalInstance$"); }); const domFiber = dom[key]; if (domFiber == null) return null; if (domFiber._currentElement) { let compFiber = domFiber._currentElement._owner; for (let i = 0; i < traverseUp; i++) { compFiber = compFiber._currentElement._owner; } return compFiber._instance; } const GetCompFiber = fiber => { let parentFiber = fiber.return; while (typeof parentFiber.type == "string") { parentFiber = parentFiber.return; } return parentFiber; }; let compFiber = GetCompFiber(domFiber); for (let i = 0; i < traverseUp; i++) { compFiber = GetCompFiber(compFiber); } return compFiber.stateNode || compFiber; }, }; var op1 = `