Greasy Fork

Greasy Fork is available in English.

JCCC Library JSON

Using https://library.jccc.edu/home/?newlibrary this script interacts with http://jccc.summon.serialssolutions.com/api/search to get all results as quickly as possible for a particular query. It can handle 1000 results total, because that is where the api cuts it off. This is a very early version try to check back for newer versions with the full features.

当前为 2015-09-15 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name        JCCC Library JSON
// @namespace   JCCC Library JSON
// @description Using https://library.jccc.edu/home/?newlibrary this script interacts with http://jccc.summon.serialssolutions.com/api/search to get all results as quickly as possible for a particular query. It can handle 1000 results total, because that is where the api cuts it off.  This is a very early version try to check back for newer versions with the full features.
// @include     about:blank?jccclibrary
// @include     chrome://blank/?library
// @include     https://library.jccc.edu/home/?newlibrary
// @match       http://jccc.summon.serialssolutions.com/api/*
// @version     0.2
// @grant       GM_xmlhttpRequest
// ==/UserScript==
///////////////////////////////////////////////////////////////
// In order for this script to work in google chrome you must
// have tampermonkey or another script manager that emulates 
// the greasemonkey api.
// Reduce default 'referer' header granularity must be enabled
// in chrome://flags
//////////////////////////////////////////////////////////////
var startFuncVar = function () {

start();
};
var stopFuncVar = function () {stop();};
//disable all existing stylesheets
for (i=0;i<document.styleSheets.length;i++) {
document.styleSheets[i].disabled=true;
}
// start with a fresh body
document.body.innerHTML='';
// create de
deciplineSelectElem = document.createElement('select')
deciplineSelectElem.multiple=true
deciplineSelectElem.style.resize="both";
deciplineSelectElem.style.width="28em";
deciplineSelectElem.style.height="10em";
//deciplineSelectElem.style.fontFamily="monospace";
deciplineOptionArray = ["agriculture","anatomy & physiology","anthropology","applied sciences","architecture","astronomy & astrophysics","biology","botany","business","chemistry","computer science","dance","dentistry","diet & clinical nutrition","drama","ecology","economics","education","engineering","environmental sciences","film","forestry","geography","geology","government","history & archaeology","international relations","journalism & communications","languages & literatures","law","library & information science","mathematics","medicine","meteorology & climatology","military & naval science","music","nursing","occupational therapy & rehabilitation","oceanography","parapsychology & occult sciences","pharmacy, therapeutics, & pharmacology","philosophy","physical therapy","physics","political science","psychology","public health","recreation & sports","religion","sciences","social sciences","social welfare & social work","sociology & social history","statistics","veterinary medicine","visual arts","women's studies","zoology"];
newOption=document.createElement("option");
// Create 'any' option
	newOption.value='';
	newOption.innerHTML='Any';
	newOption.selected=true;
	deciplineSelectElem.appendChild(newOption);
// loop to populate the decipline select
for (i in deciplineOptionArray) {
	newOption=document.createElement("option");
	newOption.value=deciplineOptionArray[i];
	newOption.innerHTML=deciplineOptionArray[i];
	deciplineSelectElem.appendChild(newOption);
}
// start, information, results, and query elements
containerElem = document.createElement("div");
startElem = document.createElement("input");
startElem.setAttribute("value","Start");
startElem.setAttribute("type","button");
startElem.addEventListener("click",startFuncVar,false);
/*
stopElem = document.createElement("input");
stopElem.setAttribute("value","STOP");
stopElem.setAttribute("type","button");
stopElem.addEventListener("click",function () {
		for (j=0;j<timeoutarray.length;j++) {
			clearTimeout(timeoutarray[j]);
		}
		});
*/
infoElem = document.createElement("div");
queryElem = document.createElement("input");
queryElem.setAttribute("type","text");


