Stash-TCode (dtt fork) - Fully refreshed, now with automatic HR edging!

Finally got some free time so I went ahead and did a full revamp of Stash T-Code USB that I was fixing in the previous thread.

Cleaning it up, streamlining and adding features that I really liked from other players (Thank you Yoooi and Zersty your projects are awesome!)

As usual, use at your own risk. :warning: I am a developer and I (mostly) read and test the code but it is vibecoded.

Stash-TCode 1.1: play funscripts from Stash on your OSR/SR6 over USB, a Stash plugin with heart-rate edging

A Stash plugin that drives TCode devices (OSR2, SR6 and similar) straight from Stash’s own player over USB. It plays single and multi-axis funscripts in sync with the video, and with a Bluetooth heart-rate monitor it can edge you automatically.

Features

  • Connect to T-Code device over USB or Bluetooth: connect once, then it reconnects by itself on refresh or replug.
  • Per-axis control: range, invert, home position and a speed limit (%/s), in a settings dialog that looks native to Stash.
  • Linked axes: make an axis follow another, e.g. twist mirroring stroke (0–100% stroke = 0–100% twist), optionally overriding the axis’s own script.
  • Auto motion: a smooth sine wave at your chosen frequency for any axis without a script, so even videos with no funscript get motion.
  • Idle motion: a slow stroke whenever no video is playing, while you browse for the next scene or with the video paused. It gives way the moment a video plays.
  • Heart-rate edging (any standard Bluetooth HR monitor: chest strap or a watch broadcasting HR):
    • Strokes shorten as your heart rate approaches your edge. At the edge the stroker backs off until you recover, then ramps back in.
    • Adaptive decay lowers the edge as edges add up over a long session.
    • Climax markers: tag a Stash scene marker “Climax” and the limiter lets go around that point in the video. Not ready yet? Switch climax markers off and keep edging through them.
    • Safety: if the monitor drops out or you take the strap off, the device stops.
  • Stats overlay on the video: heart rate, edge, edge count and what the limiter is doing. The navbar button shows the device and monitor status and your live heart rate.
  • Settings in your browser or in Stash: optionally save them to Stash so every browser uses them, private windows included.


Navbar

Install

  1. In Stash, go to Settings → Plugins → Available Plugins → Add Source and add https://dtt-git.github.io/stash-tcode/main/index.yml
  2. Tick Stash-TCode, click Install and refresh the page.
  3. Click Connect in the navbar and pick your device.

Updates show up in Stash under Settings → Plugins → Check for updates.

Notes

  • Use Chrome or Edge: Web Serial and Web Bluetooth are Chromium-only.
  • Reaching Stash over plain HTTP by LAN IP or hostname? Add it to chrome://flags/#unsafely-treat-insecure-origin-as-secure (Web Serial/Bluetooth need a secure origin). localhost and HTTPS work as they are.
  • Any address works: reverse proxy, different port, LAN name.
  • Stash Interactive Tools is optional; you only need it for separate per-axis files (.twist.funscript etc.) and for picking between several scripts.
  • Tested on Stash v0.31.

Coming from the Tampermonkey userscript? It’s retired: 0.7.0 is its last version. Let Tampermonkey update it (a pop-up says it’s retired), then install the plugin and refresh. The userscript hands your settings to the plugin and stops running. Refresh once more, then delete the userscript. Don’t run the plugin next to an older userscript, or both will drive the device.

Heart-rate quick start

Device tab → Heart rate monitor → Connect. Then on the Heart Rate tab turn on Enable and set Edge to the heart rate that counts as an edge for you. The defaults (10 BPM approach band, 30% shortest stroke, 8 s rejoin) are a good starting point.

Credits

Based on Stash-TCode by Spunkle, with modifications by Steel. The heart-rate modulation is inspired by EdgeLoop by marshallmims and reimplemented here.

Source, docs and issues: GitHub - dtt-git/stash-tcode: Stash plugin: drive TCode devices (OSR2/SR6) from Stash over USB Web Serial, with heart-rate modulation · GitHub (GPLv3)

