Skip to content

期望实现一个新动作:添加新条目时,若检测到条目重复,则为新条目添加一个重复标签; #310

Closed Answered by LumaFilter
LumaFilter asked this question in Q&A
Discussion options

You must be logged in to vote

参考下面这个链接,代码几乎照抄的,所以注释什么的也没改:
大佬的代码

实现如下:
事件:新建条目
操作: 自定义脚本
Data:

// Automatically detect duplicated items and add tags.
// @author northword
// @link https://github.com/windingwind/zotero-actions-tags/discussions/133
// @see https://github.com/northword/zotero-format-metadata/blob/main/src/modules/rules/item-no-duplicate.ts

const TAG_NAME = "REPLACE WITH YOUR TAG"

if (!item) {
	return;
}

const itemID = item.id;
const duplicates = new Zotero.Duplicates("1");
const search = (await duplicates.getSearchObject());
const searchResult = await search.search();
if (searchResult.includes(itemID)) {
	item.addTag(TAG_NAME, 1);
	return;
} else {
	return;
}

Replies: 3 comments 3 replies

Comment options

You must be logged in to vote
1 reply
@LumaFilter
Comment options

Comment options

You must be logged in to vote
1 reply
@okerivy
Comment options

Answer selected by LumaFilter
Comment options

You must be logged in to vote
1 reply
@LumaFilter
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants