Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
Adding option panel;
Adding mirror site support;
Adding Chinese localization;
  • Loading branch information
nico-zck committed Jun 21, 2023
1 parent 9b6ca9a commit d474ae6
Show file tree
Hide file tree
Showing 18 changed files with 332 additions and 311 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,5 @@ build/
builds/
.DS_Store
package-lock.json

.VSCodeCounter
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ v2.1.0

## Development
1. Clone this source code.
2. Create a text file in the 'extensions' directory of your Zotero profile directory named after the extension id `zoteroscholarcitations@nico.info`. The file contents should be the absolute path to the root of your plugin source code directory, where your install.rdf file is located.
2. Create a text file in the 'extensions' directory of your Zotero profile directory (refer to [this](https://www.zotero.org/support/dev/client_coding/plugin_development) for your profile path) named after the extension id `zoteroscholarcitations@nico.info`. The file contents should be the absolute path to the root of your plugin source code directory, where your install.rdf file is located.
3. Open prefs.js in the Zotero profile directory in a text editor and delete the lines containing `extensions.lastAppBuildId` and `extensions.lastAppVersion`. Save the file and restart Zotero. This will force Zotero to read the extensions' directory and install your plugin from source, after which you should see it listed in Tools → Add-ons. This is only necessary once.
4. Run zotero with argments `-purgecaches -ZoteroDebug`, for example:
>./zotero.exe -purgecaches -ZoteroDebug
Expand Down
3 changes: 1 addition & 2 deletions chrome.manifest
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
content zoteroscholarcitations chrome/content/

locale zoteroscholarcitations en-US chrome/locale/en-US/
locale zoteroscholarcitations ru-RU chrome/locale/ru-RU/
locale zoteroscholarcitations it-IT chrome/locale/it-IT/
locale zoteroscholarcitations zh-CN chrome/locale/zh-CN/

overlay chrome://zotero/content/zoteroPane.xul chrome://zoteroscholarcitations/content/overlay.xul
9 changes: 9 additions & 0 deletions chrome/content/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,12 @@ function checkScholarUrl() {
}
}
}

function saveUA() {
var boxText = document.getElementById("pref-zscc-user-agent").value;
if (boxText.length == 0) {
Zotero.Prefs.set("extensions.zscc.userAgent", "");
} else {
Zotero.Prefs.set("extensions.zscc.userAgent", boxText);
}
}
16 changes: 13 additions & 3 deletions chrome/content/options.xul
Original file line number Diff line number Diff line change
@@ -1,27 +1,37 @@
<?xml version="1.0"?>

<!DOCTYPE prefwindow SYSTEM "chrome://zoteroscholarcitations/locale/options.dtd">

<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<?xml-stylesheet href="chrome://zotero-platform/content/preferences.css"?>
<?xml-stylesheet href="chrome://zotero-platform-version/content/style.css"?>

<!DOCTYPE window SYSTEM "chrome://zoteroscholarcitations/locale/options.dtd">

<prefwindow id="zscc-perf" title="&zscc-preferences;"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">

<prefpane label="&zscc-prefpane;" id="zscc-perfpane">
<preferences>
<preference id="pref-zscc-scholar-url" name="extensions.zscc.scholarUrl" type="string"/>
<preference id="pref-zscc-user-agent" name="extensions.zscc.userAgent" type="string"/>
</preferences>

<groupbox>
<separator class="thin"/>
<label id="pref-zscc-scholar-url-label" value="&scholar-url-label;"/>
<label value="&scholar-url-label;"/>
<description>&scholar-url-desc;</description>
<textbox id="pref-zscc-scholar-url" preference="pref-zscc-scholar-url"/>
<button id="pref-zscc-url-verify" label="&scholar-url-verify;" oncommand="checkScholarUrl();"/>
<separator class="thin"/>
</groupbox>

<groupbox>
<separator class="thin"/>
<label value="&user-agent-label;"/>
<description>&user-agent-desc;</description>
<textbox id="pref-zscc-user-agent" preference="pref-zscc-user-agent"/>
<button id="pref-zscc-user-agnet-save" label="&user-agent-save;" oncommand="saveUserAgent();"/>
<separator class="thin"/>
</groupbox>

</prefpane>
<script src="options.js"/>
Expand Down
8 changes: 6 additions & 2 deletions chrome/content/zsc.js
Original file line number Diff line number Diff line change
Expand Up @@ -408,8 +408,12 @@ 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;
userUA = getPref("userAgent");
if (userUA != null && userUA.length > 0) {
return userUA
} else{
return defaultUA;
}
};

