Skip to content

Commit

Permalink
支持zotero7。
Browse files Browse the repository at this point in the history
  • Loading branch information
018 committed Dec 27, 2023
1 parent e8366e7 commit bf1247b
Show file tree
Hide file tree
Showing 5 changed files with 133 additions and 82 deletions.
Binary file modified .DS_Store
Binary file not shown.
56 changes: 50 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,57 @@
# uRead
<p align="center">
<img src="https://raw.githubusercontent.com/018/zoturead/main/src/chrome/content/images/zoturead.png">
</p>
<p align="center">
<a href="https://www.zotero.org">
<img src="https://img.shields.io/badge/Zotero-7-red" alt="Zotero-7">
</a>
<a href="https://github.com/018/zoturead/stargazers">
<img src="https://img.shields.io/github/stars/018/zoturead?label=Stars" alt="element-ui">
</a>
<a href="https://github.com/018/zoturead/releases">
<img src="https://img.shields.io/github/downloads/018/zoturead/total?label=Downloads" alt="element-ui">
</a>
</p>

## 介绍

zoturead是Zotero的大杂烩插件。

今日优读,帮助你更快学习。
今日优读:http://uread.today

1、今日优读网站相关:刷新、收录、查看中图分类、学科、作者等信息、添加目录对比等等。
## 快速开始

