Skip to content

Instantly share code, notes, and snippets.

@Tarrgon
Last active March 7, 2026 20:44
Show Gist options
  • Select an option

  • Save Tarrgon/a58375cd3c1f15d8fd4238a2a7df35b5 to your computer and use it in GitHub Desktop.

Select an option

Save Tarrgon/a58375cd3c1f15d8fd4238a2a7df35b5 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name BSky Redirect
// @namespace http://tampermonkey.net/
// @version 2026-03-07
// @description Redirect you to the best version available from bluesky
// @author You
// @match https://cdn.bsky.app/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=bsky.app
// @grant none
// @run-at document-start
// ==/UserScript==
(async function () {
'use strict';
let url = window.location.pathname.split("/")
if (url.length < 6) return
let did = url[4]
let cid = url[5].includes("@") ? url[5].slice(0, url[5].lastIndexOf("@")) : url[5]
if (did && cid) {
console.log(`https://bsky.social/xrpc/com.atproto.sync.getBlob?did=${did}&cid=${cid}`)
window.location.href = `https://bsky.social/xrpc/com.atproto.sync.getBlob?did=${did}&cid=${cid}`
}
})();
@imitationfacade
Copy link

There's an indexing issue in line 20: if the cid string does not contain @, it will truncate the cid. Consider replacing with these two lines:

  const cid_at_idx = url[5].lastIndexOf("@");
  let cid = cid_at_idx === -1 ? url[5] : url[5].slice(0, cid_at_idx);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment