Skip to content

Commit

Permalink
修复误删style样式,增加翻译主句对照[实验]
Browse files Browse the repository at this point in the history
  • Loading branch information
MuiseDestiny committed Feb 20, 2023
1 parent c3530b4 commit d4fafae
Show file tree
Hide file tree
Showing 6 changed files with 305 additions and 197 deletions.
15 changes: 0 additions & 15 deletions addon/chrome/content/style.css
Original file line number Diff line number Diff line change
@@ -1,15 +0,0 @@
.tag-box .tag-swatch {
position: absolute;
display: inline-block;
height: .9em;
width: .9em;
border-radius: 100%;
font-size: 1em;
}

.tag-box {
display: inline-block;
position: relative;
height: 1em;
line-height: 1em;
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "zotero-style",
"version": "2.2.0",
"version": "2.2.1",
"description": "让你的Zotero看起来更有趣",
"config": {
"addonName": "Zotero Style",
Expand Down
22 changes: 12 additions & 10 deletions src/modules/item.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const log = console.log
export default class AddonItem {
public item!: _ZoteroItem;
public title = "Addon Item"
public prefKey = "Zotero.AddonItem.key";
public cache: {[key: string]: any} = {};
constructor() {
Expand All @@ -26,7 +27,7 @@ export default class AddonItem {
}
}
let s = new Zotero.Search();
s.addCondition("title", "contains", "Addon Item");
s.addCondition("title", "contains", this.title);
var ids = await s.search();
let items = await Zotero.Items.getAsync(ids);
console.log(items)
Expand All @@ -37,7 +38,7 @@ export default class AddonItem {
} else {
// @ts-ignore
item = new Zotero.Item('computerProgram');
item.setField('title', 'Addon Item');
item.setField('title', this.title);
await item.saveTx()
log("From new")
}
Expand Down Expand Up @@ -128,20 +129,21 @@ export default class AddonItem {
public hiddenNotes() {
const excludeKey = this.item.key
const search = Zotero.Search.prototype.search;
const itemTitle = this.title
Zotero.Search.prototype.search = async function () {
let ids = await search.apply(this, arguments);
// log("hook ids", ids)
// return ids.filter((id: number) => {
// return Zotero.Items.get(id).parentKey != excludeKey
// })
// 只有在搜索结果是笔记时才过滤
if (
Zotero.Items.get(ids[0]).itemTypeID == 26
&& Zotero.Items.get(ids.slice(-1)[0]).itemTypeID == 26
Zotero.Items.get(ids[0]).itemTypeID == 26 &&
Zotero.Items.get(ids.slice(-1)[0]).itemTypeID == 26
) {
log("hook ids", ids)
log("hook ids", ids.length)
return ids.filter((id: number) => {
return Zotero.Items.get(id).parentKey != excludeKey
const parentID = Zotero.Items.get(id).parentID
if (!parentID) { return true }
const parentItem = Zotero.Items.get(parentID)
if (!parentItem) { return true }
return parentItem.key != excludeKey && parentItem.getField("title") != itemTitle
})
} else {
return ids
Expand Down
Loading

0 comments on commit d4fafae

Please sign in to comment.