From 9f74be22b60376f4097d0863c2154a8a6491043c Mon Sep 17 00:00:00 2001 From: Elad Richardson Date: Wed, 24 Jun 2020 18:57:01 +0300 Subject: [PATCH] Updated code to point to exact page on Paperswithcode instead of search resutls --- background.js | 4 +++- manifest.json | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/background.js b/background.js index 6d2944a..cf35ae0 100644 --- a/background.js +++ b/background.js @@ -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) { @@ -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 @@ -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( { diff --git a/manifest.json b/manifest.json index e572ecd..995caf2 100644 --- a/manifest.json +++ b/manifest.json @@ -2,7 +2,7 @@ "manifest_version": 2, "name": "Scholar with Code", - "version": "1.0.1", + "version": "1.0.2", "icons":{ "493":"logo.png" },