Greasy Fork

Greasy Fork is available in English.

知网批量下载PDF

用于知网批量下载PDF

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         知网批量下载PDF
// @namespace    https://ixz.im/
// @version      0.1
// @description  用于知网批量下载PDF
// @author       Juicpt
// @match        *://*.cnki.net/*
// @include      *://*.cnki.net.*
// @include      *://*/cnki.net/*
// @run-at       document-end
// @grant        none
// ==/UserScript==

(function () {
    'use strict';
    const html = document.querySelector(".SavePoint");
    const button = document.createElement('a');
    const Util = {
        dflag: res => res.replace('&dflag=nhdown', '&dflag=pdfdown'),

    };
    button.innerHTML = '批量下载PDF';

    if (html) {
        html.style.width = '600px';
        html.appendChild(button);

    }
    const table = document.querySelector('.GridTableContent');
    const tr = table.querySelectorAll('tr [bgcolor]');
    tr.forEach(
        res => {
            const a = res.querySelector('.briefDl_Y, .briefDl_D');
            a.href = a.href.match('&dflag') ? Util.dflag(a.href) : (a.href + '&dflag=pdfdown');
        }
    );
    button.addEventListener('click', () => {
        tr.forEach(
            res=>{
                const a = res.querySelector('.briefDl_Y, .briefDl_D');
                a.click();
            }
        )
    });

})();