Last active
August 10, 2017 15:48
-
-
Save sjpfenninger/5020075 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @id scopus-doi-linker | |
// @name Scopus DOI Linker | |
// @version 1.0 | |
// @namespace pfenninger.org | |
// @author Stefan Pfenninger | |
// @description Adds hyperlinks to DOIs on Scopus preview pages | |
// @homepage http://pfenninger.org/ | |
// @match http://www.scopus.com/* | |
// @match http://*.scopus.com/* | |
// @match https://www.scopus.com/* | |
// @match https://*.scopus.com/* | |
// @require http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js | |
// @grant none | |
// ==/UserScript== | |
// Smart jQuery loading modified from this example: | |
// http://stackoverflow.com/a/12751531/397746 | |
function GM_main ($) { | |
var target_element = $("strong:contains('DOI:')"); | |
var doi_text = target_element.parent().text().replace("DOI: ", ""); | |
var link_text = '<strong><a href="http://dx.doi.org/' | |
+ doi_text + '"> DOI: ' + doi_text + '</a></strong>'; | |
target_element.parent().html(link_text); | |
} | |
if (typeof jQuery === "function") { | |
// Run with a local copy of jQuery | |
GM_main (jQuery); | |
} | |
else { | |
// Fetch jQuery 1.x from Google APIs | |
add_jQuery (GM_main, "1"); | |
} | |
function add_jQuery (callbackFn, jqVersion) { | |
var jqVersion = jqVersion; | |
var D = document; | |
var targ = D.getElementsByTagName ('head')[0] || D.body || D.documentElement; | |
var scriptNode = D.createElement ('script'); | |
scriptNode.src = 'http://ajax.googleapis.com/ajax/libs/jquery/' | |
+ jqVersion | |
+ '/jquery.min.js' | |
; | |
scriptNode.addEventListener ("load", function () { | |
var scriptNode = D.createElement ("script"); | |
scriptNode.textContent = | |
'var gm_jQuery = jQuery.noConflict (true);\n' | |
+ '(' + callbackFn.toString () + ')(gm_jQuery);' | |
; | |
targ.appendChild (scriptNode); | |
}, false); | |
targ.appendChild (scriptNode); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment