Skip to content

Commit

Permalink
v2.1.2
Browse files Browse the repository at this point in the history
add custom user_agent to reduce the change of encountering recaptcha;
fix generated urls with editors' name;
  • Loading branch information
nico-zck committed Jul 5, 2022
1 parent aacca59 commit 1273a87
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
13 changes: 11 additions & 2 deletions chrome/content/zsc.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ zsc.retrieveCitationData = function (item, cb) {
let citeCount;
let xhr = new XMLHttpRequest();
xhr.open("GET", url, true);
xhr.setRequestHeader("User-Agent", zsc.getUserAgent());
// xhr.responseType = "document"; // will return a HTMLDocument instead of text
xhr.onreadystatechange = function () {
if (this.readyState == 4 && this.status == 200) {
Expand Down Expand Up @@ -304,7 +305,7 @@ zsc.generateItemUrl = function (item) {
"scholar?hl=en&as_q=" +
// + zsc.cleanTitle(item.getField('title'))
item.getField("title") +
"&as_epq=&as_occt=title&num=1";
"&as_occt=title&num=1";

let creators = item.getCreators();
if (creators && creators.length > 0) {
Expand All @@ -314,7 +315,8 @@ zsc.generateItemUrl = function (item) {
url += "&as_sauthors=";
url += creators[0].lastName;
for (let idx = 1; idx < num_creators; idx++) {
url += "+" + creators[idx].lastName;
// creatorTypeID = 1, only append authors not editors
if (creators["creatorTypeID"] == 1) url += "+" + creators[idx].lastName;
}
}

Expand Down Expand Up @@ -403,6 +405,13 @@ zsc.getBaseUrl = function () {
}
};

zsc.getUserAgent = function () {
defaultUA =
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.5060.53 Safari/537.36";
// userUA = getPref("userAgent");
return defaultUA;
};

if (typeof window !== "undefined") {
window.addEventListener(
"load",
Expand Down
2 changes: 1 addition & 1 deletion install.rdf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<Description about="urn:mozilla:install-manifest">
<em:id>[email protected]</em:id>
<em:name>Zotero Scholar Citations</em:name>
<em:version>2.1.1</em:version>
<em:version>2.1.2</em:version>
<em:type>2</em:type>
<em:multiprocessCompatible>true</em:multiprocessCompatible>
<em:creator>Nico</em:creator>
Expand Down
6 changes: 3 additions & 3 deletions update.rdf
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
<rdf:Seq>
<rdf:li>
<rdf:Description>
<em:version>2.1.1</em:version>
<em:version>2.1.2</em:version>

<em:targetApplication>
<rdf:Description>
<em:id>[email protected]</em:id>
<em:minVersion>5.0.0</em:minVersion>
<em:maxVersion>6.*</em:maxVersion>
<em:updateLink>https://github.com/nico-zck/zotero-scholar-citations/releases/download/2.1.1/zotero-scholar-citations-2.1.1.xpi</em:updateLink>
<em:updateLink>https://github.com/nico-zck/zotero-scholar-citations/releases/download/2.1.2/zotero-scholar-citations-2.1.2.xpi</em:updateLink>
</rdf:Description>
</em:targetApplication>

Expand All @@ -22,7 +22,7 @@
<em:id>[email protected]</em:id>
<em:minVersion>4.999</em:minVersion>
<em:maxVersion>6.*</em:maxVersion>
<em:updateLink>https://github.com/nico-zck/zotero-scholar-citations/releases/download/2.1.1/zotero-scholar-citations-2.1.1.xpi</em:updateLink>
<em:updateLink>https://github.com/nico-zck/zotero-scholar-citations/releases/download/2.1.2/zotero-scholar-citations-2.1.2.xpi</em:updateLink>
</rdf:Description>
</em:targetApplication>

Expand Down

0 comments on commit 1273a87

Please sign in to comment.