wiley补充资料的快速下载方法

搜索技巧 3907 0 2
molihuakai
molihuakai 来自四川 发表于:2026-06-16 20:20:59

Wiley 补充材料批量打包下载

右侧黑白灰面板 · 自动提取文件名 · 一键打包 ZIP
版本:v1.4 
匹配 *.onlinelibrary.wiley.com/*
授权 MIT
作者 定制脚本 · DeepSeek 辅助
 
 
 
⬆ 右侧浮动面板 · 自动识别补充材料链接
 

1 使用方法

在 Wiley 文章页面,脚本会自动在右上角生成控制面板,无需额外操作。

  • 1 安装脚本管理器 —— 推荐 脚本猫Tampermonkey,确保已启用。
  • 2 添加用户脚本 —— 将下方完整代码复制到脚本管理器中,保存并启用。(@match 已适配 Wiley 域名
  • 3 访问 Wiley 文章页 —— 任意包含 action/downloadSupplement?doi= 链接的页面,面板会自动出现。
  • 4 勾选文件 → 一键打包 —— 点击 「打包下载选中文件」,ZIP 将自动下载,文件名取自 file= 参数。

2 完整脚本代码

复制以下代码到脚本管理器,保存即用。

// ==UserScript==
            // @name         Wiley 补充材料批量打包下载(右侧黑白灰+file命名)
            // @namespace    http://tampermonkey.net/
            // @version      1.4
            // @description  修复面板不显示问题,右侧黑白灰样式,提取file=文件名,文件直放ZIP根目录
            // @author       定制脚本
            // @match        https://*.onlinelibrary.wiley.com/*
            // @grant        none
            // @require      https://cdn.jsdelivr.net/npm/jszip@3.10.1/dist/jszip.min.js
            // @require      https://cdn.jsdelivr.net/npm/file-saver@2.0.5/dist/FileSaver.min.js
            // @license      MIT
            // ==/UserScript==

            (function() {
                'use strict';

                // 解析 file= 参数获取文件名
                const getFileName = (url) => {
                    let name = '';
                    const fileMatch = url.match(/file=([^&]+)/);
                    if (fileMatch && fileMatch[1]) {
                        name = decodeURIComponent(fileMatch[1]);
                    } else {
                        const fnMatch = url.match(/filename=([^&]+)/);
                        name = fnMatch ? decodeURIComponent(fnMatch[1]) : '';
                    }
                    return name.replace(/[\\/:*?"<>|]/g, '_') || 'unknown_file';
                };

                // 创建控制面板
                function createPanel(links) {
                    if (document.getElementById('wiley_supplement_panel')) return;

                    const panel = document.createElement('div');
                    panel.id = 'wiley_supplement_panel';
                    panel.style.cssText = `
                        position: fixed; top: 20px; right: 20px; z-index: 999999;
                        background: #f8f8f8; border: 1px solid #ccc; border-radius: 6px;
                        padding: 12px; box-shadow: 0 2px 8px rgba(0,0,0,0.15);
                        font-size: 14px; width: 320px; color: #333;
                    `;

                    const title = document.createElement('div');
                    title.textContent = `📦 补充材料打包下载 (${links.length} 个文件)`;
                    title.style.fontWeight = 'bold';
                    title.style.marginBottom = '8px';
                    title.style.color = '#222';
                    panel.appendChild(title);

                    const selectBtn = document.createElement('button');
                    selectBtn.textContent = '全选 / 反选';
                    selectBtn.style.margin = '0 5px 8px 0';
                    selectBtn.style.padding = '4px 8px';
                    selectBtn.style.border = '1px solid #999';
                    selectBtn.style.background = '#eee';
                    selectBtn.style.color = '#333';
                    selectBtn.style.borderRadius = '3px';
                    selectBtn.style.cursor = 'pointer';
                    panel.appendChild(selectBtn);

                    const downloadBtn = document.createElement('button');
                    downloadBtn.textContent = '✅ 打包下载选中文件';
                    downloadBtn.style.background = '#666';
                    downloadBtn.style.color = '#fff';
                    downloadBtn.style.border = '1px solid #555';
                    downloadBtn.style.borderRadius = '3px';
                    downloadBtn.style.padding = '4px 12px';
                    downloadBtn.style.cursor = 'pointer';
                    panel.appendChild(downloadBtn);

                    const fileList = document.createElement('div');
                    fileList.style.maxHeight = '200px';
                    fileList.style.overflowY = 'auto';
                    fileList.style.marginTop = '8px';
                    fileList.style.borderTop = '1px solid #ddd';
                    fileList.style.paddingTop = '8px';
                    panel.appendChild(fileList);
                    document.body.appendChild(panel);

                    const checkboxes = [];
                    links.forEach((link) => {
                        const fileName = getFileName(link.href);
                        const item = document.createElement('div');
                        item.style.margin = '3px 0';

                        const checkbox = document.createElement('input');
                        checkbox.type = 'checkbox';
                        checkbox.checked = true;
                        checkbox.value = link.href;

                        const label = document.createElement('span');
                        label.textContent = fileName;
                        label.style.marginLeft = '5px';

                        item.appendChild(checkbox);
                        item.appendChild(label);
                        fileList.appendChild(item);
                        checkboxes.push(checkbox);
                    });

                    // 全选反选
                    let isAllChecked = true;
                    selectBtn.onclick = () => {
                        isAllChecked = !isAllChecked;
                        checkboxes.forEach(cb => cb.checked = isAllChecked);
                    };

                    // 打包下载
                    downloadBtn.onclick = async () => {
                        const selected = checkboxes.filter(cb => cb.checked).map(cb => cb.value);
                        if (selected.length === 0) {
                            alert('请至少选择一个文件');
                            return;
                        }

                        downloadBtn.textContent = '⏳ 正在打包,请稍等...';
                        downloadBtn.disabled = true;

                        const zip = new JSZip();
                        const doi = location.pathname.split('/doi/')[1]?.replace(/\//g, '.') || 'wiley-supplements';

                        for (const url of selected) {
                            try {
                                const fileName = getFileName(url);
                                const res = await fetch(url, { mode: 'cors' });
                                const blob = await res.blob();
                                zip.file(fileName, blob);
                            } catch (e) {
                                console.warn('文件获取失败:', url, e);
                            }
                        }

                        zip.generateAsync({ type: 'blob' }).then(blob => {
                            saveAs(blob, `补充材料_${doi}.zip`);
                            downloadBtn.textContent = '✅ 打包下载完成';
                            setTimeout(() => {
                                downloadBtn.textContent = '✅ 打包下载选中文件';
                                downloadBtn.disabled = false;
                            }, 2000);
                        });
                    };
                }

                // 轮询检测异步加载的链接
                function checkLinks() {
                    const supplementLinks = Array.from(document.querySelectorAll('a[href*="action/downloadSupplement?doi="]'));
                    if (supplementLinks.length > 0) {
                        createPanel(supplementLinks);
                        return true;
                    }
                    return false;
                }

                // 初次检测 + 定时轮询
                if (!checkLinks()) {
                    const timer = setInterval(() => {
                        if (checkLinks()) {
                            clearInterval(timer);
                        }
                    }, 800);
                }

            })();

 


本帖完毕 ,最后编辑于:2026-06-16 20:47:52
回帖
  • 等待你,消灭零评论
科研通是完全免费的文献互助平台,具备全网最快的应助速度,最高的求助完成率。 对每一个文献求助,科研通都将尽心尽力,给求助人一个满意的交代。
实时播报
1秒前
小羊咩咩发布了新的文献求助10
1秒前
1秒前
Karma发布了新的文献求助10
1秒前
2秒前
2秒前
ding应助义气成风采纳,获得10
2秒前
小肚丸完成签到,获得积分10
2秒前
3秒前
3秒前
jun发布了新的文献求助10
4秒前
轻松静竹发布了新的文献求助10
4秒前
Owen应助苹果亦巧采纳,获得10
4秒前
4秒前
5秒前
氨基酸发布了新的文献求助10
6秒前
6秒前
小蘑菇应助chxhwu采纳,获得10
7秒前
Ava应助科研通管家采纳,获得10
7秒前
7秒前
小蘑菇应助科研通管家采纳,获得10
7秒前
小马甲应助科研通管家采纳,获得10
7秒前
孙孙孙发布了新的文献求助10
7秒前
7秒前
乐乐应助科研通管家采纳,获得10
7秒前
难过的豆芽完成签到,获得积分10
7秒前
Akim应助科研通管家采纳,获得10
7秒前
8秒前
8秒前
华仔应助科研通管家采纳,获得30
8秒前
小二郎应助科研通管家采纳,获得10
8秒前
CodeCraft应助科研通管家采纳,获得10
8秒前
8秒前
超级微笑发布了新的文献求助20
8秒前
Dean应助科研通管家采纳,获得50
8秒前
blue完成签到,获得积分10
9秒前
9秒前
英姑应助烂漫的奇迹采纳,获得10
9秒前
9秒前
9秒前
热门帖子
关注 科研通微信公众号,转发送积分 7737998
求助须知:如何正确求助?哪些是违规求助? 9287203
关于积分的说明 20181937
捐赠科研通 7315717
什么是DOI,文献DOI怎么找? 3305747
关于科研通互助平台的介绍 2458004
邀请新用户注册赠送积分活动 2315475
最新评论
感谢平台 1小时前
感谢平台 2小时前
感谢平台 2小时前
感谢平台 8小时前
科研通求助即可 8小时前
谢谢平台 10小时前
你说的非常有道理,这个确实很经典 11小时前
老师,你最终找到了吗 12小时前