您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
PikePak 为导航和文件列表添加新标签页打开按钮、复制文件/文件夹名按钮 Open in new tab, Copy file/folder name
当前为
// ==UserScript== // @name PikPak 更多交互功能 新标签页打开 复制文件/文件夹名 More interactive function // @namespace https://gf.qytechs.cn/zh-CN/users/722555-vveishu // @version 2.1.4 // @description PikePak 为导航和文件列表添加新标签页打开按钮、复制文件/文件夹名按钮 Open in new tab, Copy file/folder name // @author vvei // @match https://mypikpak.com/s/* // @icon http://mypikpak.com/favicon.ico // @grant none // @require https://code.jquery.com/jquery-3.7.1.slim.min.js // @run-at document-end // ==/UserScript== (function ($) { 'use strict'; // 添加 Material Symbols Outlined 样式表 $('head').append( $('<link>', { rel: 'stylesheet', href: 'https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@24,400,0,0&icon_names=content_copy,open_in_new' }) ); // 添加 CSS 样式 $('<style>').text(` .folder-navigator{ >ul>li>.pp-link-button{ padding-right: 0; } .copy-name{ font-size: 1.5em; } .open_in_new{ font-size: 1.5em; height: 36px; min-width: 1em; margin: 0 8px; align-items: center; line-height: 36px; text-decoration: none; } } .custom-alert { position: fixed; padding: 3px 0.5em; background: #333C; color: #fff; border: 1px solid #5f5; border-radius: 5px; z-index: 9000; box-shadow: 0 0 10px rgba(0, 0, 0, 0.5); } .grid-operation.folder-CM8m{ display:block!important; >.pp-link-button>.pp-icon{ color: #000!important; } >.pp-link-button.pp-link-button.pp-link-button { top: 40px; background-color: #fff7; } >.open_in_new { position: absolute; min-width: 24px; height: 24px; top: 8px; right: 8px; } } `).appendTo('head'); const $canonical = $('link[rel="canonical"]').attr('href'); // 执行时间 // 延迟执行 setTimeout(() => { // 初始化处理 const $navLis = $('.folder-navigator > ul').first().children('li') const $grids = $('.file-list').first().find('.grid') navCopys($navLis); fileCopy($grids); navAddLink($navLis); fileListAddLink($grids); // 监听导航列表变化 new MutationObserver(mutations => { mutations.forEach(m => { m.addedNodes.forEach(node => { navCopy($(node)); navAddLink($(node)); }); m.removedNodes.forEach(node => { navRemove($('.folder-navigator > ul').first().children('li')); }); }); }).observe($('.folder-navigator > ul')[0], { childList: true }); // 循环执行 let checkCount = 0; const fileListInterval = setInterval(() => { fileListAddLink($grids); if (++checkCount >= 3) { //检查3次 clearInterval(fileListInterval); // 监听 file-list new MutationObserver(mutations => { mutations.forEach(m => { $(m.addedNodes).each((i, node) => { if ($(node).hasClass('grid')) { fileCopy($(node)); fileListAddLink($(node)); } }); }); }).observe($('.file-list')[0], { childList: true }); } }, 1000); // 间隔1秒 }, 1500); // 延迟1.5秒 // 模块化添加复制文本按钮的功能 function addCopy($element, buttonText) { $element.after( $('<span>', { class: 'copy-name material-symbols-outlined', text: buttonText, }).on('click', function (event) { const textToCopy = $element.text(); navigator.clipboard.writeText(textToCopy).then(() => { // 创建自定义的提示框 const alertBox = $('<div>', { class: 'custom-alert', text: '已复制文本: ' + textToCopy, }).appendTo('body'); // 设置提示框的位置 alertBox.css({ top: event.pageY + parseFloat(getComputedStyle(document.body).fontSize) + 'px', left: event.pageX + 'px' }); // 3秒后自动关闭提示框 setTimeout(function () { alertBox.remove(); }, 3000); }).catch(err => console.error('复制失败: ', err)); // 复制失败后的处理,可选 }) ); } // 导航添加复制文本按钮 function navCopys($navLis) { // 排除第一个li $navLis.slice(1).find('.pp-link-button').each(function () { addCopy($(this), 'content_copy'); }); } function navCopy($navLi) { $navLi.find('.pp-link-button').each(function () { addCopy($(this), 'content_copy'); }); } // 文件列表添加复制文本按钮 function fileCopy($grids) { $grids.find('.name').each(function () { const $ell = $(this).children('.ellipsis').first(); addCopy($ell, 'content_copy'); }); } // 导航添加新标签页打开链接 function navAddLink($navLis) { $navLis.prev().each(function () { const $li = $(this); $li.append( $('<a>', { href: $li.children('.pp-link-button').first().attr('href'), target: '_blank', class: 'open_in_new material-symbols-outlined', text: 'open_in_new' }) ); }); } function navRemove($navLis) { $navLis.last().find('.open_in_new').remove(); } // 文件列表添加新标签页打开链接 function fileListAddLink($grids) { $grids.each(function () { const $grid = $(this); // 判断 .folder-cover 存在 if ($grid.has('.folder-cover').length) { // .pp-link-button 添加 class (通过 css 下移) if (!$grid.hasClass('folder-CM8m')) $grid.addClass('folder-CM8m'); // 添加按钮 const $openInNew = $grid.find('.open_in_new').first(); if (!$openInNew.length) { $grid.find('.grid-operation').first().append( $('<a>', { href: $canonical + '/' + $grid.attr('id'), target: '_blank', class: 'open_in_new' }).append( $('<span>', { class: 'material-symbols-outlined', text: 'open_in_new' }) ) ); } } }); } })(jQuery);
QingJ © 2025
镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址