Skip to content
This repository has been archived by the owner on Dec 26, 2020. It is now read-only.

Commit

Permalink
Merge branch 'release/1.9.4'
Browse files Browse the repository at this point in the history
  • Loading branch information
MaxKuehn committed Apr 6, 2019
2 parents 82fd0aa + 0ab9438 commit e549222
Show file tree
Hide file tree
Showing 27 changed files with 507 additions and 49 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
.project
node_modules/
24 changes: 17 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,30 @@ When updating multiple citations in a batch, it may happen that citation queries

Currently, Zotero doesn't have any special field for the number of citations, that's why it is stored in the "Extra" field. To sort by this field you have to add it in the source listing table.

*Note* Apparently Zotero now supports [adding custom fields](https://github.com/beloglazov/zotero-scholar-citations/issues/37), soo this might be comming soon(tm)!

*IMPORTANT:* in version 1.8 the field for storing the number of citations has been changed from "Call Number" to "Extra" -- please update your column configuration.

The add-on supports both versions of Zotero:

1. Zotero Standalone:
- Download the add-on from https://github.com/beloglazov/zotero-scholar-citations/raw/master/builds/zotero-scholar-citations-1.9.3-fx.xpi
- In Zotero Standalone go to Tools -> Add-ons -> click the settings button in the top-right corner -> Install Add-on From File -> select the downloaded file and restart Zotero.
2. Zotero for Firefox:
- Install the Firefox add-on from https://addons.mozilla.org/en-us/firefox/addon/zotero-scholar-citations/
1. Download the newest version of the add-on from [the release page](https://github.com/MaxKuehn/zotero-scholar-citations/releases)
1. In Zotero (Standalone) go to Tools -> Add-ons -> click the settings button in the top-right corner -> Install Add-on From File -> select the downloaded file and restart Zotero.

Read about how the add-on was made: http:https://blog.beloglazov.info/2009/10/zotero-citations-from-scholar-en.html

## Why the Fork

The original maintainer [Anton Beloglazov](https://github.com/beloglazov) seems semi-active.

[Texot](https://github.com/tete1030) fixed some stuff that needed fixing BADly, i.e.

- Fix detection of google robot checking
- Show `No Citation Data` in failure cases instead of `00000`

But there's more to do!

# License

Copyright (C) 2011-2013 Anton Beloglazov
Copyright (C) 2011-2013 Anton Beloglazov?

Distributed under the Mozilla Public License (MPL).
Distributed under the Mozilla Public License 2.0 (MPL).
10 changes: 7 additions & 3 deletions build.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
#!/bin/sh

version=1.9.3
rm builds/zotero-scholar-citations-${version}-fx.xpi
zip -r builds/zotero-scholar-citations-${version}-fx.xpi chrome/* chrome.manifest install.rdf
version=1.9.4
rm build -rf
if [ -z $DEBUG ]; then
zip -r builds/zotero-scholar-citations-${version}-fx.xpi chrome/* chrome.manifest install.rdf
else
zip -r builds/zotero-scholar-citations-${version}-debug.xpi chrome/* chrome.manifest install.rdf
fi
Binary file removed builds/zotero-scholar-citations-1.4-fx.xpi
Binary file not shown.
Binary file removed builds/zotero-scholar-citations-1.5-fx.xpi
Binary file not shown.
Binary file removed builds/zotero-scholar-citations-1.6-fx.xpi
Binary file not shown.
Binary file removed builds/zotero-scholar-citations-1.7-fx.xpi
Binary file not shown.
Binary file removed builds/zotero-scholar-citations-1.8-fx.xpi
Binary file not shown.
Binary file removed builds/zotero-scholar-citations-1.8.1-fx.xpi
Binary file not shown.
Binary file removed builds/zotero-scholar-citations-1.8.2-fx.xpi
Binary file not shown.
Binary file removed builds/zotero-scholar-citations-1.8.3-fx.xpi
Binary file not shown.
Binary file removed builds/zotero-scholar-citations-1.8.4-fx.xpi
Binary file not shown.
Binary file removed builds/zotero-scholar-citations-1.8.5-fx.xpi
Binary file not shown.
Binary file removed builds/zotero-scholar-citations-1.8.6-fx.xpi
Binary file not shown.
Binary file removed builds/zotero-scholar-citations-1.8.7-fx.xpi
Binary file not shown.
Binary file removed builds/zotero-scholar-citations-1.8.8-fx.xpi
Binary file not shown.
Binary file removed builds/zotero-scholar-citations-1.9.0-fx.xpi
Binary file not shown.
Binary file removed builds/zotero-scholar-citations-1.9.1-fx.xpi
Binary file not shown.
Binary file removed builds/zotero-scholar-citations-1.9.2-fx.xpi
Binary file not shown.
Binary file removed builds/zotero-scholar-citations-1.9.3-fx.xpi
Binary file not shown.
3 changes: 1 addition & 2 deletions chrome/content/overlay.xul
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@
</popup>

<popup
id="zotero-itemmenu"
onpopupshowing="ZoteroPane.buildItemContextMenu();">
id="zotero-itemmenu">
<menuitem
id="zotero-itemmenu-scholarcitations"
label="&zotero.scholarcitations.update.label;"
Expand Down
35 changes: 22 additions & 13 deletions chrome/content/scripts/zoteroscholarcitations.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,30 +139,31 @@ Zotero.ScholarCitations.generateItemUrl = function(item) {
Zotero.ScholarCitations.updateItem = function(item) {
var req = new XMLHttpRequest();
var url = Zotero.ScholarCitations.generateItemUrl(item);
if (Zotero.Debug.enabled) Zotero.debug("[scholar-citations] GET " + url);
req.open('GET', url, true);

req.onreadystatechange = function() {
if (req.readyState == 4) {
if (req.status == 200 && req.responseText.search("RecaptchaOptions") == -1) {
if (req.status == 200 && req.responseText.search("www.google.com/recaptcha/api.js") == -1) {
if (item.isRegularItem() && !item.isCollection()) {
var citations = Zotero.ScholarCitations.getCitationCount(
req.responseText);
try {
var old = item.getField('extra')
if (old.length == 0 || old.search(/^\d{5}$/) != -1) {
if (old.length == 0 || old.search(/^(\d{5}|No Citation Data)$/) != -1) {
item.setField('extra', citations);
} else if (old.search(/^\d{5} *\n/) != -1) {
} else if (old.search(/^(\d{5}|No Citation Data) *\n/) != -1) {
item.setField(
'extra',
old.replace(/^\d{5} */, citations + ' '));
} else if (old.search(/^\d{5} *[^\n]+/) != -1) {
old.replace(/^(\d{5}|No Citation Data) */, citations + ' '));
} else if (old.search(/^(\d{5}|No Citation Data) *[^\n]+/) != -1) {
item.setField(
'extra',
old.replace(/^\d{5} */, citations + ' \n'));
} else if (old.search(/^\d{5}/) != -1) {
old.replace(/^(\d{5}|No Citation Data) */, citations + ' \n'));
} else if (old.search(/^(\d{5}|No Citation Data)/) != -1) {
item.setField(
'extra',
old.replace(/^\d{5}/, citations));
old.replace(/^(\d{5}|No Citation Data)/, citations));
} else {
item.setField('extra', citations + ' \n' + old);
}
Expand All @@ -178,12 +179,12 @@ Zotero.ScholarCitations.updateItem = function(item) {
req2.open('GET', url, true);
req2.onreadystatechange = function() {
if (req2.readyState == 4) {
if (typeof Zotero.launchURL !== 'undefined') {
Zotero.launchURL(url);
} else if (typeof Zotero.openInViewer !== 'undefined') {
if (typeof Zotero.openInViewer !== 'undefined') {
Zotero.openInViewer(url);
} else if (typeof ZoteroStandalone !== 'undefined') {
ZoteroStandalone.openInViewer(url);
} else if (typeof Zotero.launchURL !== 'undefined') {
Zotero.launchURL(url);
} else {
window.gBrowser.loadOneTab(
url, {inBackground: false});
Expand All @@ -192,6 +193,8 @@ Zotero.ScholarCitations.updateItem = function(item) {
}
}
req2.send(null);
} else {
if (Zotero.Debug.enabled) Zotero.debug("[scholar-citations] req.status == " + req.status);
}
}
};
Expand All @@ -211,16 +214,22 @@ Zotero.ScholarCitations.fillZeros = function(number) {

Zotero.ScholarCitations.getCitationCount = function(responseText) {
if (responseText == '') {
return '00000';
return 'No Citation Data';
}

var citeStringLength = 15;
var lengthOfCiteByStr = 9;
var citeArray = new Array();

// 'gs_r gs_or gs_scl' is classes of each item element in search result
var resultExists = responseText.match('gs_r gs_or gs_scl') ? true : false;

var citeExists = responseText.search('Cited by');
if (citeExists == -1) {
return '00000';
if (resultExists)
return '00000';
else
return 'No Citation Data';
}

var tmpString = responseText.substr(citeExists, citeStringLength);
Expand Down
2 changes: 1 addition & 1 deletion install.rdf
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
RDF:about="urn:mozilla:install-manifest"
em:id="[email protected]"
em:name="Zotero Scholar Citations"
em:version="1.9.3"
em:version="1.9.4"
em:type="2"
em:creator="Anton Beloglazov"
em:description="Zotero plugin for auto-fetching numbers of citations from Google Scholar"
Expand Down
Loading

0 comments on commit e549222

Please sign in to comment.