-
-
Save phette23/3f1e6264f79eadb567193d5139cce57d to your computer and use it in GitHub Desktop.
Simple script to add link to link resolver in Summon results
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
setTimeout(() => { | |
libScope(angular.element('html').scope()); | |
}, 1000); | |
function libScope(scope) { | |
// Watch results feed for changes... | |
scope.$watchCollection('feed', () => { | |
// give AngularJS time to update the DOM | |
// Probably need to wait a few seconds before running this to make sure the DOM loads | |
setTimeout(function() { | |
// Get all the results | |
const results = document.querySelectorAll('#results > div.inner > ul > li') | |
const linkResolver = 'https://ey7mr5fu9x.search.serialssolutions.com' | |
const linkLabel = 'All Full Text Options' | |
// Get OpenURL and add link to result | |
for (const result of results) { | |
// Get the OpenURL in a variable | |
var OpenURLSpan = result.querySelector('span.Z3988'); | |
if (OpenURLSpan && !result.querySelector('.fulltext-hack')) { | |
var OpenURL = OpenURLSpan.title | |
// add a new link to the right of the Full Text Online link | |
jQuery(OpenURLSpan).after(`<div class="fulltext-hack availability" style="margin-left:1.1em;"><a tabindex="0" target="_blank" class="availabilityLink" href="${linkResolver}/?${OpenURL}&newui=1clickoff">${linkLabel}</a></div>`) | |
} | |
} | |
}, 500) // Wait a second and a half before running this on page load | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Just testing if a record has an OpenURL isn't good enough—you'll end up with links for all your catalog records, too. So you probably want to check the record's type before adding the fulltext-hack link. Rather than use the DOM for this and the OpenURL, you can get a record's data via angular with
angular.element('.documentSummary').scope().document
(results list is structuredli > div.documentSummary
)