Skip to content

Commit

Permalink
Fixed bug with new paperswithcode version
Browse files Browse the repository at this point in the history
  • Loading branch information
eladrich committed Dec 31, 2021
1 parent 9a87882 commit ee174e8
Show file tree
Hide file tree
Showing 5 changed files with 95 additions and 93 deletions.
86 changes: 44 additions & 42 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,42 +1,44 @@
# Scholar With Code

[![Chrome Web Store](https://img.shields.io/chrome-web-store/v/nlnjigejpgngahmoainkakaafabijeki)](https://chrome.google.com/webstore/detail/scholar-with-code/nlnjigejpgngahmoainkakaafabijeki)

A simple chrome extension to present the number of available code implementions (via `Papers With Code`) for articles listed on `Google Scholar` and `arXiv`.

<p align="center">
<img src="docs/teaser_scholar.gif" width="800px"/>
</p>
<br>
<p align="center">
<img src="docs/teaser_arxiv.gif" width="800px"/>
</p>

## Recent Updates
**`2020.07.15`**: Added arXiv Support

**`2020.06.24`**: Chrome Extension release

**`2020.06.16`**: First Release


## Why?
Two of the most used tools for me during research are `Google Scholar` and `Papers with Code`, together giving a full view of citations and code implementations.

I've noticed that a thing that I do a lot is to start from a paper I know, go through the "Papers that cite this work" page on `Google Scholar`, and then for each paper check whether it has a code implementation using `Papers With Code`.

As it is kind of annoying to go back and forth between the two, I've written a small chrome extension that shows whether the paper has code implementation and links to the matching page on `Papers with Code`.

<p align="center">
<img src="docs/teaser_scholar.png" width="800px"/>
</p>

## Installation

Extension is available in the [Chrome Web Store](https://chrome.google.com/webstore/detail/scholar-with-code/nlnjigejpgngahmoainkakaafabijeki). Alternatively you can download the project directory and drag it to your chrome extensions.


## TODOs
- [x] Publish to Chrome Web Store
- [x] Check how to remove permissions to all sites
- [x] Support arXiv.org
# Scholar With Code

[![Chrome Web Store](https://img.shields.io/chrome-web-store/v/nlnjigejpgngahmoainkakaafabijeki)](https://chrome.google.com/webstore/detail/scholar-with-code/nlnjigejpgngahmoainkakaafabijeki)

A simple chrome extension to present the number of available code implementations (via `Papers With Code`) for articles listed on `Google Scholar` and `arXiv`.

<p align="center">
<img src="docs/teaser_scholar.gif" width="800px"/>
</p>
<br>
<p align="center">
<img src="docs/teaser_arxiv.gif" width="800px"/>
</p>

## Recent Updates
**`2021.11.18`**: Minor fix to support changes in `Papers With Code`

**`2020.07.15`**: Added arXiv Support

**`2020.06.24`**: Chrome Extension release

**`2020.06.16`**: First Release


## Why?
Two of the most used tools for me during research are `Google Scholar` and `Papers with Code`, together giving a full view of citations and code implementations.

I've noticed that a thing that I do a lot is to start from a paper I know, go through the "Papers that cite this work" page on `Google Scholar`, and then for each paper check whether it has a code implementation using `Papers With Code`.

As it is kind of annoying to go back and forth between the two, I've written a small chrome extension that shows whether the paper has code implementation and links to the matching page on `Papers with Code`.

<p align="center">
<img src="docs/teaser_scholar.png" width="800px"/>
</p>

## Installation

Extension is available in the [Chrome Web Store](https://chrome.google.com/webstore/detail/scholar-with-code/nlnjigejpgngahmoainkakaafabijeki). Alternatively you can download the project directory and drag it to your chrome extensions.


## TODOs
- [x] Publish to Chrome Web Store
- [x] Check how to remove permissions to all sites
- [x] Support arXiv.org
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.3",
"version": "1.0.4",
"icons":{
"493":"docs/logo.png"
},
Expand Down
58 changes: 29 additions & 29 deletions src/background.js
Original file line number Diff line number Diff line change
@@ -1,29 +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
}
}
sendResponse({txt: txt, paper_link: paper_link, payload: request.payload});
}
}
xhr.send();
return true;
});
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[1].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;
});
18 changes: 9 additions & 9 deletions src/content_arxiv.js
Original file line number Diff line number Diff line change
@@ -1,9 +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);
});
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);
});
24 changes: 12 additions & 12 deletions src/content_scholar.js
Original file line number Diff line number Diff line change
@@ -1,12 +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);
});
}
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);
});
}

0 comments on commit ee174e8

Please sign in to comment.