// ==UserScript==
// @name Bypass paywalls for scientific documents
// @namespace StephenP
// @version 2.2
// @description Bypass paywalls for scientific documents by downloading them from sci-hub instead of paying something like 50 bucks for each paper. This script adds download buttons on Scopus and Web Of Science, which lead to sci-hub.bz. In this way you can get free access to scientific papers even if you (or your university) can't afford their prices.
// @author StephenP
// @match https://www.scopus.com/record/display.uri?*
// @match https://apps.webofknowledge.com/full_record.do?*
// @grant none
// @downloadURL none
// ==/UserScript==
(function() {
'use strict';
//If Sci-Hub address changes, just replace the URL below with the new one
var sciHubUrl='http://sci-hub.bz/';
var doi;
var site=window.location.href.toString();
var donate='window.open(\"'+sciHubUrl+'#donate\");';
if(site.startsWith("https://www.scopus.com/")){
var fullDocument=document.querySelector('[title="Full Text(opens in a new window)"]');
//fullDocument.href=fullDocument.href.slice(54);
doi=document.getElementById("recordDOI").innerHTML;
var section=document.getElementById("outwardLinks");
section.removeChild(section.lastChild);
fullDocument.parentNode.insertAdjacentHTML('beforeend','Donate to Sci-Hub project|');
fullDocument.parentNode.children[5].setAttribute('onclick',donate);
}
else if(site.startsWith("https://apps.webofknowledge.com/")){
var documentID=document.getElementsByClassName("block-record-info block-record-info-source")[0];
for(var i=4;i<=documentID.children.length;i++){
var compare=documentID.children[i].children[0].innerHTML;
if((compare.localeCompare("DOI:")==0)||(compare.localeCompare("PMID:")==0)){
doi=documentID.children[i].children[1].innerHTML;
break;
}
}
if(doi!==undefined){
var list=document.getElementsByClassName("popup-ft-list")[0];
list.appendChild(list.children[1].cloneNode(true));
var sciHubBtn=list.lastChild.children[0].children[0];
sciHubBtn.innerHTML="Full Text from Sci-Hub";
sciHubBtn.setAttribute('onclick',('window.open(\"'+sciHubUrl+doi+'\");'));
list.insertAdjacentHTML('beforeend','