Google Scholar - Open Links in New Tab

Open links in Google Scholar search results in a new tab, including PDF links

Від 03.02.2025. Дивіться остання версія.

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(У мене вже є менеджер скриптів, дайте мені встановити його!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         Google Scholar - Open Links in New Tab
// @namespace    http://tampermonkey.net/
// @version      1.1
// @description  Open links in Google Scholar search results in a new tab, including PDF links
// @author       Bui Quoc Dung
// @match        https://scholar.google.com/*
// @grant        none

// ==/UserScript==

(function() {
    'use strict';

    // Lấy tất cả các thẻ <h3> có class là 'gs_rt'
    const headings = document.querySelectorAll('h3.gs_rt');

    headings.forEach(heading => {
        // Lấy thẻ <a> bên trong thẻ <h3>
        const link = heading.querySelector('a');

        if (link) {
            // Thêm sự kiện click để mở liên kết trong tab mới
            link.addEventListener('click', function(event) {
                event.preventDefault(); // Ngăn chặn hành động mặc định
                window.open(link.href, '_blank'); // Mở liên kết trong tab mới
            });
        }
    });

    // Mở các liên kết PDF trong tab mới (ví dụ: các liên kết có dạng [PDF] bên cạnh tiêu đề)
    const pdfLinks = document.querySelectorAll('.gs_or_ggsm a');

    pdfLinks.forEach(pdfLink => {
        pdfLink.setAttribute('target', '_blank');
    });

})();