if (typeof window !== "undefined") {
Expand Down
11 changes: 8 additions & 3 deletions chrome/locale/en-US/options.dtd
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
<!ENTITY zscc-preferences "ZSCC Preferences">
<!ENTITY zscc-prefpane "ZSCC Preferences">
<!ENTITY scholar-url-label "Scholar Mirror Site (BETA)">
<!ENTITY zscc-prefpane "ZSCC Preferences Panel">

<!ENTITY scholar-url-label "Google Scholar Mirror Site (BETA)">
<!ENTITY scholar-url-desc "The format should start with 'https://' and end with '/', e.g. https://scholar.google.com/. Leave this blank will use the official site.">
<!ENTITY scholar-url-verify "Verify URL">
<!ENTITY scholar-url-verify "Verify URL and save">

<!ENTITY user-agent-label "User Agent">
<!ENTITY user-agent-desc "Set up a user agent for the built-in browser to reduce the chances of encountering reCAPTCHA. If you don't know what it is, leave it blank.">
<!ENTITY user-agent-save "Save UA">
2 changes: 1 addition & 1 deletion chrome/locale/en-US/overlay.dtd
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!ENTITY zotero.scholarcitations.update.label "Update citation(s)">
<!ENTITY zotero.scholarcitations.updateCol.label "Update citations">
<!ENTITY zotero.scholarcitations.updateCol.label "Update citations for collection">
<!ENTITY zotero.scholarcitations.updateAll.label "Update all citations">
<!ENTITY zotero.scholarcitations.options.label "ZSCC Preferences...">
3 changes: 0 additions & 3 deletions chrome/locale/it-IT/overlay.dtd

This file was deleted.

2 changes: 0 additions & 2 deletions chrome/locale/it-IT/zsc.properties

This file was deleted.

3 changes: 0 additions & 3 deletions chrome/locale/ru-RU/overlay.dtd

This file was deleted.

2 changes: 0 additions & 2 deletions chrome/locale/ru-RU/zsc.properties

This file was deleted.

10 changes: 10 additions & 0 deletions chrome/locale/zh-CN/options.dtd
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<!ENTITY zscc-preferences "ZSCC设置">
<!ENTITY zscc-prefpane "ZSCC设置面板">

<!ENTITY scholar-url-label "谷歌学术镜像(BETA)">
<!ENTITY scholar-url-desc "URL的格式应该以'https://'开头并且以'/'结尾, 例如:“https://scholar.google.com/”. 此处留空则默认使用官方网站.">
<!ENTITY scholar-url-verify "验证URL并保存">

<!ENTITY user-agent-label "设置浏览器UA">
<!ENTITY user-agent-desc "设置内置浏览器的User Agent, 某些情况可以降低遇见reCAPTCHA的概率. 如果你不知道这是什么请留空.">
<!ENTITY user-agent-save "保存UA">
4 changes: 4 additions & 0 deletions chrome/locale/zh-CN/overlay.dtd
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<!ENTITY zotero.scholarcitations.update.label "更新引用统计">
<!ENTITY zotero.scholarcitations.updateCol.label "为该集合更新引用统计">
<!ENTITY zotero.scholarcitations.updateAll.label "更新所有引用统计">
<!ENTITY zotero.scholarcitations.options.label "ZSCC偏好设置...">
2 changes: 2 additions & 0 deletions chrome/locale/zh-CN/zsc.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
captchaString=Please enter the Captcha on the page that will now open and then re-try updating the citations, or wait a while to get unblocked by Google if the Captcha is not present.
citedPrefixString=Cited by
16 changes: 1 addition & 15 deletions 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>zoteroscholarcitations@nico.info</em:id>
<em:name>Zotero Scholar Citations</em:name>
<em:version>2.1.2</em:version>
<em:version>2.1.3</em:version>
<em:type>2</em:type>
<em:multiprocessCompatible>true</em:multiprocessCompatible>
<em:creator>Nico</em:creator>
Expand Down Expand Up @@ -36,19 +36,5 @@
<em:description>The add-on automatically fetches the number of citations of your Zotero items from Google Scholar.</em:description>
</Description>
</em:localized>
<em:localized>
<Description>
<em:locale>ru-RU</em:locale>
<em:name>Zotero Scholar Citations</em:name>
<em:description>Плагин для Zotero для автоматической выборки числа цитирований из Google Scholar.</em:description>
</Description>
</em:localized>
<em:localized>
<Description>
<em:locale>it-IT</em:locale>
<em:name>Zotero Scholar Citations</em:name>
<em:description>Plugin di Zotero per il recupero automatico del numero di citazioni in Google Scholar.</em:description>
</Description>
</em:localized>
</Description>
</RDF>
Loading

0 comments on commit d474ae6

Please sign in to comment.