Greasy Fork is available in English.
打开ResearchGate下载PDF页面
当前为
// ==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();
}
}