Action it, tag it, sorted.
![image](https://private-user-images.githubusercontent.com/33902321/267937377-05aa4dc2-4782-4ddf-84ea-949de96820a7.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjQwNjA1NjEsIm5iZiI6MTcyNDA2MDI2MSwicGF0aCI6Ii8zMzkwMjMyMS8yNjc5MzczNzctMDVhYTRkYzItNDc4Mi00ZGRmLTg0ZWEtOTQ5ZGU5NjgyMGE3LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA4MTklMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwODE5VDA5Mzc0MVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWYzZWFiN2Q3YmFlZjU0MTQ3ZjkyM2M5MTYzZWIyZDhiMThjMjFhZDM5ZjgxYzYyNmRhZDUxODI2NzcwNzg0ZmQmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.ioGDHdPoNpXIHkSY7gVv5KNgpnEMe0mK68wqXDAPusg)
Actions & Tags (AT), also known as Zotero Tag, is a plugin for Zotero.
AT can help you:
- Automatically tag items with our actions, triggered by Zotero events or user-defined shortcuts
- Automate your workflow with custom scripts!
-
Download the latest release (.xpi file) from:
Note: If you're using Firefox as your browser, right click the xpi and select "Save As.."
-
In Zotero click "Tools" in the top menu bar and then click "Addons"
-
Go to the Extensions page and then click the gear icon in the top right.
-
Select Install Add-on from file.
-
Browse to where you downloaded the .xpi file and select it.
-
Restart Zotero, by clicking "restart now" in the extensions list where the plugin is now listed.
This plugin is designed to be easy to use. Start in 1 minutes!
We have prepared a simple example for you to get started. The example is called unread
, which will tag the item with unread
when you add it to the library (create, import, or from zotero-connector) and remove the tag when you close the item.
Steps:
- Have this plugin installed and download a paper into your Zotero client.
- The newly added item is tagged with
/unread
! - Open the item and read it.
- Close the item and the tag is removed!
Don't know where to find the tag? Check the "Tags" tab in the right panel. See also Zotero Doc:adding tags to items
Now that you have learned how to use the example, you can create your own actions!
Steps to open the list of actions:
- Open the settings (aka. preferences) page of this plugin. See Zotero Doc:preferences for more details.
- Click the "Actions & Tags" tab.
Now you can see a list of actions.
The community contributed some useful actions via custom script
. Take an example of copy item link
, You can use it by:
- Create an action by clicking the "+" button. Set the operation to
customScript
, assignshortcut
andmenu label
.
![image](https://private-user-images.githubusercontent.com/33902321/278569944-9c327c8a-46d0-416c-b21a-95d4d021c9ea.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjQwNjA1NjEsIm5iZiI6MTcyNDA2MDI2MSwicGF0aCI6Ii8zMzkwMjMyMS8yNzg1Njk5NDQtOWMzMjdjOGEtNDZkMC00MTZjLWIyMWEtOTVkNGQwMjFjOWVhLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA4MTklMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwODE5VDA5Mzc0MVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTU3YmQyNGIwMmZiNjVjYmY1YWU0ZGZmMzU4NzM0MjU1NGU3MGE3MWU3NzFkZmY0YzkyYzc0NWRiZjkzM2QzNmYmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.gSba9OnnbRvpfuwo0QJj0EssNeS_PVxURQ5k1kQXx8M)
- Copy the script from community: [Share] Copy item link of the selected item -> data.
![image](https://private-user-images.githubusercontent.com/33902321/278571602-fad3449a-13ac-4b13-bb19-efe537c4579d.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjQwNjA1NjEsIm5iZiI6MTcyNDA2MDI2MSwicGF0aCI6Ii8zMzkwMjMyMS8yNzg1NzE2MDItZmFkMzQ0OWEtMTNhYy00YjEzLWJiMTktZWZlNTM3YzQ1NzlkLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA4MTklMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwODE5VDA5Mzc0MVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWIwZjczY2ZmMmYxYmY4MjFkOTQwYWVmOTAxMzQzMDc0Mzk3YjU0ZThmN2UyOTA0MDc4ZDljZDIwMTQ1ODhhN2EmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.9KeALrWzVhI8TZ9UEnXp8JQ6MWOwYLEdTFcNVBf4ecE)
-
Paste the script to the
data
field of the action. -
Click "Save" to save the action.
Great! Now you can use the action by:
-
Right click the item in the library and select the action in the menu -> trigger action -> Copy item link.
-
Use the shortcut you assigned to the action.
Check your clipboard and you will find the link of the item!
You can find more actions by searching community.
An action has the following settings:
- Event: The event that triggers the action.
Show supported events
Event | Description |
---|---|
createItem |
Triggered when an item is created. |
openFile |
Triggered when an item is opened. |
closeTab |
Triggered when an item is closed. |
createAnnotation |
Triggered when an annotation is created. |
createNote |
Triggered when a note is created. |
appendAnnotation |
Triggered when an annotation is appended to target item. |
appendNote |
Triggered when a note is appended to target item. |
programStartup |
Triggered when the Zotero client (or this plugin) starts. |
mainWindowLoad |
Triggered when the main window is loaded. |
mainWindowUnload |
Triggered when the main window is unloaded (closed). |
- Operation: The operation that the action will perform.
Show supported operations
Operation | Description |
---|---|
addTag |
Add tag(s) to the target item. |
removeTag |
Remove tag(s) from the target item. |
toggleTag |
Add tag(s) to the target item if it doesn't have the tag, otherwise remove it. |
otherAction |
Run other custom actions. |
customScript |
Run a custom script. |
-
Data: The action data.
- For tag operations, it's tags separated by comma
- For custom script, it's the script code.
- For trigger other actions, it's the target actions' names (each in one line).
Click
⤤
in the edit action popup to open editor for multi-line data. -
Shortcut: The shortcut that triggers the action. Leave it empty if you don't want to use a shortcut.
Click shortcut button in the edit action popup to record custom shortcut from keyboard.
-
Menu Label: The label of the menu item to be displayed in the right-click menu in the library / reader popup menu.
Leave empty to hide in the menu. Sort by the menu label alphabetically.
-
Enabled: Whether the action is enabled. Uncheck it to disable the action.
You can colorize your tags by assigning a color to the tag in the tag selector. See Zotero Doc:colored tags for more details.
Use cases:
- Assign a color to the
/unread
tag so that you can easily find the unread items in your library. - Assign colors to the
⭐️
,⭐️⭐️
,⭐️⭐️⭐️
, ... tags so that you can easily sort the items by their importance.
⚠️ Warning: Custom script is a powerful feature. It can do anything that you can do in the Zotero client. Use it with caution!All the scripts shared in the community will be manually reviewed by me to make sure it is not malicious. However, they may still cause data loss if you does not use them properly! Do not run the script that you do not trust!
You can run custom script with the customScript
operation. The script will be executed in the context of the Zotero client.
Share & find custom scripts here: https://github.com/windingwind/zotero-actions-tags/discussions/categories/action-scripts
You can use the following variables in the script:
-
triggerType
: The trigger type. Can bemenu
,shortcut
,createItem
,openFile
,closeTab
,createAnnotation
,createNote
,appendAnnotation
,appendNote
,programStartup
,mainWindowLoad
,mainWindowUnload
. -
item
: The target item. Might benull
if the action is triggered by an event that doesn't have a target item, e.g. shortcut in the Zotero client without selecting an item. (Not available inprogramStartup
,mainWindowLoad
, andmainWindowUnload
event)Examples with `item`
- Get the title of the item:
item.getField('title')
. More details of the available fields can be found in Zotero:item fields - Get the tags of the item:
item.getTags().map(tag => tag.tag)
- Add a tag to the item:
item.addTag('tag')
- Remove a tag from the item:
item.removeTag('tag')
- Get the title of the item:
-
items
: The target items[] array. Only available in menu/shortcut-triggered actions, otherwise it'snull
.When selecting multiple items in the library, the action will be triggered once for all items (
items=[...], item=undefined
) and then one by one for each item (items=[], item=...
). You can use theitems
variable to get the selected items array and avoid duplicate executions.Examples with `items`
if (item) { // Disable the action if it's triggered for a single item to avoid duplicate operations return; } if (items?.length > 0) { // Do something with all selected items }
-
collection
: The target collection object, is only available when triggered by the collection menu. -
require
: Therequire
function to import global variables. Useconst window = require('window')
to import thewindow
variable.Examples with `require`
-
Get selected items:
const selectedItems = require('ZoteroPane').getSelectedItems()
-
Get the item of current tab:
const Zotero = require("Zotero"); const Zotero_Tab = require("Zotero_Tab"); const itemID = Zotero_Tabs._tabs[Zotero_Tabs.selectedIndex].data.itemID; const item = Zotero.Items.get(itemID);
-
-
window
: Only available inmainWindowLoad
andmainWindowUnload
event. In other events, you should userequire('Zotero').getMainWindow()
to import thewindow
variable.
This plugin is built based on the Zotero Plugin Template. See the setup and debug details there.
To startup, run
git clone https://github.com/windingwind/zotero-actions-tags.git
cd zotero-actions-tags
npm install
npm run build
The plugin is built to ./build/*.xpi
.
Use this code under AGPL. No warranties are provided. Keep the laws of your locality in mind!
- Better Notes for Zotero: Everything about note management. All in Zotero.
- Translate for Zotero: Translate PDF, EPub, webpage, metadata, annotations, notes to the target language. Support 20+ translate services.
I'm windingwind, an active Zotero(https://www.zotero.org) plugin developer. Devoting to making reading papers easier.
Sponsor me to buy a cup of coffee. I spend more than 24 hours every week coding, debugging, and replying to issues in my plugin repositories. The plugins are open-source and totally free.
If you sponsor more than $10 a month, you can list your name/logo here and have priority for feature requests/bug fixes!
Thanks peachgirl100, Juan Gimenez, and other anonymous sponsors!
If you want to leave your name here, please email me or leave a message with the donation.