Skip to content

Commit

Permalink
Update zsc.js
Browse files Browse the repository at this point in the history
Temporarily disable Notifier to observe add event, as the request cannot use local cookie when adding new item.
  • Loading branch information
nico-zck committed Apr 9, 2020
1 parent 9974ecc commit b6d3737
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions chrome/content/zsc.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,11 @@ zsc.init = function() {
this._citedPrefixString = stringBundle.getString('citedPrefixString');
}

// Register the callback in Zotero as an item observer
let notifierID = Zotero.Notifier.registerObserver(
this.notifierCallback, ['item']);
// Temporarily disable Notifier to observe add event,
// as the request cannot use local cookie when adding new item.
// // Register the callback in Zotero as an item observer
// let notifierID = Zotero.Notifier.registerObserver(
// this.notifierCallback, ['item']);

// Unregister callback when the window closes (important to avoid a memory leak)
window.addEventListener('unload', function(e) {
Expand Down Expand Up @@ -182,12 +184,12 @@ zsc.retrieveCitationData = function(item, cb) {
xhr.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
if (this.responseText.indexOf('www.google.com/recaptcha/api.js') == -1) {
if (isDebug()) Zotero.debug("[scholar-citations] "
+ "recieved non-captcha scholar results");
if (isDebug()) Zotero.debug('[scholar-citations] '
+ 'recieved non-captcha scholar results');
cb(item, zsc.getCiteCount(this.responseText));
} else {
if (isDebug()) Zotero.debug("[scholar-citations] "
+ "received a captcha instead of a scholar result");
if (isDebug()) Zotero.debug('[scholar-citations] '
+ 'received a captcha instead of a scholar result');
alert(zsc._captchaString);
if (typeof Zotero.openInViewer !== 'undefined') {
Zotero.openInViewer(url);
Expand Down Expand Up @@ -229,6 +231,7 @@ zsc.retrieveCitationData = function(item, cb) {
// request progress, I guess
}
};
xhr.withCredentials = true;
xhr.send();
};

Expand Down

0 comments on commit b6d3737

Please sign in to comment.