[addon] Undelete

https://raw.githubusercontent.com/ChrisRaven/Pyr-Undelete/main/Undelete.user.js

Another simple addon. This time to add the ability to bring back the unstarred segments. It works for up to 50 removed elements. If you need more, you can change the value of MAX_LENGTH in the code for the appropriate value.

It has its limitations - doesn’t work, if you remove all the segments at once.
It will also add a segment to the queue, if you split any segment (splitting a segment removes the old one, after all).
It has a single list for all the tabs, so if you have more than one instances of Neuroglancer opened, beware of that.

The button to bring back a removed segment is at the top bar near the right side of the screen. The counter next to the “Undelete” label shows, how many segments there are in the queue. When the queue is full, the oldest ones (removed earlier) are removed from the list and you can’t no longer bring them back.

6 Likes

will this work for pyr alone or for BANC as well? And oh this is very nice thanks!

1 Like

This one works just for Pyr, but I’ve just created a version for BANC. I’ll add a similar topic with the link.

3 Likes

:exploding_head: amazing!

2 Likes

niiiiice! thanks.

2 Likes

Crucial feature! Thanks!

3 Likes

Cool!! This is great

3 Likes

Did not see. ABSolutely great like a six pack ! :star_struck: :grin:

1 Like

Just noting a bug: It seems like if you add and remove the same segment multiple times the Undelete function gets stuck in a loop and won’t move back through older segments.

2 Likes

Oh, right. Didn’t think about it. Thanks for reporting!

2 Likes

I was able to reproduce this issue for a moment, but then I’ve cleared the undelete history (in localStorage) and I’m no longer able to reproduce it. @Celia_D Do you have some steps to reproduce is regularly?

Also, try clearing the history in localStorage and see, if the problem persists.

To clear it:

  1. Open the Console (F12) and make sure, you’re on the Console tab.
  2. Paste this code: localStorage.removeItem('delete') and press Enter.
  3. Refresh the page.
    Warning: this will clear you’re undelete history, but that probably won’t be a problem, since it currently doesn’t work anyway.
2 Likes

It seemed to clear up for a moment, but then I went further back in the list and it seems like it’s still stuck. Here’s my link if you want to give it a look - neuroglancer , though maybe it won’t work for you if it’s a local issue

1 Like


Here’s a screenshot of the log if it’s helpful at all

1 Like

Unfortunately, that won’t help me. If you could get me a copy of your localStorage that could potentially help.
To do this, in the console type: localStorage.getItem('deleted') and press Enter.

It will look similar to this:

If you’d just copy and paste here the string, that’s in blue on my screenshot, I’d be very grateful.

1 Like

Screenshot 2025-01-31 at 3.47.19 PM
Screenshot 2025-01-31 at 3.47.29 PM
‘[“648518346438031583”,“76002229642969036”]’

2 Likes

Thank you!

Now I was able to reproduce the issue.
The problem seems to be with the shorter numbers (starting with 7 in this case). If I’m not mistaken, those numbers happen, when Neuroglancer adds a component segment ID, instead of the whole segment ID. Not sure, why it happens, but it happens, none the less.
The issue with the loop happens, because even if a user tries to manually add such shorter number as a segment ID, Neuroglancer will remove such segment automatically. So, when the addon tries to undelete such a segment, Neuroglancer removes it, addons adds it to its list and we’re in a loop.
I’ll fix the issue by checking the length of the number added to the list (hopefully, the future segment IDs won’t change in length, or they won’t be added to the undelete list. But if it was going to happen, I’ll just try to find another fix then).
In the meantime, to escape from the loop, just clear the localStorage. Just a small correction: yesterday I wrote, that the instruction is with delete in it, but it should be deleted (with the “d” at the end). So, the correct one is: localStorage.removeItem('deleted').

1 Like

Great, thanks for looking into this!

2 Likes

Ok, now in v. 1.2 it should be fixed.
Also added a small update: if a user removes the same segment for a few times in a row without undeleting it in the meantime, the segment will be added to the undelete history only once.

3 Likes