Skip to content
Browse files

v0.3.5.1

  • Loading branch information...
1 parent afe6423 commit 5f248eb93e2f4379273ef3051973f51e436bcf62 @coronin committed
Showing with 75 additions and 20 deletions.
  1. +1 −0 README
  2. +24 −5 background.html
  3. +20 −6 contentscript.js
  4. +30 −9 manifest.json
  5. BIN v0.3.5.1.zip
View
1 README
@@ -38,6 +38,7 @@ Source of this extension is at https://github.com/coronin/thepaperlink-chrome
Change Log:
+ * v0.3.5.1 - context menu for page
* v0.3.5 - context menu for selected text
* v0.3.4.1 - bug fix of its Option page
* v0.3.4 - bug fix (single no-repeat call, insert title_pos, multi-tab); update to jQuery 1.6.3
View
29 background.html
@@ -8,9 +8,9 @@
<script type="text/javascript"><!--
current_tabId = undefined;
function openNewTab(winId,url) {
- chrome.tabs.create({'windowId': winId, 'url': url, 'selected': true, 'pinned': true}, function (tab) {
+ chrome.tabs.create({'windowId': winId, 'url': url, 'selected': true}, function (tab) {
current_tabId = tab.id;
- console.log('new pinned tab for your search #' + current_tabId);
+ console.log('new tab for your search #' + current_tabId);
});
}
@@ -43,8 +43,27 @@
}
}
-chrome.contextMenus.create({'title': 'Search the_Paper_Link for \'%s\'', 'contexts':['selection'], "onclick": selectOnClick});
-chrome.contextMenus.create({'title': 'Visit the_Paper_Link', 'contexts':['page', 'link', 'editable', 'image', 'video', 'audio'], "onclick": genericOnClick});
+function callJsOnClick(info,tab) {
+ var apikey = localStorage.getItem('thepaperlink_apikey'),
+ rev_proxy = localStorage.getItem('rev_proxy'),
+ base;
+ if (rev_proxy === 'yes') {
+ base = 'http://0.pl4.me/';
+ } else {
+ base = 'https://thepaperlink.appspot.com/';
+ }
+ if (apikey === null) {
+ apikey = 'G0oasfw0382Wd3oQ0l1LiWzE'; // temp apikey, may disabled in the future
+ }
+ chrome.tabs.getSelected(tab.windowId, function () {
+ chrome.tabs.sendRequest(tab.id, {js_key: apikey, js_base: base});
+ });
+}
+
+chrome.contextMenus.create({'title': 'Search the_Paper_Link for \'%s\'', 'contexts':['selection'], 'onclick': selectOnClick});
+chrome.contextMenus.create({'title': 'Find ID on this page', 'contexts':['page'], 'onclick': callJsOnClick});
+chrome.contextMenus.create({'title': 'Visit the_Paper_Link', 'contexts':['page', 'link', 'editable', 'image', 'video', 'audio'], 'onclick': genericOnClick});
+
function eSearch(search_term, tabId) {
var url = 'http://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi?tool=thepaperlink_chrome&db=pubmed&term=' + search_term;
@@ -161,7 +180,7 @@
if (request.url) {
$.getJSON(uri + request.url + apikey, function (d) {
chrome.tabs.getSelected(sender.tab.windowId, function () {
- if (d && (d.count || d.error)) {
+ if (d && (d.count || d.error)) { // good or bad, both got json return
if (localStorage.getItem('thepaperlink_apikey')) {
chrome.tabs.sendRequest(sender.tab.id, {r: d, tail: tail, tpl: apikey, save_key: pubmeder_apikey, save_email: pubmeder_email, uri: uri});
} else {
View
26 contentscript.js
@@ -155,6 +155,25 @@ chrome.extension.onRequest.addListener(
var r = request.r,
div, i, j, k, S, styles, peaks,
bookmark_div = '<div id="css_loaded"></div>';
+ if (request.except) {
+ console.log('oops, no json return from the server');
+ t('h2')[title_pos].innerHTML = old_title + ' <span style="font-size:14px;font-weight:normal;color:red">error in "the Paper Link" <button onclick="window.location.reload();">try reload?</button></span>';
+ sendResponse({});
+ return;
+ }
+ if (request.js_key && request.js_base) {
+ console.log('starting the js client');
+ localStorage.setItem('thePaperLink_pubget_js_key', request.js_key);
+ localStorage.setItem('thePaperLink_pubget_js_base', request.js_base);
+ if (!$('__tr_display')) {
+ var jsClient = document.createElement('script');
+ jsClient.setAttribute('type', 'text/javascript');
+ jsClient.setAttribute('src', request.js_base + 'js?y=' + (Math.random()));
+ document.body.appendChild(jsClient);
+ }
+ sendResponse({});
+ return;
+ }
if (!$('paperlink2_display')) {
peaks = document.createElement('script');
peaks.setAttribute('type', 'text/javascript');
@@ -165,11 +184,6 @@ chrome.extension.onRequest.addListener(
}
document.body.appendChild(peaks);
}
- if (request.except) {
- t('h2')[title_pos].innerHTML = old_title + ' <span style="font-size:14px;font-weight:normal;color:red">error in "the Paper Link" <button onclick="window.location.reload();">try reload?</button></span>';
- sendResponse({});
- return;
- }
if (r.error) {
t('h2')[title_pos].innerHTML = old_title + ' <span style="font-size:14px;font-weight:normal;color:red">"the Paper Link" error : ' + r.error + '</span>';
sendResponse({});
@@ -267,4 +281,4 @@ chrome.extension.onRequest.addListener(
sendResponse({});
return;
}
-);
+);
View
39 manifest.json
@@ -1,17 +1,26 @@
{
"name": "the Paper Link for PubMed",
- "version": "0.3.5",
+ "version": "0.3.5.1",
"description": "Add direct PDF link; display F1000 scores, Impact Factor, Peaks and much more... (by Liang Cai, for Google Chrome)",
"permissions": [
- "tabs",
"contextMenus",
- "*://*/*"
+ "tabs",
+ "https://www.ncbi.nlm.nih.gov/*",
+ "https://thepaperlink.appspot.com/*",
+ "https://pubmeder.appspot.com/*",
+ "http://*.gov/*",
+ "http://*.org/*",
+ "http://*.net/*",
+ "http://*.com/*",
+ "http://*.info/*",
+ "http://*.jp/*",
+ "http://*.pl4.me/*"
],
"icons": {
"128": "128.png",
"48": "48.png",
"19": "19.png",
- "16": "16.png"
+ "16": "16.png"
},
"options_page" : "options.html",
"background_page" : "background.html",
@@ -21,12 +30,24 @@
"default_popup" : "popup.html"
},
"content_scripts": [ {
- "matches": [ "http://*/*", "https://*/*" ],
- "exclude_globs": [ "*://www.ncbi.nlm.nih.gov/pubmed/",
- "*://www.ncbi.nlm.nih.gov/sites/entrez?db=pubmed"
- ],
+ "matches": [
+ "https://www.ncbi.nlm.nih.gov/*",
+ "https://thepaperlink.appspot.com/*",
+ "https://pubmeder.appspot.com/*",
+ "http://*.gov/*",
+ "http://*.org/*",
+ "http://*.net/*",
+ "http://*.com/*",
+ "http://*.info/*",
+ "http://*.jp/*",
+ "http://*.pl4.me/*"
+ ],
+ "exclude_globs": [
+ "*://www.ncbi.nlm.nih.gov/pubmed/",
+ "*://www.ncbi.nlm.nih.gov/sites/entrez?db=pubmed"
+ ],
"js": [ "contentscript.js" ],
"run_at" : "document_idle",
"all_frames" : true
} ]
-}
+}
View
BIN v0.3.5.1.zip
Binary file not shown.

0 comments on commit 5f248eb

Please sign in to comment.
Something went wrong with that request. Please try again.