6 Likes

Bro, that’s awesome! Keep up the good work!

2 Likes

v1.0.0: Stash-TCode is now a Stash plugin

The Tampermonkey userscript is retired. Stash-TCode now installs straight from Stash’s plugin list, so no extension is needed.

Not sure why the original script wasn’t a plugin already, perhaps the author didn’t know or Tampermonkey was faster.

Install: Settings → Plugins → Available Plugins → Add Source → https://dtt-git.github.io/stash-tcode/main/index.yml, then install Stash-TCode and refresh.

New

  • A real Stash plugin: works on any address you reach Stash at (reverse proxy, other ports, LAN names) with no more “user includes”, and updates through Stash’s own plugin page.
  • Save settings to Stash (Advanced tab, off by default): every browser uses the same settings, including private windows, so closing an incognito tab no longer wipes them. Which device and HR monitor to reconnect to always stays with each browser.
  • Works on phones: the settings dialog is now readable on small screens. Sliders move below their labels instead of squashing them.

Improved

  • Uses Stash’s plugin API instead of polling the page. It picks up page changes as soon as they happen, the navbar button stays put, and it uses Stash’s own player.
  • The connection dot lines up properly in the navbar and the settings.
  • Switching scripts in the Interactive Tools picker reloads them reliably. Per-axis files are hidden from the list.

Coming from the userscript

Tampermonkey updates it to 0.7.0, its last version. It keeps working and tells you it’s retired. Install the plugin and refresh: the userscript copies your settings to the plugin and stops running. Refresh once more, then delete the userscript.

:warning: Don’t install the plugin next to an older userscript (0.6 or earlier), or both will drive the device. Update or delete the userscript first.

1 Like

v1.1.0: Idle motion, a climax switch and smoother edging

New

  • Idle motion (Axes → L0 → Idle motion, off by default): keeps a slow stroke going whenever no video is playing, while you browse for the next scene or with the video paused. Speed is 3–60 strokes a minute and the stroke length is adjustable. It starts 2 s after playback stops and gives way the moment a video plays. It follows your range, invert, speed limit and heart-rate edging like normal playback, so it backs off at an edge too.
  • Climax switch (Climax tab → Enable): turn it off and a scene’s climax markers are ignored, so you keep edging through them. Handy when you want to watch a scene that has a climax you’re not ready for. The overlay shows “Climax off” while a marker is still ahead. Turn it back on when you’re ready.
  • Heart-rate dot in the navbar: with heart-rate modulation on, the navbar button shows a second dot beside the device’s, green while the monitor is sending readings.

Fixed

  • Stutter after an edge: how far each axis may move changed in steps (once per heart-rate reading, and all at once when an edge started or cleared), which a slow auto-motion twist showed as a lurch about once a second. Changes now ease in: up gently, down within about a second, so backing off at the edge stays prompt.
  • Spin on seek: skipping through a video made auto motion (e.g. a slow twist) spin quickly to a new point in its cycle. Auto motion now runs on its own clock that only moves while the video plays, so seeking doesn’t jolt it.
  • Device not moving after opening a scene from Stash Battle: the plugin could latch onto one of Stash Battle’s preview videos instead of the scene’s player, so the script loaded but nothing moved, and the stats overlay showed up on the preview. It now only ever follows Stash’s own player.

Improved

  • Tidier Axes tab: settings that only matter while another one is on (Frequency, Max speed, Home position, the Idle settings, Override script) stay hidden until it is, and sit indented under it.
  • Navbar on phones: the button is sized and spaced like its neighbours.
2 Likes

v1.1.1: Works with Stash on a subpath

Fixed

  • If Stash was being served under a subpath (e.g. /stash/ behind a reverse proxy): settings and climax markers didn’t load, and the default funscript link pointed to the wrong place, because the plugin always went to the root of the domain. It now follows Stash’s subpath like Stash itself does.