acj / scholar2csx

Greasemonkey script for adding CiteSeerX links to Google Scholar results

This URL has Read+Write access

scholar2csx / scholar2csx.js
100644 55 lines (53 sloc) 1.887 kb
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
// 2007-04-30
// Copyright (c) 2007, punkaholic, Based on Butler script.
// Released under the GPL license
// http://www.gnu.org/copyleft/gpl.html
//
// --------------------------------------------------------------------
//
// This is a Greasemonkey user script.
//
// To install, you need Greasemonkey: http://greasemonkey.mozdev.org/
// Then restart Firefox and revisit this script.
// Under Tools, there will be a new menu item to "Install User Script".
// Accept the default configuration and install.
//
// ==UserScript==
// @name scholar2csx
// @namespace http://
// @description Add links to Google Scholar for CiteSeerX
// @include http://scholar.google.*/*
// ==/UserScript==
 
var ScholarServices = {
_otherWebSearches: function(q) {
var s = '';
s += '<a href="http://scholar.google.com/scholar?q=' + q + '">Google Scholar</a>';
return s;
}};
 
var Scholar = {
// add arbitrary CSS styles to page
addGlobalStyle: function(css) {
var style = document.createElement("style");
style.type = "text/css";
style.innerHTML = css;
document.getElementsByTagName('head')[0].appendChild(style);
}};
var ScholarFunc = {
addOtherWebSearches: function() {
var titles = document.getElementsByTagName('H3');
for (var t in titles) {
var title_text = titles[t].childNodes[0].innerHTML.replace(/<[^\>]*>/g, "");
// Correct for PDF links
if (title_text == "[PDF]") {
title_text = titles[t].childNodes[3].innerHTML.replace(/<[^\>]*>/g, "");
titles[t].innerHTML += " - <a href=\"http://citeseerx.ist.psu.edu/search?q=" + title_text + "\">CiteSeerX</a>";
} else {
titles[t].innerHTML += " - <a href=\"http://citeseerx.ist.psu.edu/search?q=" + title_text + "\">CiteSeerX</a>";
}
}
},
}
var href = window.location.href;
if (href.match(/^http:\/\/scholar\.google\.com\/[\w\.]+/i)) {
ScholarFunc.addOtherWebSearches();
}