Greasy Fork

Greasy Fork is available in English.

ResearchGate下载PDF

打开ResearchGate下载PDF页面

当前为 2024-09-29 提交的版本,查看 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         ResearchGate下载PDF
// @namespace    http://tampermonkey.net/
// @version      0.4
// @description  打开ResearchGate下载PDF页面
// @author       HuanZhi
// @match        https://www.researchgate.net/*
// @grant        unsafewindow
// @license      MIT
// @run-at       document-end
// ==/UserScript==
(function(){
    //添加按钮显示
    AddDownloadButton()
}
)();

// 下载按钮
function AddDownloadButton(){
    var download_btn = document.createElement("button");
    download_btn.setAttribute('style', "position:absolute; z-index:1000; right:15px; top:55px; height:28px; background-color:#3E8CD0; border:none; color:white; font-size:16px; cursor:pointer; border-radius:1em;");
    download_btn.setAttribute('id', "download_btn");
    download_btn.textContent = '输入关键词';
    document.body.appendChild(download_btn);
    download_btn.onmouseover = function() {
        this.style.backgroundColor="#e9686b";
    };
    download_btn.onmouseout = function() {
        this.style.backgroundColor="#3E8CD0";
    };
    download_btn.onclick = startSearchQueue;
}

// Function to display the prompt and start the search
function startSearchQueue() {
        const keywords = prompt("输入关键词,逗号分割:");
        if (keywords) {
            const keywordArray = keywords.split(',').map(k => k.trim());
            searchNextKeyword(keywordArray);
        }
    }

// Function to search the next keyword in the queue
function searchNextKeyword(keywordQueue) {
    if (keywordQueue.length === 0) {
        alert("All keywords have been searched.");
        return;
    }

    const keyword = keywordQueue.shift();
    performSearch(keyword);
    link.href = document.querySelector('.nova-legacy-c-button.nova-legacy-c-button--align-center.nova-legacy-c-button--radius-full.nova-legacy-c-button--size-s.nova-legacy-c-button--color-blue.nova-legacy-c-button--theme-ghost').href;
    window.open(link.href, '_blank');

    // Set a timeout to wait for the search to complete before moving to the next keyword
    setTimeout(() => searchNextKeyword(keywordQueue), 5000); // Wait 5 seconds before the next search
}

// Function to perform the search
function performSearch(keyword) {
    const searchInput = document.querySelector('input[name="query"]');
    const searchButton = document.querySelector('button[type="submit"]');

    if (searchInput && searchButton) {
        searchInput.value = keyword;
        searchButton.click();
    }
}