diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e43b0f9 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.DS_Store diff --git a/doi-bookmarklet.js b/doi-bookmarklet.js new file mode 100644 index 0000000..e3f9bb2 --- /dev/null +++ b/doi-bookmarklet.js @@ -0,0 +1,12 @@ +(function() { + var proxyUrl = ""; + var selection = document.getSelection ? document.getSelection().toString() : document.selection.createRange().text; + var regex = /\w?(?:doi:|hdl:(?:\/\/)?)\s*([0-9./a-z]+)\w?/i; + var match = regex.exec(selection); + if (match != null) { + var doi = match[1]; + var tempAnchor = document.createElement('a'); + tempAnchor.href = proxyUrl; + document.location = tempAnchor.protocol + '//dx.doi.org.' + tempAnchor.host + '/' + doi; + } +})(); \ No newline at end of file