Skip to content

Commit

Permalink
Updated code to point to exact page on Paperswithcode instead of sear…
Browse files Browse the repository at this point in the history
…ch resutls
  • Loading branch information
eladrich committed Jun 24, 2020
1 parent 620e333 commit 9f74be2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion background.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ chrome.runtime.onMessage.addListener(function(request, sender, sendResponse) {
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)
{
Expand All @@ -14,6 +15,7 @@ chrome.runtime.onMessage.addListener(function(request, sender, sendResponse) {
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
Expand All @@ -22,7 +24,7 @@ chrome.runtime.onMessage.addListener(function(request, sender, sendResponse) {
var code_str = "var panels = document.getElementsByClassName('gs_ri');"
+"var a = document.createElement('a');"
+"a.innerText =\"" + txt +"\";"
+"a.href =\"" + paperurl +"\";"
+"a.href =\"" + paper_link +"\";"
+ "panels[" + request.ind + "].childNodes[3].appendChild(a);"

chrome.tabs.executeScript( {
Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"manifest_version": 2,

"name": "Scholar with Code",
"version": "1.0.1",
"version": "1.0.2",
"icons":{
"493":"logo.png"
},
Expand Down

0 comments on commit 9f74be2

Please sign in to comment.