Last active
December 12, 2015 08:49
-
-
Save jlewin/4747001 to your computer and use it in GitHub Desktop.
Fiddle with Scholar -
Override the default behavior of the 'Cite' link and instead search for the APA reference and write the results to the console
This file contains hidden or 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
| function extractCite(elem, exporterName) | |
| { | |
| var apa, exporter; | |
| var results = elem.querySelectorAll('.gs_citf'); | |
| var exporters = elem.querySelectorAll('a.gs_citi'); | |
| // Find the APA row | |
| for(var i = 0; i < results.length; i++) { | |
| if(results[i].textContent == 'APA') | |
| apa = results[i]; | |
| } | |
| // Find the exporter link | |
| for(var i = 0; i < exporters.length; i++) { | |
| if(exporters[i].textContent.indexOf(exporterName) != -1) | |
| exporter = exporters[i]; | |
| } | |
| if(exporter) | |
| { | |
| gs_ajax(exporter.getAttribute('href'), function(status, results){ | |
| console.log('ExporterResults', results); | |
| }); | |
| } | |
| // Return the cite | |
| return apa.nextSibling.querySelector('div').textContent; | |
| } | |
| if(typeof(jsAjaxOriginal) == "undefined") { | |
| // Store the original reference | |
| window['jsOcitOriginal'] = gs_ocit; | |
| // wrap original | |
| function gs_ocit(e, id) { | |
| var url = '/scholar?q\x3dinfo:{id}:scholar.google.com/\x26output\x3dcite\x26hl\x3den\x26as_sdt\x3d0,5\x26scfhb\x3d1'.replace('{id}',id); | |
| gs_ajax(url, function(status, results){ | |
| var temp = document.createElement('div'); | |
| temp.innerHTML = results; | |
| console.log(extractCite(temp, 'RefMan')); | |
| }); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment