-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsummon.js
59 lines (56 loc) · 2.58 KB
/
summon.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
// ==UserScript==
// @name Summon Mods
// @namespace https://libraries.cca.edu
// @version 1.2.4
// @description helpful modifications for the Summon discovery layer
// @author @phette23
// @match https://cca.summon.serialssolutions.com/*
// @match https://cca-summon-serialssolutions-com.proxy.cca.edu/*
// @match https://cca.preview.summon.serialssolutions.com/*
// @grant none
// @updateURL https://raw.githubusercontent.com/cca/libraries_tampermonkey/main/summon.js
// @downloadURL https://raw.githubusercontent.com/cca/libraries_tampermonkey/main/summon.js
// ==/UserScript==
/*global angular*/
(function() {
// expose metadata in global scope
// note first item is query & then come results documents
let interval = setInterval(() => {
console.log('Tampermonkey: checking to see if results feed exists.')
if (document.querySelector('.documentSummary') && !window.docs) {
console.log('Found results feed, window.docs references it.')
// map to documents for those items, query & newsRollup will stay
// the same
window.docs = angular.element('div[results-feed]')
.scope().feed.items.map(item => {
if (item.document) return item.document
return item
})
clearInterval(interval)
}
}, 1000)
// format metadata for use in Ex Libris support tickets
window.report = () => {
// support ticket text, to be copied to clipboard later
let text = 'The link to this article\n\n'
// angular doc with metadata details
let doc = angular.element('.documentSummary').scope().document
let authors = doc.authors.reduce((text, author, idx, arr) => {
text += author.fullname
// it's _not_ the last author in the list
if (arr.length - idx != 1) {
text += ', '
}
// there's more than one author and this is the penultimate author
if (arr.length > 1 && arr.length - idx === 2) {
text += '& '
}
return text
}, '')
// citation
text += `"${doc.full_title}" by ${authors}. _${doc.publication_title}_, ${doc.publication_date}.\n\n`
text += `fails to resolve correctly.\n\nSummon bookmark:\n${'https://cca.summon.serialssolutions.com/#!/search?bookMark=' + doc.bookmark}\n\nOpenURL:\n${doc.open_url}`
prompt("Copy to clipboard with CMD+C", text)
open("https://support.proquest.com/s/login", "_blank")
}
})()