Skip to content

Commit

Permalink
Update zsc.js
Browse files Browse the repository at this point in the history
add debug string when not got meaningful response or captcha.
  • Loading branch information
nico-zck committed Aug 27, 2020
1 parent e2b26a1 commit 74079c5
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions chrome/content/zsc.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,11 +183,16 @@ zsc.retrieveCitationData = function(item, cb) {
xhr.open('GET', url, true);
xhr.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
if (this.responseText.indexOf('www.google.com/recaptcha/api.js') == -1) {
// // debug on response text
// if (isDebug()) Zotero.debug(this.responseText);

// check if response includes meaningful content
if (this.responseText.indexOf('class="gs_r gs_or gs_scl"') != -1) {
if (isDebug()) Zotero.debug('[scholar-citations] '
+ 'recieved non-captcha scholar results');
cb(item, zsc.getCiteCount(this.responseText));
} else {
// check if response includes captcha
} else if (this.responseText.indexOf('www.google.com/recaptcha/api.js') != -1){
if (isDebug()) Zotero.debug('[scholar-citations] '
+ 'received a captcha instead of a scholar result');
alert(zsc._captchaString);
Expand All @@ -200,6 +205,11 @@ zsc.retrieveCitationData = function(item, cb) {
} else {
window.gBrowser.loadOneTab(url, {inBackground: false});
}
} else {
// debug response text in other cases
if (isDebug()) Zotero.debug('[scholar-citations] '
+ 'neither got meaningful text or captcha, please check the following response text');
if (isDebug()) Zotero.debug(this.responseText);
}
} else if (this.readyState == 4 && this.status == 429) {
if (this.responseText.indexOf('www.google.com/recaptcha/api.js') == -1) {
Expand Down

0 comments on commit 74079c5

Please sign in to comment.