stopping=false;
stillrequesting=false;
//onpage = '<span id="onpage"></span>';
//options = '<select id="categories"><option value="">Any</option><option value="agriculture">agriculture</option><option value="anatomy & physiology">anatomy & physiology</option><option value="anthropology">anthropology</option><option value="applied sciences">applied sciences</option><option value="architecture">architecture</option><option value="astronomy & astrophysics">astronomy & astrophysics</option><option value="biology">biology</option><option value="botany">botany</option><option value="business">business</option><option value="chemistry">chemistry</option><option value="computer science">computer science</option><option value="dance">dance</option><option value="dentistry">dentistry</option><option value="diet & clinical nutrition">diet & clinical nutrition</option><option value="drama">drama</option><option value="ecology">ecology</option><option value="economics">economics</option><option value="education">education</option><option value="engineering">engineering</option><option value="environmental sciences">environmental sciences</option><option value="film">film</option><option value="forestry">forestry</option><option value="geography">geography</option><option value="geology">geology</option><option value="government">government</option><option value="history & archaeology">history & archaeology</option><option value="international relations">international relations</option><option value="journalism & communications">journalism & communications</option><option value="languages & literatures">languages & literatures</option><option value="law">law</option><option value="library & information science">library & information science</option><option value="mathematics">mathematics</option><option value="medicine">medicine</option><option value="meteorology & climatology">meteorology & climatology</option><option value="military & naval science">military & naval science</option><option value="music">music</option><option value="nursing">nursing</option><option value="occupational therapy & rehabilitation">occupational therapy & rehabilitation</option><option value="oceanography">oceanography</option><option value="parapsychology & occult sciences">parapsychology & occult sciences</option><option value="pharmacy, therapeutics, & pharmacology">pharmacy, therapeutics, & pharmacology</option><option value="philosophy">philosophy</option><option value="physical therapy">physical therapy</option><option value="physics">physics</option><option value="political science">political science</option><option value="psychology">psychology</option><option value="public health">public health</option><option value="recreation & sports">recreation & sports</option><option value="religion">religion</option><option value="sciences">sciences</option><option value="social sciences">social sciences</option><option value="social welfare & social work">social welfare & social work</option><option value="sociology & social history">sociology & social history</option><option value="statistics">statistics</option><option value="veterinary medicine">veterinary medicine</option><option value="visual arts">visual arts</option><option value="women\'s studies">women\'s studies</option><option value="zoology">zoology</option></select>';
/*document.body.innerHTML='<input type="text" id="query">'; //<input type="button" value="start" id="start">'+onpage+'<br>'+options+'<br><input type="button" value=" . stop . " id="stop"><span id="total"></span><br>';
q = document.getElementById('query').value;
//document.getElementById('start').addEventListener("click",function () {start();});
*/
checkKeyFuncVar = function (event) {checkkey(event);}
queryElem.addEventListener("keydown",checkKeyFuncVar);
queryElem.addEventListener("keyup",checkKeyFuncVar);
/*
document.getElementById("stop").addEventListener("click",function () {
		for (j=0;j<timeoutarray.length;j++) {
			clearTimeout(timeoutarray[j]);
		}
		});
*/
timeoutarray = [];




//append all elements

containerElem.appendChild(queryElem);
containerElem.appendChild(startElem);
document.body.appendChild(containerElem);
//document.body.appendChild(stopElem);
document.body.appendChild(deciplineSelectElem);

function stop() {
		stopping=true;
		startElem.setAttribute("value","Start");
		startElem.addEventListener("click",startFuncVar,false);
		queryElem.addEventListener("keydown",checkKeyFuncVar);
		queryElem.addEventListener("keyup",checkKeyFuncVar);
		
}

function start() {
queryElem.removeEventListener("keydown",checkKeyFuncVar);
queryElem.removeEventListener("keyup",checkKeyFuncVar);
allResults = document.getElementsByClassName("resultdiv");
while (allResults.length>0) {

	document.body.removeChild(allResults[0]);
}


startElem.setAttribute("value","STOP");
startElem.removeEventListener("click",startFuncVar,false);
startElem.addEventListener("click",stopFuncVar,false);
deciplineQuery='';
	stopping=true;
	//q = document.getElementById('query').value;
	q = queryElem.value;

		for (i=0; i<deciplineSelectElem.options.length; i++) {
			if (deciplineSelectElem.options[i].selected===true && deciplineSelectElem.options[i].value==='') {
				break;
			}
			if (deciplineSelectElem.options[i].selected===true) {
				//console.log(deciplineSelectElem.options[i]);
				deciplineQuery+='&fvf[]=Discipline,'+deciplineSelectElem.options[i].value.replace(/\s/g,'+').replace(/&/g,'%26')+',f'
			}
		}
	console.log(deciplineQuery);

	//decipline = '&fvf[]=Discipline,'+decipline.replace(/\s/g,'+').replace(/&/g,'%26')+',f';
	//document.body.innerHTML+='<input type="text" id="query">'
	//document.body.innerHTML='<input type="text" id="query" value="'+q.replace(/"/g,'&quot;')+'"><input type="button" value="start" id="start">'+onpage+'<br>'+options+'<br><input type="button" value=" . stop . " id="stop"><span id="total"></span><br>';
	//document.getElementById('start').addEventListener("click",function () {start();});
	//document.getElementById('query').addEventListener("keydown",function (event) {checkkey(event);});
	//document.getElementById('query').addEventListener("keyup",function (event) {checkkey(event);});
	//document.getElementById("stop").addEventListener("click",function () {
		//for (j=0;j<timeoutarray.length;j++) {
		//	clearTimeout(timeoutarray[j]);
		//}
		//stopping=true;
		//});
	/*
	alloptions = document.getElementsByTagName("option");
	for (o in alloptions) {
		if (alloptions[o].value==decipline) {
			alloptions[o].selected=true;
		}
	}
	*/
	ii=1;
	otherii=1;
	totalpages = 51;
	linksarray = [];
	function linksa(link) {
	linksarray.push(link);
	}
	arrayi = [];
	for (i=0;i<totalpages;i++) {
	arrayi[i]=i;
	}
	i=0;
	for (j=0;j<timeoutarray.length;j++) {
			clearTimeout(timeoutarray[j]);
	}
	//for (i=0;i<totalpages;i++) {

	
	//timeoutarray[i]=setTimeout(function (i) {
		stopping=false;
		requestingdone=false;
		resultnumber = 0;
		//document.getElementById("onpage").innerHTML="Requesting Page 1";
		apireq(ii);
		//apireqsingle(1);
		

	
	//},(timeoutForEachRequest*arrayi.shift()));


	//}
}

