Feature request: More options for the javascript runner
The ability to run arbitrary javascript code via the new javascript runner is extremely helpful, especially for things that don't really warrant for a plugin. Would it be possible to add a few more features to the runner that would make it even more useful:
For example:
1. A way to save and load scripts: I guess a common scenario involves having some scripts that are used on a regular basis, like for data transformation, merging, and similar things. It would be great if theses scripts could be saved directly in Zotero.
If 1. is possible:
2. A way to upon a script in an external editor.
3. Associate execution mode with a given file (run as async function)
For example:
1. A way to save and load scripts: I guess a common scenario involves having some scripts that are used on a regular basis, like for data transformation, merging, and similar things. It would be great if theses scripts could be saved directly in Zotero.
If 1. is possible:
2. A way to upon a script in an external editor.
3. Associate execution mode with a given file (run as async function)
The latter is what you see in Firefox's Scratchpad, but that seems fairly pointless to me when you can just copy and paste.
The ability to store scripts in Zotero is interesting, though. One model here would be the old keyconfig extension for Firefox/Thunderbird, which let you assign custom code snippets to keyboard shortcuts. (I actually use that in Thunderbird many times a day to open the URLs for Zotero Forums posts, and it's incredibly useful.) The main downside would be the proliferation of code snippets that would likely eventually become obsolete and either break (at best) or cause damage (at worst, though unlikely), whereas extension code generally has a maintainer. But that might be a reasonable trade-off for most of the people who would actually take advantage of this sort of thing.
var foo = 1; foo;
shows===>6<=== (number)
. In async mode, it's the resolved value of the promise, so you have to usevar foo = 6; return foo;
, which is a bit different from what you might expect from a REPL, Scratchpad, etc. On the other hand, almost all Zotero code where you would actually want to see a return value — as opposed to just triggering some action — probably does need to be async, so maintaining the standard behavior may not be worth it.(@dstillman : Sorry for the late reply; I have gotten a email notification for emilianos first comment, but not for your comments. Is that how it should be or are there problems with the notification system?)
Separately, a tutorial would be great too, especially on how not to mess things up.
Thanks for considering.
I tried to install keyconfig in Zotero 5.0.69 using the link on the keyboard shortcuts documentation page. https://www.zotero.org/support/kb/keyboard_shortcut
It didn't work. Is there a way to install keyconfig on an updated Zotero?
I think it was possible to run some version of keyconfig in Zotero at one point, but that may have been only in Zotero for Firefox, or a much older version of Zotero Standalone and/or keyconfig.
For now, if you use the Run JS window often, I'd just recommend keeping a collection of snippets in a text file.
(As for keyconfig-like functionality, I don't know when we'd get to it ourselves, but if someone is interested in working on it, we can certainly discuss.)
I wish I could program a plug-in for this. Since I can't, let me know if there is any way I could help someone's efforts to create this in any way.
Zutilo includes an adapted version of the Keyconfig extension for setting up its keyboard shortcuts, see here. With Zutilo, it should then be possible to assign keyboard shortcuts for executing scripts.
I opened an issue on Zutilo's GitHub site for related discussions:
https://github.com/wshanks/Zutilo/issues/171
We'll look into implementing this soon.
I see two use case here: (1) Someone is starting with a new Zotero script and wants to save it (locally) at some point in order to continue later or to execute it from time to time. (2) Someone has shared a Zotero script which another one wants to open and use as well, e.g. I have some Zotero scripts shared online e.g. for a Wikidata lookup.
In the second case one could save this script in a special folder within Zotero data directory and then restart Zotero. This would require that all scripts in this special folder are afterwards available within Zotero's Run JS functionality. Would this work? I am not sure if you @dstillman were refering to something else with "external files" in the other thread.
https://github.com/windingwind/zotero-actions-tags