-
Notifications
You must be signed in to change notification settings - Fork 1
/
script_arxive.org.js
44 lines (44 loc) · 1.47 KB
/
script_arxive.org.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
$(function() {
function get_file_type(url) {
if (/^\/pdf/.test(url)) {
return "pdf";
}
if (/^\/ps/.test(url)) {
return "ps";
}
return false;
}
function get_authors($element) {
return $element.text().replace("Authors:", "").replace(/\n/g, "").trim();
}
function get_title($element) {
return $element.text().replace("Title:", "").trim()
}
if (/arxiv.org\/abs/.test(document.location)) {
var authors = get_authors($("div.authors"));
var title = get_title($("h1.title"));
$("div.full-text a").click(function() {
var $this = $(this);
var file_type = get_file_type($this.attr("href"));
if (!file_type) {
return true;
}
process_link_click(authors, title, file_type, $this);
return false;
});
}
else if (/arxiv.org\/list/.test(document.location)) {
$("span.list-identifier a").click(function() {
var $this = $(this);
var file_type = get_file_type($this.attr("href"));
if (!file_type) {
return true;
}
var $dd = $this.parents("dt:first").next();
var title = get_title($dd.find("div.list-title"));
var authors = get_authors($dd.find("div.list-authors"));
process_link_click(authors, title, file_type, $this);
return false;
});
}
});