Google Scholar Save All

Adds a Save All button to save all articles on the page in Google Scholar

当前为 2024-10-07 提交的版本,查看 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Google Scholar Save All 
// @namespace    https://github.com/asmpro7
// @version      1.0
// @description  Adds a Save All button to save all articles on the page in Google Scholar
// @author       Ahmed ElSaeed
// @icon         https://scholar.google.com/favicon.ico
// @match        https://scholar.google.com/scholar*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    // Function to simulate a click
    function simulateClick(element) {
        if (element) {
            element.click();
        }
    }

    // Add the "Save All" button
    function addSaveAllButton() {
        const gsAbMdDiv = document.getElementById('gs_ab_md');
        if (gsAbMdDiv) {
            const saveAllButton = document.createElement('button');
            saveAllButton.textContent = 'Save All';
            saveAllButton.style.backgroundColor = 'blue';
            saveAllButton.style.color = 'white';
            saveAllButton.style.padding = '10px';
            saveAllButton.style.border = 'none';
            saveAllButton.style.cursor = 'pointer';
            saveAllButton.style.marginLeft = '10px';

            saveAllButton.addEventListener('click', function() {
                // Get all "Save" buttons on the page
                const saveButtons = document.querySelectorAll('span.gs_or_btn_lbl');
                saveButtons.forEach((btn, index) => {
                    // Simulate a click on each Save button
                    setTimeout(() => {
                        simulateClick(btn);
                        // After a click, wait for popups and then dismiss them
                        setTimeout(() => {
                            const popup = document.querySelector('.gs_or_sav');
                            if (popup) {
                                simulateClick(document.body); // Click outside to close the popup
                            }
                        }, 500);
                    }, 500 * index); // Delay between each click to ensure the popup appears and is closed
                });

                // Change the button's background color to green once done
                saveAllButton.style.backgroundColor = 'green';
            });

            gsAbMdDiv.appendChild(saveAllButton);
        }
    }

    // Wait for the page to load, then add the button
    window.addEventListener('load', addSaveAllButton);

})();