[Plugin] Actions & Tags

edited September 14, 2023
Hi everyone!

I've updated the old zotero-tag plugin to the Actions & Tags for Zotero! See https://github.com/windingwind/zotero-actions-tags.

It's compatible with the latest Zotero 7 beta now.

I hope to receive your feedback and would like to welcome you to share your experiences and workflow of using the plugin.

Some highlighted features:

  • Automatically trigger actions to manipulate tags or metadata when { createItem, openFile, closeTab, createAnnotation, createNote, appendAnnotation, appendNote, programStartup, mainWindowLoad, mainWindowUnload }!
  • Automate your workflow with custom scripts to:
    • Replace tag
    • Copy item link
    • Auto-generate note when opening item
    • Auto-translate new items' title/abstract
    • Find out more →
  • Trigger actions from the right-click menu
  • Trigger actions with user-defined shortcuts
Best,
  • @hsiangyu_wong Thanks for the great plugin
    Can we use it to save "Developer..Run Java scripts" :

    For instance, the following Java script

    https://gist.github.com/KalebNyquist/2ca3ac322751578b6d791cd90b4df15b
    was suggested to show collections that an item belongs to, can it be saved as an action to trigger by right click in actions and tags? :
    ```
    // Instructions:
    // (1) Highlight file of interest.
    // (2) Run code in Zotero's JavaScript console (found under Tools > Developer > Run Javascript) in sync mode.

    function collections_output() {
       zp = Zotero.getActiveZoteroPane()
       items = zp.getSelectedItems()
       collection_ids = items[0]["_collections"]
       
       collections_cache = Zotero.Collections._objectCache
       
       return_string = items[0]["_displayTitle"]
       return_string += "\n\nCollections: \n"
       
       for (i = 0; i < collection_ids.length; i++) {
           return_string += "("
           return_string += i+1
           return_string += ") "
           return_string += collections_cache[collection_ids[i]]["name"]
           if (i + 1 != collection_ids.length) {
               return_string += "\n"
           }
       }

       return return_string
    }

    collections_output()
    ```
  • > show collections that an item belongs to

    press `alt/option` and its parent collections will be highlighted. this is a built-in feature
  • edited December 3, 2023
    @hsiangyu_wong
    Thanks for your rapid reply and sorry for not being clear enough. Actions and Tags seems to be very useful especially with enabling many custom scripts to run through it either automatically, via right click or shortcuts. This is already clear with many custom scripts in the plug-in webpage to toggle panes, remove auto tags, add tags from title, among many other functions.
    The script to save and restore reader tabs itself is equivalent of a separate plugin.
    My questions are:

    1-Using actions and tags to save and recall javascript: Is it possible to use action and tags scrips to paste javascripts suggested by others to perform many specific functions in Zotero (via tools>developer>Run Javascript) or does these javascripts need to be amended or modified some how? Some other users have asked to have the ability to save these javascripts instead of needing to re-insert them every time their functions are needed. If this is doable by actions and tags in a simple way, this will be of a great help.

    2- Showing collections of an item as an example:
    As an example, the previous question included as a javascript that produces a listing of collections and subcollection any item resides into. This is sometimes needed as the built in (ctrl/alt/option+ pressing the item) sometimes does not work perfectly (When the item is listed in many collections , and the number of collections is big, pressing ctrl shows only the first collection without being able to scroll down on the left pane to see other collections where the item belongs). (Edit: Sorry, I found out it is possible while pressing ctrl to scroll the left pane to see all collections but only through pressing its scroll bar as mouse scroll does not work in this case)

    So my question is: Is it possible to paste this javascript in actions and tags as a script and recall it by right click or shortcut to show this listing or create an item note showing the collections the item belongs to?

    3- If this is possible, either directly or with some modifications, then would it be possible to build on this javascript or any similar script to take it a step further to:

    A- right click an item and show the collections it resides into:,and then add these collections names as tags for the item.
    b-Can this possibly be applied to more than item at once? [To generate tags for all items existing already within collections in the library]
    c-Can this possibly be automated for any new items to automatically add tags with the name of the collection they are directed to [there is currently a good plugin for this specific purpose but it has some issues and I think it was not updated to Zotero 7 yet]


    Sorry for the lengthy post and sorry again for Zotero Moderators if it is related to a plugin but some of the suggestions are related to Zotero functions as well (being able to save and recall javascripts easily, being able to autotag items with collection names, etc...)

    Thanks again for all your great efforts in developing Zotero and its related plug-ins.

  • @agam2222

    1.
    > Is it possible to use action and tags scrips to paste javascripts suggested by others to perform many specific functions in Zotero (via tools>developer>Run Javascript) or does these javascripts need to be amended or modified some how?

    Generally, they need to be modified before use. for security reasons, by default only the global variable `Zotero` is available in the scope of custom scripts. However, most of these scripts that are shared in the forums (or by someone else) use other variables like `ZoteroPane`, which need to be got by `const ZoteroPane = Zotero.getActiveZoteroPane()`. And, the executing logic is also different, see https://github.com/windingwind/zotero-actions-tags#custom-script

    2.
    > Is it possible...

    Yes. But I doubt `pressing ctrl shows only the first collection without being able to scroll down on the left pane`. It shows all collections and for me, I can scroll up/down in the collection tree.


    3.
    > add these collections names as tags for the item.

    Yes.

    > Can this possibly be applied to more than item at once?

    Yes. That's what A&T is designed for: to run actions on multiple items (from selection)

    > be automated for any new items to automatically add tags

    Yes. That's also what A&T is designed for.

    And, for script requests, please post them to the plugin's GitHub discussions: https://github.com/windingwind/zotero-actions-tags/discussions
  • Hello, I am a beginner at Zotero and just learned about actions and tags plugins. I installed it on a Windows laptop but the user interface is completely different than screenshots on Git Hub. I found four columns representing ID, tags, shortcuts, and actions (a premade list of actions without access to script insertion for custom actions). how can I access the custom scripts, or is there something wrong that I did during installation? thanks in advance.
  • @a_e_helmy98

    You'll need to install the latest beta version (with Zotero 7 beta) that provides these new features.
Sign In or Register to comment.