DiceR

:placard: Summary Randomizer with logic to prevent repetition until exhaustion and include new content while actively maintaining list integrity.
:link: Repository https://github.com/Servbot91/DiceR/tree/main/plugins/DiceR
:information_source: Source URL https://raw.githubusercontent.com/Servbot91/Sakotos-Stash-Repo/main/plugins/manifest.yml
:open_book: Install How to install a plugin?

DiceR

DiceR(oll) is an improvement on the original Stash plugin random button written by MrDocSabio. It features better entity context, localstorage, performance, and better logging. DiceR provides alot of improvements over the original random plugin such as localstoage which will cache your seen items and continue with the DiceR list until exhaustion. It also features checks in case content has been added and will include that content in the shuffle while protecting your already ‘seen’ list. Each entity scenes, images, galleries, tags etc all carry their own DiceR list when rolled.

Features

  1. Random Item Selection:

    • DiceR fetches all IDs of the current entity type via GraphQL query. It’ll then randomly sort and select
    • Entity handling with their own lists
    • DiceR tracks which items have already been shown from the shuffled list thus preventing repeat selections
    • Optimized performance and content handling due to new logic. Shuffling and verifying millions of items takes milliseconds
  2. Better Randomization

    • Shuffles the IDs and selects the next random ID. Supercedes any sort bias when calling randomGlobal()
    • Uses localStorage to store shuffled ID lists and remaining IDs. A major improvement over the original which would inevitably show the same content session to session.
    • Once all items have been shown, the list reshuffles automatically
    • Works globally (all Scenes, performers, etc.)
  3. New Content Handling

    • It compares the freshly fetched list (currentIds) with the stored cache (stored.allIds) using arraysEqual(). If the IDs have changed (i.e., new content has been added or some items removed) the cache will update to include the new items.
  4. Logging

    • You can verify the state of your local cached list via the F12 browser console menu. All functions are fully logged and color coded to assist with debug.

Installation

  1. Settings → Plugins → Available Plugins
  2. Add Source → Name: Sakotos Stash Repo
  3. Source URL: https://raw.githubusercontent.com/Servbot91/Sakotos-Stash-Repo/refs/heads/main/plugins/manifest.yml
  4. Click checkbox, Install
  5. Reload Plugins

Release Notes

  • 3/29/2026 - Version 1.7
  • 3/28/2026 - Version 1.5

Minor Improvement

  • Rolling in a gallery will now roll another gallery rather than diving down to images. Better filter respect has been added but it could still use some more work.
  • 3/28/2026 - Version 1.4:
  • Major performance improvements
    • Improved cache logic and handling of rebuild of remaining items and when dataset changes
    • Random selection: updated selection logic to better handle large collections (in the millions for images or 100k + for scenes)
      • Instead of loading the entire entity it gets a total count, picks a random page, selects random item from that page.
    • Count is now checked every 5 minutes per click.
      • Basically, if you roll and 5 minutes have passed since you last rolled it will update the count to check for diffs in the cache and update accordingly. This happens in miliseconds and is a major improvement over how it originally worked. You will no longer get huge delays when your DB is in the 100k+ scenes or millions for images
    • Corrected memory leaks
    • Logs in console now show how much you’ve seen via count
    • Added more verbose console logging
      Screenshot 2026-03-20 164957
  • Minor Improvements
    • Added safety checks and better error handling
    • Changed array handling to better maintain ‘allIds’ and ‘remaining’ relationship
    • Added Visual responses when clicked. button changes to ‘Rolling’ and yellow when clicked.
  • 2/28/2026 - Version 1.3:

Enhanced cache handling for IDs with incremental updates:

  • Added additional logging to track the removal and adding of ID’s. This allows the user to identify why their list may be updated.
  • When cache is first run, a log will indicate this
  • When the cache list is updated ie: removed or added scene\performer. The cache now correctly handles the count and incrementally updates the list as it should. Meaning, your active cache list will be maintained while updating to include the new\removed ID’s and randomly sort them into the remaining ID’s without a full rebuild.
  • Full rebuild should now only happen upon complete exhaustion or if local storage has been deleted.
  • This update will force a cache rebuild for everyone
    Example of new logging below:
  • 2/17/2026 - Version 1.2:

Added Console logging for debug.

Screenshots

Screenshot 2026-02-12 141956
Screenshot 2026-02-12 141924

Credit

random button written by MrDocSabio.

3 Likes

I am considering adding some kind of visual indicator if the cache list has been modified or rebuilt. Not sure how much demand is there for that feature though. A manual rebuild cache button could be useful however.

I strongly recommend anyone that is using this plugin to update to the latest version. The performance enhancements are noticeable, but more importantly logic is much better than it was before.