-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from idow09/master
Added support for arXiv.org
- Loading branch information
Showing
10 changed files
with
71 additions
and
53 deletions.
There are no files selected for viewing
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
This file was deleted.
Oops, something went wrong.
File renamed without changes
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
File renamed without changes
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,29 @@ | ||
chrome.runtime.onMessage.addListener(function(request, sender, sendResponse) { | ||
var xhr = new XMLHttpRequest(); | ||
xhr.responseType = "document" | ||
var paperurl = "https://paperswithcode.com/search?q_meta=&q="+request.title.replace(/\s/g,"+") //Search in PapersWithCode | ||
xhr.open("GET", paperurl, true); | ||
xhr.onreadystatechange = function() { | ||
if (xhr.readyState == 4) { | ||
var paper_link = paperurl; // Initialize with search query | ||
var elems = xhr.response.getElementsByClassName('col-lg-9 item-content') | ||
if (elems.length == 0) | ||
{ | ||
var txt = "no code implementation"; // No results | ||
} | ||
else { | ||
var title = elems[0].childNodes[1].textContent.toUpperCase() | ||
if (title == request.title.toUpperCase()){ | ||
var txt = elems[0].childNodes[3].childNodes[3].text; | ||
paper_link = elems[0].childNodes[1].childNodes[0].href; // If exist, use page url | ||
} | ||
else { | ||
var txt = "no code implementation"; // No result with same title | ||
} | ||
} | ||
var code_str = "var panels = document.getElementsByClassName('gs_ri');" | ||
+"var a = document.createElement('a');" | ||
+"a.innerText =\"" + txt +"\";" | ||
+"a.href =\"" + paper_link +"\";" | ||
+ "panels[" + request.ind + "].childNodes[3].appendChild(a);" | ||
|
||
chrome.tabs.executeScript( { | ||
code: code_str | ||
}); | ||
} | ||
} | ||
xhr.send(); | ||
}); | ||
chrome.runtime.onMessage.addListener(function(request, sender, sendResponse) { | ||
var xhr = new XMLHttpRequest(); | ||
xhr.responseType = "document" | ||
var paperurl = "https://paperswithcode.com/search?q_meta=&q="+request.title.replace(/\s/g,"+") //Search in PapersWithCode | ||
xhr.open("GET", paperurl, true); | ||
xhr.onreadystatechange = function() { | ||
if (xhr.readyState == 4) { | ||
var paper_link = paperurl; // Initialize with search query | ||
var elems = xhr.response.getElementsByClassName('col-lg-9 item-content') | ||
if (elems.length == 0) | ||
{ | ||
var txt = "no code implementation"; // No results | ||
} | ||
else { | ||
var title = elems[0].childNodes[1].textContent.toUpperCase() | ||
if (title == request.title.toUpperCase()){ | ||
var txt = elems[0].childNodes[3].childNodes[3].text; | ||
paper_link = elems[0].childNodes[1].childNodes[0].href; // If exist, use page url | ||
} | ||
else { | ||
var txt = "no code implementation"; // No result with same title | ||
} | ||
} | ||
sendResponse({txt: txt, paper_link: paper_link, payload: request.payload}); | ||
} | ||
} | ||
xhr.send(); | ||
return true; | ||
}); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
var paper_title = document.querySelector("#abs h1").childNodes[1].textContent; | ||
chrome.runtime.sendMessage({title: paper_title}, function(response) { | ||
var a = document.createElement('a'); | ||
a.innerText = response.txt; | ||
a.href = response.paper_link; | ||
var li = document.createElement('li'); | ||
li.appendChild(a); | ||
document.querySelector(".full-text ul").appendChild(li); | ||
}); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
var panels = document.getElementsByClassName('gs_ri'); | ||
// Go over all regions and add code implementations | ||
for (var i = 0, l = panels.length; i < l; i++) { | ||
var title = panels[i].childNodes[0].textContent; | ||
chrome.runtime.sendMessage({title: title, payload: i}, function(response) { | ||
var panels = document.getElementsByClassName('gs_ri'); | ||
var a = document.createElement('a'); | ||
a.innerText = response.txt; | ||
a.href = response.paper_link; | ||
panels[response.payload].childNodes[3].appendChild(a); | ||
}); | ||
} |