RGdoi

Detect DOIs as hyperlinks

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

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

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

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.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==UserScript==
// @name        RGdoi
// @namespace   https://www.researchgate.net
// @description Detect DOIs as hyperlinks
// @include     http://www.researchgate.net/publication/*
// @include     https://www.researchgate.net/publication/*
// @version     0.0.3
// @grant       none
// ==/UserScript==


function rgdoi()
{
    openDoi(window.top)
}

var matchRegexpGlobal = /DOI:.*/mg;
var extractRegexp = /(?:DOI:\s)([\w\.\/\-])*/g;

function openDoi(win)
{
    var root = "https://doi.org/";

    var text = win.document.body.textContent;
    while((match = matchRegexpGlobal.exec(text)) != null) {
        var doi = extractRegexp.exec(match[0]);
        if (doi != null) {
            var doi_link = doi[0].replace(/DOI\:\s/i, "");
            alert('DOI detected');
            replaceElement(doi_link);
        }
    }
    for (var i = 0, n = win.frames.length; i < n; i++)
        openDoi(win.frames[i]);
}


function replaceElement(doi) {
    var divs = document.querySelectorAll(".publication-meta-secondary");
    var element = divs[0];
    var replace = '<a href="https://doi.org/' + doi +'">' + element.innerHTML +  '</a>';
    element.innerHTML = replace;
}


rgdoi()