var otherii;
var otherii2;
var resultnumber = 0;
function apireq(ii) {
GM_xmlhttpRequest({
	  method: "GET",
	  url: 'http://jccc.summon.serialssolutions.com/api/search?pn='+(ii)+'&ho=t'+deciplineQuery+'&fvf[]=IsFullText,true,f&l=en&ps=50&q='+q,
	  data: "",
	  headers: {
		"Host": "jccc.summon.serialssolutions.com",
		"User-Agent": "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:37.0) Gecko/20100101 Firefox/37.0",
	   	"Accept": "application/json, text/plain, */*",
	   	"Accept-Language": "en-US,en;q=0.5",
	   	"Accept-Encoding": "gzip, deflate",
	   	"SUMMON_SID": "",
	   	"Referer": "http://jccc.summon.serialssolutions.com/search",
	   	"Cookie": "Summon-Two=true; hasSavedItems=1",
	   	"Connection": "keep-alive"
	  },
	  onload: function(response) {
		console.log('onload');
		//document.body.innerHTML="<pre>"+response.responseText+"</pre>"
		pages =	JSON.parse(response.responseText);
		
		//document.body.innerHTML="<pre>"+pages.full_text_link+"</pre>";
		//document.body.innerHTML="";
		/*
		findobj = pages;
		for (key in findobj) {
			document.body.innerHTML+="<br>"+key+":\n"+findobj[key]+"<br>";
		}
		*/
		if (pages.documents=='') {
				requestingdone=true;
		}
		//document.getElementById("total").innerHTML=" Total Records "+pages.record_count;
		for (key in pages.documents) {
			resultnumber++;
			console.log(resultnumber);
			newh3 = document.createElement("h3");
			newh3.setAttribute("class","result");
			newh3.innerHTML=pages.documents[key]["full_title"];
			newh3.style.display="inline";
			newh4 = document.createElement("h4");
			newh4.setAttribute("class","result");
			newh4.innerHTML=resultnumber+" ";
			newh4.style.display="inline";
			newdiv2 = newdiv = document.createElement("div");
			
			newa = document.createElement("a");
			newa.setAttribute("class","result");
			newa.setAttribute("href",pages.documents[key]["fulltext_link"]);
			newa.appendChild(newh3);
			newdiv2.appendChild(newh4);
			newdiv2.appendChild(newa);
			newa.style.display="inline";
			newdiv = document.createElement("div");
			newdiv.setAttribute("class",ii);
			//newdiv.innerHTML=pages.documents[key]["snippet"];
			newdiv.style.padding="2px";
			newdiv2.style.padding="2px";
			newdiv.setAttribute("class","result");
			newdiv2.setAttribute("class","resultdiv");
			if ((resultnumber%2)==0) {
				newdiv2.style.backgroundColor="#e9e9e9";
				newdiv.style.backgroundColor="#e9e9e9";
			}
			document.body.appendChild(newdiv2);
			
			newspan = document.createElement("span");
			newspan.setAttribute("class","result");
			if (pages.documents[key]["snippet"]==undefined) {
				newspan.innerHTML=''
			} else {
				newspan.innerHTML=pages.documents[key]["snippet"];
			}
			newdiv.appendChild(newspan);
			
			newdiv2.appendChild(newdiv);
			
			
			
			//document.body.innerHTML+='<h3>'+pages.documents[key]["full_title"]+'</h3><br><a href="'+pages.documents[key]["fulltext_link"]+'">'+pages.documents[key]["fulltext_link"]+'</a><br>'+pages.documents[key]["snippet"]+"<br><br>";
		
		}
		/*
		console.log(ii+","+q+","+decipline.replace(/\s/g,'+'));
		if (ii<20) {
		document.getElementById("onpage").innerHTML="Last Requested Page "+ii;
		} else {
		document.getElementById("onpage").innerHTML="Requesting Done Page "+ii;
		//alert("'"+pages.documents+"'");
		}
		if (requestingdone==true) {
			document.getElementById("onpage").innerHTML="Requesting Done Page "+ii;
		}
		*/
		otherii = (ii+1);
		if (otherii<21 && stopping==false) {
		//console.log(otherii+" , "+(ii+1));
		if (requestingdone==false) {
		setTimeout(apireq(otherii),0);
		}
		}
	
	  }
	});


}

function checkkey(event) {
	thekey = event.which || event.keyCode;
	if (thekey==13) {
		start();
	}
}