Hello, I'm also upset about the fact that Zotero still doesn't offer a function of "Recent Read Papers" lol.
In your workflow, you have to manually switch to the Javascript interface and execute the code when you switch from one paper to another. However, Zotero offers a (probably unused) API to define a callback function when a tab is closed. (though it is currently not on the wiki page. I found that through reading the Zotero source code)
let win = Zotero.getMainWindow();
let zts = win.Zotero_Tabs._tabs;
// zts is a list of tab objects with many useful fields including id, title, time of last selected/unselected.
// Usually, zts[0] is the main panel where you select papers, while the others are the papers you have opened.
let old_onClose = zts[1].onClose; // undefined
zts[1].onClose = ()={
alert('this tab is closed');
}
// after you execute, when you close the first tab, the callback runs, and you will see the alert.
So in your case, you can define your second piece of code as a function and register it as the onClose callback of each opened tab. You can even use setInterval to iterate over all opened tabs (with zts) every given time (e.g., 10 seconds), so you only have to execute the code once and don't have to bother with it anymore!
And this can go even further, like writing the closing time into the paper's metadata (it seems #1 mentioned writing to the attachment (pdf) of the paper, but actually there is a (probably) unused access_time field in the metadata), and/or tag them "Recently Read" / add them to a collection named "Recent Read". After that, you can simply visit the "Recently Read" tag/collection and sort the paper by access time, like the way Mendeley does. I plan to work on this if I got time :)
Hello, I'm also upset about the fact that Zotero still doesn't offer a function of "Recent Read Papers" lol.
In your workflow, you have to manually switch to the Javascript interface and execute the code when you switch from one paper to another. However, Zotero offers a (probably unused) API to define a callback function when a tab is closed. (though it is currently not on the wiki page. I found that through reading the Zotero source code)
So in your case, you can define your second piece of code as a function and register it as the
onClose
callback of each opened tab. You can even usesetInterval
to iterate over all opened tabs (withzts
) every given time (e.g., 10 seconds), so you only have to execute the code once and don't have to bother with it anymore!And this can go even further, like writing the closing time into the paper's metadata (it seems #1 mentioned writing to the attachment (pdf) of the paper, but actually there is a (probably) unused
access_time
field in the metadata), and/or tag them "Recently Read" / add them to a collection named "Recent Read". After that, you can simply visit the "Recently Read" tag/collection and sort the paper by access time, like the way Mendeley does. I plan to work on this if I got time :)