Permalink
Browse files

v0.3.7

  • Loading branch information...
coronin committed Dec 23, 2011
1 parent 43ff34a commit e4a8417012325496d3d7a8f843fefb8dd653135d
Showing with 126 additions and 53 deletions.
  1. +5 −3 README
  2. +33 −13 background.html
  3. +63 −28 contentscript.js
  4. +4 −0 jquery171.js
  5. +1 −1 manifest.json
  6. +19 −7 options.html
  7. +1 −1 popup.html
  8. BIN v0.3.7.zip
View
8 README
@@ -12,11 +12,11 @@ Detailed enhancement includes:
* Direct link to its PDF file
* External pages related to the article
* Faculty 1000 score and link to its comment page
- * "Peaks", which is based on Impact Factor (the playground for "Peaks" is at http://paperlink2.appspot.com/static/peaks.html)
+ * "Peaks", which is based on Impact Factor (the playground for "Peaks" is at http://2.thepaperlink.com/static/peaks.html)
* Email PDF file to yourself
* Extract PMID on any webpage
-This extension is built using API from http://pubmeder.appspot.com, http://thepaperlink.appspot.com and PubMed eUtils.
+This extension is built using API from http://www.pubmeder.com, http://www.thepaperlink.com and PubMed eUtils.
For Firefox, please use the following:
@@ -38,6 +38,8 @@ Source of this extension is at https://github.com/coronin/thepaperlink-chrome
Change Log:
+ * v0.3.7 - automatically enable the reverse proxy; jQuery 1.7.1
+ * v0.3.6.3 - "save it" to www.douban.com
* v0.3.6.2 - bug fix for v0.3.6
* v0.3.6 - "pubmeder it" changed to "save it", option page update
* v0.3.5.2 - option to disable the context menu
@@ -60,5 +62,5 @@ Change Log:
* v0.2.2 - add https support
* v0.2.1 - bug fix
* v0.2.0 - two-hit for fast data fetching
- * v0.1.2 - "pubmeder all" for users of "pubmeder at appspot.com"
+ * v0.1.2 - "pubmeder all" for users of http://www.pubmeder.com
* v0.1.1 - first public version
View
@@ -4,7 +4,7 @@
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<title>background for PubMed-er</title>
- <script type="text/javascript" src="jquery17.js"></script>
+ <script type="text/javascript" src="jquery171.js"></script>
<script type="text/javascript"><!--
current_tabId = undefined;
@@ -176,6 +176,7 @@
m_status = localStorage.getItem('mendeley_status'),
f_status = localStorage.getItem('facebook_status'),
d_status = localStorage.getItem('dropbox_status'),
+ b_status = localStorage.getItem('douban_status'),
cloud_op = '',
apikey = localStorage.getItem('thepaperlink_apikey'),
rev_proxy = localStorage.getItem('rev_proxy'),
@@ -192,6 +193,9 @@
if (d_status && d_status === 'success') {
cloud_op += 'd';
}
+ if (b_status && b_status === 'success') {
+ cloud_op += 'b';
+ }
if (apikey === null) {
apikey = 'G0oasfw0382Wd3oQ0l1LiWzE'; // temp apikey, may disabled in the future
//chrome.tabs.create({ url: chrome.extension.getURL("/options.html") });
@@ -216,7 +220,7 @@
}
} else {
chrome.tabs.sendRequest(sender.tab.id,
- {except:1, uri:uri});
+ {except:1, tpl:apikey});
}
});
});
@@ -237,17 +241,21 @@
localStorage.setItem(request.service + '_status', 'error? try again please');
}
reLoadOp();
- } else if (request.sendID && localStorage.getItem('co_pubmed') !== 'no') {
- chrome.pageAction.show(sender.tab.id);
- localStorage.setItem('tabId:' + sender.tab.id.toString(), request.sendID);
- var dotCheck = /\./,
- pmcCheck = /PMC/;
- if (dotCheck.test(request.sendID) || pmcCheck.test(request.sendID)) {
- eSearch(request.sendID, sender.tab.id);
- }
- } else if (request.menu_display && localStorage.getItem('contextMenu_shown') !== 'no') {
- menu_generator();
- // just generated context menu
+ } else if (request.sendID) {
+ if (localStorage.getItem('co_pubmed') !== 'no') {
+ chrome.pageAction.show(sender.tab.id);
+ localStorage.setItem('tabId:' + sender.tab.id.toString(), request.sendID);
+ var dotCheck = /\./,
+ pmcCheck = /PMC/;
+ if (dotCheck.test(request.sendID) || pmcCheck.test(request.sendID)) {
+ eSearch(request.sendID, sender.tab.id);
+ }
+ } else { console.log('do nothing to ' + request.sendID); }
+ } else if (request.menu_display) {
+ if (localStorage.getItem('contextMenu_shown') !== 'no') {
+ menu_generator();
+ // just generated context menu
+ } else { console.log('no need to update context menu'); }
} else if (request.upload_url && request.pdf && request.pmid && request.apikey) {
console.log(request.pdf);
var pdf_data = getBinary(request.pdf), msg;
@@ -265,9 +273,21 @@
}
);
} }
+ } else {
+ console.log(request);
}
}
chrome.extension.onRequest.addListener(getRequest);
+
+$.ajax({
+ url: 'https://thepaperlink.appspot.com/static/humans.txt',
+ dataType: 'text',
+ timeout: 4000,
+ success: function() { console.log('Hi, you can access our secured server directly.'); },
+ error: function() {
+ console.log('error? force rev_proxy');
+ localStorage.setItem('rev_proxy', 'yes'); }
+});
//-->
</script>
</head>
View
@@ -35,33 +35,36 @@ function parse_id(a) { // pubmeder code
return ID;
}
-var noRun = 0;
+var noRun = 0,
+ page_url = document.URL,
+ page_body = document.body;
-if (document.URL === 'http://www.thepaperlink.com/reg'
- || document.URL === 'http://thepaperlink.appspot.com/reg'
- || document.URL === 'https://thepaperlink.appspot.com/reg'
- || document.URL === 'http://0.pl4.me/reg') { // storage data for access the api server
+if (page_url === 'http://www.thepaperlink.com/reg'
+ || page_url === 'http://www.thepaperlink.net/reg'
+ || page_url === 'http://thepaperlink.appspot.com/reg'
+ || page_url === 'https://thepaperlink.appspot.com/reg'
+ || page_url === 'http://0.pl4.me/reg') { // storage data for access the api server
console.log('the Paper Link, setup a');
var apikey = $('apikey').innerHTML;
a_proxy({thepaperlink_apikey: apikey});
noRun = 1;
-} else if (document.URL === 'http://www.pubmeder.com/registration'
- || document.URL === 'http://pubmeder.appspot.com/registration'
- || document.URL === 'https://pubmeder.appspot.com/registration'
- || document.URL === 'http://1.pl4.me/registration') { // storage data for access the bookmark server
+} else if (page_url === 'http://www.pubmeder.com/registration'
+ || page_url === 'http://pubmeder.appspot.com/registration'
+ || page_url === 'https://pubmeder.appspot.com/registration'
+ || page_url === 'http://1.pl4.me/registration') { // storage data for access the bookmark server
console.log('the Paper Link, setup b');
var email = $('currentUser').innerHTML,
apikey = $('apikey_pubmeder').innerHTML;
a_proxy({pubmeder_apikey: apikey, pubmeder_email: email});
noRun = 1;
-} else if (document.URL.indexOf('://www.thepaperlink.com/oauth') > 0) {
+} else if (page_url.indexOf('://www.thepaperlink.com/oauth') > 0) {
console.log('the Paper Link, setup m f d');
var content = $('r_content').innerHTML,
service = $('r_success').innerHTML;
a_proxy({service: service, content: content});
noRun = 1;
-} else if (document.URL.indexOf('://www.ncbi.nlm.nih.gov/pubmed') === -1 && document.URL.indexOf('://www.ncbi.nlm.nih.gov/sites/entrez?db=pubmed&term=') === -1) {
- var ID = parse_id(document.body.innerText) || parse_id(document.body.innerHTML);
+} else if (page_url.indexOf('://www.ncbi.nlm.nih.gov/pubmed') === -1 && page_url.indexOf('://www.ncbi.nlm.nih.gov/sites/entrez?db=pubmed&') === -1) {
+ var ID = parse_id(page_body.innerText) || parse_id(page_body.innerHTML);
if (ID !== null) {
console.log('non-ncbi site, got ID ' + ID[1]);
a_proxy({sendID: ID[1]});
@@ -160,39 +163,71 @@ function run() {
pmids = pmids.substr(1, pmids.length);
pmidArray = pmids.split(',');
if (pmids) {
+ localStorage.setItem('thePaperLink_ID', pmidArray[0]);
get_Json(pmids);
}
}
if (!noRun) {
run();
}
+var alert_js = 'function alert_dev(apikey) {' +
+' if (apikey && apikey !== "G0oasfw0382Wd3oQ0l1LiWzE") {' +
+' var oXHR = new XMLHttpRequest();' +
+' oXHR.open("POST", "http://0.pl4.me/?action=alert_dev&pmid=1&apikey=" + apikey, true);' +
+' oXHR.onreadystatechange = function (oEvent) {' +
+' if (oXHR.readyState === 4) {' +
+' if (oXHR.status === 200) {' +
+' console.log(oXHR.responseText);' +
+' } else {' +
+' console.log("Error", oXHR.statusText);' +
+' } }' +
+' };' +
+' oXHR.send(null);' +
+' } else {' +
+' alert("You have to be a registered user to be able to alert the developer.");' +
+' }' +
+'}';
+
chrome.extension.onRequest.addListener(
function (request, sender, sendResponse) {
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');
+ if (!search_term) {
+ search_term = page_url.split('/pubmed/')[1];
+ }
+ if (!search_term) {
+ search_term = localStorage.getItem('thePaperLink_ID');
+ }
+ var alert_script = document.createElement('script');
+ alert_script.type = 'text/javascript';
+ alert_script.text = alert_js;
+ page_body.appendChild(alert_script);
t('h2')[title_pos].innerHTML = old_title +
' <span style="font-size:14px;font-weight:normal;color:red">Error! Try ' +
'<button onclick="window.location.reload()">reload</button> or ' +
- '<button onclick="window.location.replace(\'http://www.thepaperlink.com/?q=' +
- $('search_term').value + '\')">search "the Paper Link"</button></span>';
+ '<b>Search</b> <a href="http://www.thepaperlink.com/?q=' + search_term +
+ '" target="_blank">the Paper Link</a>' +
+ '<span style="float:right;cursor:pointer" id="thepaperlink_alert" onclick="alert_dev(\'' +
+ request.tpl + '\')">&lt;!&gt;</span></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);
- }
+ if (window.location.protocol !== 'https:') {
+ 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()));
+ page_body.appendChild(jsClient);
+ }
+ } else { alert('this is a secure page, js client not working yet'); }
sendResponse({});
return;
}
@@ -209,7 +244,7 @@ chrome.extension.onRequest.addListener(
} else {
peaks.setAttribute('src', 'https://thepaperlink.appspot.com/jss?y=' + (Math.random()));
}
- document.body.appendChild(peaks);
+ page_body.appendChild(peaks);
}
styles = '.thepaperlink {'
+ ' background: #e0ecf1;'
@@ -240,7 +275,7 @@ chrome.extension.onRequest.addListener(
S = document.createElement('style');
S.type = 'text/css';
S.appendChild(document.createTextNode(styles));
- document.body.appendChild(S);
+ page_body.appendChild(S);
//GM_addStyle(styles);
}
if (request.pubmeder && old_title) {
@@ -287,7 +322,7 @@ chrome.extension.onRequest.addListener(
if (request.tpl) {
div.innerHTML += '<span id="thepaperlink_rpt' + r.item[i].pmid +
'" class="thepaperlink-home" onclick="show_me_the_money(\'' +
- r.item[i].pmid + '\',\'' + request.tpl + '\')">?</span>';
+ r.item[i].pmid + '\',\'' + request.tpl + '\')">&hellip;</span>';
}
if (request.tpl && r.item[i].pdf) {
div.innerHTML += '<span style="display:none !important;" id="thepaperlink_hidden' + r.item[i].pmid + '"></span>';
@@ -333,4 +368,4 @@ chrome.extension.onRequest.addListener(
sendResponse({});
return;
}
-);
+);
View

Large diffs are not rendered by default.

Oops, something went wrong.
View
@@ -1,6 +1,6 @@
{
"name": "__MSG_appName__",
- "version": "0.3.6.2",
+ "version": "0.3.7",
"description": "__MSG_appDesc__",
"default_locale": "en",
"permissions": [
View
@@ -12,7 +12,7 @@
li{font-size:1.3em;line-height:1.4em;padding-bottom:0.4em;}
.Off{display:none !important;}
</style>
- <script type="text/javascript" src="jquery17.js"></script>
+ <script type="text/javascript" src="jquery171.js"></script>
</head>
<body>
@@ -21,7 +21,7 @@ <h1>"the Paper Link" for PubMed - Google Chrome</h1>
<h3 style="color:red">"the Paper Link" API &ndash; required</h3>
<p><span class="thepaperlink_a">0. visit <a rel="external" href="http://www.thepaperlink.com/reg">http://www.thepaperlink.com/reg</a> to activate your own key for the service
<br/></span><input type="text" value="" size="40" id="thepaperlink_apikey" /> <a style="text-decoration:none;" rel="external" href="http://www.thepaperlink.com">the Paper Link</a> apikey
- <br/><i style="color:#ccc" class="thepaperlink_a">once enabled</i> - expandable icon <b style="background:#f0f0f0">"?"</b> will show on the bar for extra function
+ <br/><i style="color:#ccc" class="thepaperlink_a">once enabled</i> - expandable icon <b style="background:#f0f0f0">"&hellip;"</b> will show on the bar for extra function
<br/><i style="color:#ccc" class="thepaperlink_a">once enabled</i> - you will get more reliable response from our server, with much less error
<br/><i style="color:#ccc" class="thepaperlink_a">once enabled</i> - you will be able to save the articles you read to multiple service
</p>
@@ -47,17 +47,18 @@ <h3>save it &mdash; archive what you read to the cloud</h3>
&nbsp;&nbsp;[<a rel="external" href="http://www.thepaperlink.com/oauth?v=facebook" id="facebook_a">connect now</a>]
<br/><input style="display:none" type="text" value="" size="20" id="facebook_status" />
</li>
- <li><b>http://www.dropbox.com/</b> (beta testing)
+ <li><b>http://www.douban.com/</b>
+ &nbsp;&nbsp;[<a rel="external" href="http://www.thepaperlink.com/oauth?v=douban" id="douban_a">connect now</a>]
+ <br/><input style="display:none" type="text" value="" size="20" id="douban_status" />
+ </li>
+ <li><b>http://www.dropbox.com/</b> (testing)
&nbsp;&nbsp;[<a rel="external" href="http://www.thepaperlink.com/oauth?v=dropbox" id="dropbox_a">connect now</a>]
<br/><input style="display:none" type="text" value="" size="20" id="dropbox_status" />
</li>
</ul>
<h3>Other Settings</h3>
- <p><input type="checkbox" id="rev_proxy" /> If you cannot visit <a rel="external" href="http://thepaperlink.appspot.com">this page</a>, please <b>check to enable</b> the reverse proxy. 推荐中国用户使用
- <br/>Most users don't need to. Using the reverse proxy will slow down the communication with our server.
- </p>
<p><input type="checkbox" id="co_pubmed" /> Due to slightly overlapping function with <a rel="external" href="https://chrome.google.com/webstore/detail/dijkmjebgnlpkfnmbkllaggphmnplnoj">the PubMed-er Chrome extension</a>,
<br/>you could check here to <b>prevent</b> two icons shown in your address bar.
</p>
@@ -66,6 +67,7 @@ <h3>Other Settings</h3>
</p>
<p><input type="checkbox" id="contextMenu_shown" /> You could check here to <b>disable</b> the context menu triggered by right mouse click.
</p>
+ <p id="rev_proxy_content"></p>
<div style="background:#fff0f0;position:fixed;right:50px;top:50px;padding:20px"><button id="saveBtn" class="Off" onclick="saveOptions()">Save All Options</button></div>
@@ -80,6 +82,7 @@ <h3>Other Settings</h3>
m_status = localStorage.getItem('mendeley_status'),
f_status = localStorage.getItem('facebook_status'),
d_status = localStorage.getItem('dropbox_status');
+ b_status = localStorage.getItem('douban_status');
if (a_key) {
$('#thepaperlink_apikey').val(a_key);
$('.thepaperlink_a').css('display', 'none');
@@ -104,8 +107,17 @@ <h3>Other Settings</h3>
$('#dropbox_status').val('status: ' + d_status);
$('#dropbox_a').html('check connection');
}
+ if (b_status) {
+ $('#douban_status').css('display', 'inline');
+ $('#douban_status').val('status: ' + b_status);
+ $('#douban_a').html('check connection');
+ }
if (localStorage.getItem('rev_proxy') === 'yes') {
- $('#rev_proxy').prop('checked', true);
+ $('#rev_proxy_content').html('<input type="checkbox" id="rev_proxy" checked /> You are using <b>our reverse proxy</b> to access "the Paper Link". 推荐中国用户使用' +
+ '<br/>It is slower, but more accessible.');
+ } else {
+ $('#rev_proxy_content').html('<input type="checkbox" id="rev_proxy" /> You don\'t need to use the reverse proxy, which will be slower.' +
+ '<br/>But, if you want, you can <b>check to enable</b> the reverse proxy. 推荐中国用户使用');
}
if (localStorage.getItem('co_pubmed') === 'no') {
$('#co_pubmed').prop('checked', true);
View
@@ -21,7 +21,7 @@
.Off {display:none;}
-->
</style>
- <script type="text/javascript" src="jquery17.js"></script>
+ <script type="text/javascript" src="jquery171.js"></script>
</head>
<body>
<p><input id="ess" type="text" value="Search PubMed" onkeydown="if (event.keyCode == 13) eSS(ess.value)" />
View
Binary file not shown.

0 comments on commit e4a8417

Please sign in to comment.