Skip to content

Commit

Permalink
Update zsc.js
Browse files Browse the repository at this point in the history
fix the error when encouter special characters from paper title in the url.
  • Loading branch information
nico-zck committed Sep 30, 2020
1 parent 74079c5 commit c86517a
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions chrome/content/zsc.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ let zsc = {
_extraPrefix: 'ZSCC',
_extraEntrySep: ' \n',
_noData : 'NoCitationData',
_searchblackList: new RegExp('[-+~*":]', 'g'),
// _searchblackList: new RegExp('[-+~*":]', 'g'),
_baseUrl : 'https://scholar.google.com/'
};

Expand Down Expand Up @@ -210,6 +210,7 @@ zsc.retrieveCitationData = function(item, cb) {
if (isDebug()) Zotero.debug('[scholar-citations] '
+ 'neither got meaningful text or captcha, please check the following response text');
if (isDebug()) Zotero.debug(this.responseText);
alert('neither got meaningful text or captcha, please check it in log')
}
} else if (this.readyState == 4 && this.status == 429) {
if (this.responseText.indexOf('www.google.com/recaptcha/api.js') == -1) {
Expand Down Expand Up @@ -246,8 +247,9 @@ zsc.retrieveCitationData = function(item, cb) {

zsc.generateItemUrl = function(item) {
let url = this._baseUrl
+ 'scholar?hl=en&as_q='
+ zsc.cleanTitle(item.getField('title')).split(/\s/).join('+')
+ 'scholar?hl=en&q='
// + zsc.cleanTitle(item.getField('title'))
+ item.getField('title')
+ '&as_epq=&as_occt=title&num=1';

let creators = item.getCreators();
Expand All @@ -272,9 +274,11 @@ zsc.generateItemUrl = function(item) {
return encodeURI(url);
};

zsc.cleanTitle = function(title) {
return title.replace(zsc._searchblackList, ' ');
};
// zsc.cleanTitle = function(title) {
// let clean_title = title.replace(zsc._searchblackList, ' ');
// clean_title = clean_title.split(/\s/).join('+');
// return clean_title;
// };

zsc.padLeftWithZeroes = function(numStr) {
let output = '';
Expand Down

0 comments on commit c86517a

Please sign in to comment.