- 第一步、下载zoturead最新版本:[点击下载](https://github.com/018/zoturead/releases)

- 第二步、Zotero - 工具 - 附加组件 - ⚙️ - Install Add-on From File...,选择插件xpi文件;

- 第三步、在条目右键即可使用。


## 特性

- 今日优读网站相关:刷新、收录、查看中图分类、学科、作者等信息、添加目录对比等等。

- 搜索相关:通过今日优读搜索、Zotero本身搜索、豆瓣、全图书馆参考咨询联盟、京东、当当、百度、谷歌搜索,以及搜索电子书。

- 辅助工具:展开、收起,拉目录、下载试读,更新豆瓣评分或知网引用数,整理,修复中图分类号、修复学科号,根据学科号归档,定位书籍所在分类目录。

- 自动新增可选的学科目录。

- 一键更新Translator。


## 捐赠

<img src="https://raw.githubusercontent.com/018/zotero-excalidraw/main/src/chrome/content/images/wechat-alipay.png" style="zoom:70%;float:left" />

或者

2、搜索相关:通过今日优读搜索、Zotero本身搜索、豆瓣、全图书馆参考咨询联盟、京东、当当、百度、谷歌搜索,以及搜索电子书。
<a href="https://www.buymeacoffee.com/0x18" target="_blank"><img src="https://cdn.buymeacoffee.com/buttons/v2/default-yellow.png" alt="Buy Me A Coffee" style="height: 60px !important;width: 217px !important;" ></a>

3、辅助工具:展开、收起,拉目录、下载试读,更新豆瓣评分或知网引用数,整理,修复中图分类号、修复学科号,根据学科号归档,定位书籍所在分类目录。
## 许可证

4、自动新增可选的学科目录。
[MIT](./LICENSE)

5、一键更新Translator。
Copyright (c) 2020-2023 018
2 changes: 1 addition & 1 deletion make-zips
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ cd src
zip -r ../build/zoturead-3.0.0.xpi *
cd ../build

jq ".addons[\"zoturead@zotero.org\"].updates[0].update_hash = \"sha256:`shasum -a 256 zoturead-3.0.0.xpi | cut -d' ' -f1`\"" ../updates.json.tmpl > updates.json
jq ".addons[\"zoturead@zotero.org\"].updates[0].update_hash = \"sha256:`shasum -a 256 zoturead-3.0.0.xpi | cut -d' ' -f1`\"" ../updates.json.tmpl > ../updates.json
139 changes: 64 additions & 75 deletions src/zoturead.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ Zotero.ZotURead = Object.assign(Zotero.ZotURead, {
parent: zotero_collectionmenu,
});
this.storeAddedElement(menuInitClcCollection);
menuInitCollection.hidden = !['collection'].includes(type);
menuInitClcCollection.hidden = !['collection'].includes(type);

let menuSelectnoncollection = Zotero.ZotURead.Doms.createMainWindowXULElement('menuitem', {
id: `${root}-uread-selectnoncollection`,
Expand All @@ -91,7 +91,7 @@ Zotero.ZotURead = Object.assign(Zotero.ZotURead, {
parent: zotero_collectionmenu,
});
this.storeAddedElement(menuSelectnoncollection);
menuInitCollection.hidden = !['library', 'collection', 'search', 'group'].includes(type);
menuSelectnoncollection.hidden = !['library', 'collection', 'search', 'group'].includes(type);

menuseparator.hidden = menuInitCollection.hidden && menuInitClcCollection.hidden && menuSelectnoncollection.hidden;

Expand All @@ -101,6 +101,7 @@ Zotero.ZotURead = Object.assign(Zotero.ZotURead, {
disabled = true;
menuInitCollection.label = Zotero.ZotURead.L10ns.getString('zoturead-initCollection-label');
menuInitClcCollection.label = Zotero.ZotURead.L10ns.getString('zoturead-initClcCollection-label');
Zotero.ZotURead.Logger.ding();
} else {
let collection = Zotero.getMainWindow().ZoteroPane.getSelectedCollection();
if (collection) {
Expand All @@ -115,6 +116,8 @@ Zotero.ZotURead = Object.assign(Zotero.ZotURead, {
menuInitClcCollection.label = Zotero.ZotURead.L10ns.getString('zoturead-initClcCollection-label');
}
} else {
menuInitCollection.label = Zotero.ZotURead.L10ns.getString('zoturead-initCollection-label');
menuInitClcCollection.label = Zotero.ZotURead.L10ns.getString('zoturead-initClcCollection-label');
disabled = true
}
}
Expand Down Expand Up @@ -190,71 +193,56 @@ Zotero.ZotURead = Object.assign(Zotero.ZotURead, {

if (!Zotero.getMainWindow().document.getElementById('zotero-itemmenu-zoturead')) {
let zotero_itemmenu_uread = Zotero.getMainWindow().MozXULElement.parseXULToFragment(`
<menu id="zotero-itemmenu-zoturead" data-l10n-id="zoturead-label">
<menupopup id="zotero-itemmenu-zoturead-menupopup">
<menuitem
id="zotero-itemmenu-zoturead-embody"
class="single-select-book"
data-l10n-id="zoturead-embody-label"
oncommand="Zotero.ZotURead.uRead.embody()"></menuitem>
<menuitem
id="zotero-itemmenu-zoturead-refresh"
data-l10n-id="zoturead-refresh-label"
oncommand="Zotero.ZotURead.uRead.refresh()"></menuitem>
<menuitem
id="zotero-itemmenu-zoturead-openaschrome"
data-l10n-id="zoturead-openaschrome-label"
oncommand="Zotero.ZotURead.uRead.openaschrome()"></menuitem>
<menuseparator></menuseparator>
<menuitem
id="zotero-itemmenu-zoturead-clcinfo"
class="single-select-book"
data-l10n-id="zoturead-clcinfo-label"
oncommand="Zotero.ZotURead.uRead.clcinfo()"></menuitem>
<menuitem
id="zotero-itemmenu-zoturead-subjectinfo"
class="single-select-book"
data-l10n-id="zoturead-subjectinfo-label"
oncommand="Zotero.ZotURead.uRead.subjectinfo()"></menuitem>
<menuitem
id="zotero-itemmenu-zoturead-publisherinfo"
class="single-select-book"
data-l10n-id="zoturead-publisherinfo-label"
oncommand="Zotero.ZotURead.uRead.publisherinfo()"></menuitem>
<menuseparator></menuseparator>
<menuitem
id="zotero-itemmenu-zoturead-translate"
data-l10n-id="zoturead-translate-label"
oncommand="Zotero.ZotURead.uRead.translate()"></menuitem>
<menuitem
id="zotero-itemmenu-zoturead-restoretranslate"
class="single-select-book"
data-l10n-id="zoturead-restoretranslate-label"
oncommand="Zotero.ZotURead.uRead.restoretranslate()"></menuitem>
<menuseparator></menuseparator>
<menuitem
id="zotero-itemmenu-zoturead-catalogue-compare.add"
data-l10n-id="zoturead-catalogue-compare-add-label"
oncommand="Zotero.ZotURead.uRead.addCatalogueCompare()"></menuitem>
<menuitem
id="zotero-itemmenu-zoturead-catalogue-compare.add"
data-l10n-id="zoturead-catalogue-compare-start-label"
oncommand="Zotero.ZotURead.uRead.startCatalogueCompare()"></menuitem>
<menuseparator></menuseparator>
<menuitem
id="zotero-itemmenu-zoturead-home"
data-l10n-id="zoturead-label"
oncommand="Zotero.ZotURead.uRead.home()"></menuitem>
</menupopup>
</menu>`).getElementById('zotero-itemmenu-zoturead');
<menu id="zotero-itemmenu-zoturead" data-l10n-id="zoturead-label">
<menupopup id="zotero-itemmenu-zoturead-menupopup">
<menuitem id="zotero-itemmenu-zoturead-embody" class="single-select-book" data-l10n-id="zoturead-embody-label"
oncommand="Zotero.ZotURead.uRead.embody()">
</menuitem>
<menuitem id="zotero-itemmenu-zoturead-refresh" data-l10n-id="zoturead-refresh-label"
oncommand="Zotero.ZotURead.uRead.refresh()">
</menuitem>
<menuitem id="zotero-itemmenu-zoturead-openaschrome" data-l10n-id="zoturead-openaschrome-label"
oncommand="Zotero.ZotURead.uRead.openaschrome()">
</menuitem>
<menuseparator></menuseparator>
<menuitem id="zotero-itemmenu-zoturead-clcinfo" class="single-select-book" data-l10n-id="zoturead-clcinfo-label"
oncommand="Zotero.ZotURead.uRead.clcinfo()">
</menuitem>
<menuitem id="zotero-itemmenu-zoturead-subjectinfo" class="single-select-book"
data-l10n-id="zoturead-subjectinfo-label" oncommand="Zotero.ZotURead.uRead.subjectinfo()">
</menuitem>
<menuitem id="zotero-itemmenu-zoturead-publisherinfo" class="single-select-book"
data-l10n-id="zoturead-publisherinfo-label" oncommand="Zotero.ZotURead.uRead.publisherinfo()">
</menuitem>
<menuseparator></menuseparator>
<menuitem id="zotero-itemmenu-zoturead-translate" data-l10n-id="zoturead-translate-label"
oncommand="Zotero.ZotURead.uRead.translate()">
</menuitem>
<menuitem id="zotero-itemmenu-zoturead-restoretranslate" class="single-select-book"
data-l10n-id="zoturead-restoretranslate-label" oncommand="Zotero.ZotURead.uRead.restoretranslate()">
</menuitem>
<menuseparator></menuseparator>
<menuitem id="zotero-itemmenu-zoturead-catalogue-compare.add"
data-l10n-id="zoturead-catalogue-compare-add-label" oncommand="Zotero.ZotURead.uRead.addCatalogueCompare()">
</menuitem>
<menuitem id="zotero-itemmenu-zoturead-catalogue-compare.add"
data-l10n-id="zoturead-catalogue-compare-start-label"
oncommand="Zotero.ZotURead.uRead.startCatalogueCompare()">
</menuitem>
<menuseparator></menuseparator>
<menuitem id="zotero-itemmenu-zoturead-home" data-l10n-id="zoturead-label"
oncommand="Zotero.ZotURead.uRead.home()">
</menuitem>
</menupopup>
</menu>`).getElementById('zotero-itemmenu-zoturead');
zotero_itemmenu.appendChild(zotero_itemmenu_uread);
this.storeAddedElement(zotero_itemmenu_uread);
}
Expand Down Expand Up @@ -441,7 +429,7 @@ Zotero.ZotURead = Object.assign(Zotero.ZotURead, {
tooltiptext="需要安装油猴插件今日优读才能实现点击自动搜索。"
oncommand="Zotero.ZotURead.Searcher.searchEBook('yabook')"></menuitem>
<menuitem
id="zotero-itemmenu-zoturead-pullcatalogue"
id="zotero-itemmenu-zoturead-search-ebook-weread"
data-l10n-id="zoturead-weread-label"
class="single-select-book"
oncommand="Zotero.ZotURead.Tools.weread()"></menuitem>
Expand Down Expand Up @@ -552,13 +540,15 @@ Zotero.ZotURead = Object.assign(Zotero.ZotURead, {
<menuitem
id="zotero-itemmenu-zoturead-fixsubject"
data-l10n-id="zoturead-fixsubject-label"
class="single-select-book"
oncommand="Zotero.ZotURead.Tools.fixsubject()"></menuitem>
<menuseparator></menuseparator>
<menuitem
id="zotero-itemmenu-zoturead-archive"
data-l10n-id="zoturead-archive-label"
class="single-select-book"
oncommand="Zotero.ZotURead.Tools.archive()"></menuitem>
<!--<menuitem
Expand Down Expand Up @@ -640,31 +630,31 @@ Zotero.ZotURead = Object.assign(Zotero.ZotURead, {
for (const element of item.getCreators()) {
author = element.lastName.replace(/\[.*\]/g, '').replace(/\(.*\)/g, '')

var authorSubmenu = Zotero.getMainWindow().document.createElement('menuitem')
var authorSubmenu = Zotero.getMainWindow().document.createXULElement('menuitem')
authorSubmenu.setAttribute('author', author)
authorSubmenu.setAttribute('class', 'dynamic-author')
authorSubmenu.setAttribute('label', `${!Zotero.ZotURead.uRead.checkUrl(url) ? '搜索 ' : '查看 '}${author} 信息`)
authorSubmenu.onclick = function (e) { Zotero.ZotURead.uRead.authorsinfo(e.target.getAttribute('author')) }.bind(this)
Zotero.getMainWindow().document.getElementById('zotero-itemmenu-zoturead-publisherinfo').before(authorSubmenu)

Zotero.getMainWindow().document.querySelectorAll('.series').forEach(function (element) {
let id = element.getAttribute('id')
Zotero.getMainWindow().document.querySelectorAll('.series').forEach(function (ele) {
let id = ele.getAttribute('id')
if (id) {
let searcher = id.replace('zotero-itemmenu-zoturead-search-', '').replace('-series', '')
let authorSubmenu = Zotero.getMainWindow().document.createElement('menuitem')
let authorSubmenu = Zotero.getMainWindow().document.createXULElement('menuitem')
authorSubmenu.setAttribute('author', author)
authorSubmenu.setAttribute('class', 'dynamic-author')
authorSubmenu.setAttribute('label', `搜索 ${author} 书籍`)
authorSubmenu.onclick = function (e) { Zotero.ZotURead.Searcher.searchAuthor(searcher, e.target.getAttribute('author')) }.bind(this)
element.before(authorSubmenu)
ele.before(authorSubmenu)
}
}.bind(this))
}

Zotero.getMainWindow().document.getElementById('zotero-itemmenu-zoturead-openaschrome').hidden = !Zotero.isMac || !Zotero.File.pathToFile('/Applications/Google Chrome.app/Contents/MacOS/Google Chrome').exists()
}

if (onlyRegular && onlySimple) {
if (onlySimple) {
let locationdisabled = items[0].getCollections().length === 0;
Zotero.getMainWindow().document.getElementById('zotero-itemmenu-zoturead-location').disabled = locationdisabled
if (!locationdisabled) {
Expand Down Expand Up @@ -984,7 +974,6 @@ Zotero.ZotURead = Object.assign(Zotero.ZotURead, {
},

refreshStandaloneMenuPopup() {
this.createStandaloneMenu();
},

// #####################
Expand Down
18 changes: 18 additions & 0 deletions updates.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"addons": {
"zoturead@zotero.org": {
"updates": [
{
"version": "3.0.0",
"update_link": "https://github.com/018/zoturead/releases/latest/download/zoturead-3.0.0.xpi",
"update_hash": "sha256:590444e7984804aded81ffd94d5eefcbb2f82b59cd5d18436d4812c1a0a29fd6",
"applications": {
"zotero": {
"strict_min_version": "6.999"
}
}
}
]
}
}
}

0 comments on commit bf1247b

Please sign in to comment.