Last active
February 14, 2017 15:19
-
-
Save MrClement/bd64a25d89928d9edee48963a9e8589b 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== | |
// @name 7th Grade History 2017 Collection Highlighter | |
// @namespace http://kentdenver.org/ | |
// @version 0.1 | |
// @description Highlights local resources during book searches | |
// @author Alex Clement | |
// @match http://kentdenver.catalog.aspencat.info/Union/Search* | |
// @match http://kentdenver.catalog.aspencat.info/Search* | |
// @downloadURL https://gist.github.com/MrClement/bd64a25d89928d9edee48963a9e8589b/raw/7th-Grade-History.user.js | |
// @updateURL https://gist.github.com/MrClement/bd64a25d89928d9edee48963a9e8589b/raw/7th-Grade-History.user.js | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
var list = []; | |
var xhr = new XMLHttpRequest(); | |
xhr.onload = function() { | |
var results = this.responseXML.querySelectorAll('div.result'); | |
for(var i = 0; i < results.length; i++) { | |
var result = results[i]; | |
var id = result.querySelector('a').name; | |
var title = result.querySelector('a.result-title').text; | |
var author_spot = result.querySelector('a[href^="/Author"]'); | |
var author = author_spot ? author_spot.text : ""; | |
list.push({id: id, title: title, author: author}); | |
} | |
var xhr2 = new XMLHttpRequest(); | |
xhr2.onload = function() { | |
var results = this.responseXML.querySelectorAll('div.result'); | |
for(var i = 0; i < results.length; i++) { | |
var result = results[i]; | |
var id = result.querySelector('a').name; | |
var title = result.querySelector('a.result-title').text; | |
var author_spot = result.querySelector('a[href^="/Author"]'); | |
var author = author_spot ? author_spot.text : ""; | |
list.push({id: id, title: title, author: author}); | |
} | |
var curList = document.querySelectorAll('div.result'); | |
for(var i = 0; i < curList.length; i++) { | |
var curEl = curList[i]; | |
for(var j = 0; j < list.length; j++) { | |
if(list[j].id == curEl.querySelector('a').id) { | |
curEl.style.backgroundColor = "rgba(0, 255, 100, .2)"; | |
} | |
} | |
} | |
}; | |
xhr2.open("GET", "http://kentdenver.catalog.aspencat.info/MyAccount/MyList/1301?pagesize=200&showCovers=off"); | |
xhr2.responseType = "document"; | |
xhr2.send(); | |
}; | |
xhr.open("GET", "http://kentdenver.catalog.aspencat.info/MyAccount/MyList/1299?pagesize=200&showCovers=off"); | |
xhr.responseType = "document"; | |
xhr.send(); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment