超星云盘文件信息提取器--分享链接

提取云盘文件信息

  1. // ==UserScript==
  2. // @name 超星云盘文件信息提取器--分享链接
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.2
  5. // @description 提取云盘文件信息
  6. // @author 榛铭
  7. // @match https://pan-yz.cldisk.com/external/m/file/*
  8. // @grant none
  9. // @run-at document-start
  10. // @license MIT
  11. // ==/UserScript==
  12.  
  13.  
  14.  
  15. (function() {
  16. 'use strict';
  17.  
  18. const isMobile = /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);
  19. // 通用样式
  20. const styles = {
  21. base: `
  22. background: rgba(255, 255, 255, 0.98);
  23. border-radius: 12px;
  24. transition: all 0.2s ease;
  25. `,
  26. button: `
  27. width: 100%;
  28. border: none;
  29. padding: 10px;
  30. border-radius: 8px;
  31. cursor: pointer;
  32. font-size: 14px;
  33. font-weight: 500;
  34. `
  35. };
  36.  
  37. // 检查文件信息是否存在
  38. const checkExist = setInterval(() => {
  39. if (window.fileinfo) {
  40. clearInterval(checkExist);
  41. createInfoWindow(window.fileinfo);
  42. }
  43. }, 200);
  44.  
  45. setTimeout(() => clearInterval(checkExist), 60000);
  46.  
  47. // 文件大小格式化
  48. const formatSize = bytes => {
  49. if (bytes === 0) return '0 B';
  50. const sizes = ['B', 'KB', 'MB', 'GB', 'TB'];
  51. const i = Math.floor(Math.log(bytes) / Math.log(1024));
  52. return `${(bytes / Math.pow(1024, i)).toFixed(2)} ${sizes[i]}`;
  53. };
  54.  
  55. // 复制到剪贴板
  56. async function copyToClipboard(text) {
  57. try {
  58. if (navigator.clipboard) {
  59. await navigator.clipboard.writeText(text);
  60. return true;
  61. }
  62. const textarea = document.createElement('textarea');
  63. textarea.value = text;
  64. textarea.style.position = 'fixed';
  65. textarea.style.opacity = '0';
  66. document.body.appendChild(textarea);
  67. textarea.select();
  68. const success = document.execCommand('copy');
  69. document.body.removeChild(textarea);
  70. return success;
  71. } catch (err) {
  72. console.error('复制失败:', err);
  73. return false;
  74. }
  75. }
  76.  
  77. // 显示提示
  78. function showTip(tip, isSuccess = true) {
  79. const copyTip = document.querySelector('#copyTip');
  80. copyTip.textContent = tip;
  81. copyTip.style.background = isSuccess ? 'rgba(0, 0, 0, 0.8)' : '#ff4444';
  82. copyTip.style.opacity = '1';
  83. copyTip.style.transform = 'translate(-50%, -50%) scale(1)';
  84. setTimeout(() => {
  85. copyTip.style.opacity = '0';
  86. copyTip.style.transform = 'translate(-50%, -50%) scale(0.8)';
  87. }, 2000);
  88. }
  89.  
  90. // 添加悬停效果
  91. function addHoverEffect(element, defaultColor, hoverColor) {
  92. element.addEventListener('mouseover', () => element.style.background = hoverColor);
  93. element.addEventListener('mouseout', () => element.style.background = defaultColor);
  94. }
  95.  
  96. // 拖拽处理类
  97. class DragHandler {
  98. constructor(element, handle) {
  99. this.element = element;
  100. this.handle = handle;
  101. this.isDragging = false;
  102. this.offset = { x: 0, y: 0 };
  103. this.init();
  104. }
  105.  
  106. init() {
  107. this.handle.addEventListener('mousedown', e => this.dragStart(e));
  108. document.addEventListener('mousemove', e => this.drag(e));
  109. document.addEventListener('mouseup', () => this.dragEnd());
  110. }
  111.  
  112. dragStart(e) {
  113. if (e.target === this.handle || e.target.parentNode === this.handle) {
  114. this.isDragging = true;
  115. this.initial = {
  116. x: e.clientX - this.offset.x,
  117. y: e.clientY - this.offset.y
  118. };
  119. this.element.style.transition = 'none';
  120. this.element.style.boxShadow = '0 4px 20px rgba(0,0,0,0.2)';
  121. }
  122. }
  123.  
  124. drag(e) {
  125. if (this.isDragging) {
  126. e.preventDefault();
  127. this.offset.x = e.clientX - this.initial.x;
  128. this.offset.y = e.clientY - this.initial.y;
  129. this.element.style.right = `${-this.offset.x}px`;
  130. this.element.style.top = `${this.offset.y + 10}px`;
  131. }
  132. }
  133.  
  134. dragEnd() {
  135. if (this.isDragging) {
  136. this.isDragging = false;
  137. this.element.style.transition = 'all 0.3s ease';
  138. this.element.style.boxShadow = '0 2px 10px rgba(0,0,0,0.1)';
  139. }
  140. }
  141. }
  142.  
  143. function createInfoWindow(fileinfo) {
  144. const infoDiv = document.createElement('div');
  145. infoDiv.style.cssText = `
  146. position: fixed;
  147. top: 10px;
  148. right: 10px;
  149. padding: 15px;
  150. z-index: 2147483647;
  151. font-size: 14px;
  152. max-width: 300px;
  153. width: calc(100% - 40px);
  154. border: 1px solid #e0e0e0;
  155. ${!isMobile ? 'cursor: move;' : ''}
  156. user-select: none;
  157. opacity: 0;
  158. transform: translateY(-20px);
  159. backdrop-filter: blur(10px);
  160. ${styles.base}
  161. `;
  162.  
  163. const realDownloadLink = `https://sharewh.chaoxing.com/share/download/${fileinfo.objectId}`;
  164.  
  165. infoDiv.innerHTML = `
  166. <div id="dragHandle" style="
  167. display: flex;
  168. justify-content: space-between;
  169. align-items: center;
  170. margin-bottom: 12px;
  171. ${!isMobile ? 'cursor: move;' : ''}
  172. ">
  173. <span style="font-weight: bold; color: #333;">文件信息</span>
  174. <span id="toggleBtn" style="
  175. cursor: pointer;
  176. padding: 4px 10px;
  177. background: #f5f5f5;
  178. border-radius: 6px;
  179. font-size: 12px;
  180. ${styles.base}
  181. ">收起</span>
  182. </div>
  183. <div id="infoContent">
  184. <div style="
  185. background: #f8f9fa;
  186. padding: 12px;
  187. border-radius: 8px;
  188. margin-bottom: 12px;
  189. font-size: 13px;
  190. line-height: 1.6;
  191. border: 1px solid #eee;
  192. ">
  193. <div><strong>文件名:</strong>${fileinfo.name}</div>
  194. <div><strong>大小:</strong>${formatSize(fileinfo.filesize)}</div>
  195. <div><strong>类型:</strong>${fileinfo.suffix.toUpperCase()}</div>
  196. </div>
  197. <button id="copyBtn" style="
  198. background: #4CAF50;
  199. color: white;
  200. ${styles.button}
  201. ">复制下载链接</button>
  202. </div>
  203. <div id="copyTip" style="
  204. position: fixed;
  205. top: 50%;
  206. left: 50%;
  207. transform: translate(-50%, -50%) scale(0.8);
  208. background: rgba(0, 0, 0, 0.8);
  209. color: white;
  210. padding: 10px 20px;
  211. border-radius: 8px;
  212. font-size: 14px;
  213. opacity: 0;
  214. transition: all 0.3s ease;
  215. pointer-events: none;
  216. z-index: 2147483648;
  217. ">已复制到剪贴板</div>
  218. `;
  219.  
  220. document.body.appendChild(infoDiv);
  221.  
  222. // 显示动画
  223. setTimeout(() => {
  224. infoDiv.style.opacity = '1';
  225. infoDiv.style.transform = 'translateY(0)';
  226. }, 100);
  227.  
  228. const toggleBtn = infoDiv.querySelector('#toggleBtn');
  229. const copyBtn = infoDiv.querySelector('#copyBtn');
  230. const infoContent = infoDiv.querySelector('#infoContent');
  231.  
  232. // 添加悬停效果
  233. addHoverEffect(toggleBtn, '#f5f5f5', '#e9ecef');
  234. addHoverEffect(copyBtn, '#4CAF50', '#45a049');
  235.  
  236. // 拖拽功能
  237. if (!isMobile) {
  238. new DragHandler(infoDiv, infoDiv.querySelector('#dragHandle'));
  239. }
  240.  
  241. // ��开/收起功能
  242. let isCollapsed = false;
  243. toggleBtn.addEventListener('click', () => {
  244. isCollapsed = !isCollapsed;
  245. infoContent.style.opacity = isCollapsed ? '0' : '1';
  246. infoContent.style.transform = isCollapsed ? 'translateY(-10px)' : 'translateY(0)';
  247. infoContent.style.display = isCollapsed ? 'none' : 'block';
  248. toggleBtn.textContent = isCollapsed ? '展开' : '收起';
  249. if (!isCollapsed) {
  250. infoContent.style.display = 'block';
  251. setTimeout(() => {
  252. infoContent.style.opacity = '1';
  253. infoContent.style.transform = 'translateY(0)';
  254. }, 10);
  255. }
  256. });
  257.  
  258. // 复制功能
  259. copyBtn.addEventListener('click', async () => {
  260. const success = await copyToClipboard(realDownloadLink);
  261. showTip(success ? '已复制到剪贴板' : '复制失败', success);
  262. });
  263. }
  264. })();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址