No browser chosen, no "Open on" button
CI / Typecheck, test, build (pull_request) Successful in 26s

The plain address is the one thing that button must not offer -- followed
in the browser the rewrite rules are installed in, it comes straight back
here -- so there is nothing to show until there is a browser to hand it to.
The copy button and the selectable URL were always the part carrying the
weight; the open link now ships hidden and the script reveals it along with
the scheme.

That also settles what the button should say. It went back to "Open on
<platform>": the browser's name was there to explain a tap that went
nowhere, and a button that is not shown until it works needs no such
explanation.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01KF5YF3iZVKbezwALap8LYd
This commit is contained in:
2026-08-29 19:40:39 -03:00
co-authored by Claude Opus 5
parent abf8ec317c
commit 899b6e38d8
6 changed files with 28 additions and 21 deletions
+8 -11
View File
@@ -1,7 +1,7 @@
// Progressive enhancement only. Without this file the page still shows the
// media in a swipeable rail and the original URL as selectable text.
import { browserById, browsersFor, detectOs, openUrlFor } from './browsers.js';
import { browsersFor, detectOs, openUrlFor } from './browsers.js';
const VIEW_KEY = 'antisocial:view';
const BROWSER_KEY = 'antisocial:browser';
@@ -48,24 +48,21 @@ function storedBrowser() {
}
}
// The markup carries the plain address, so the link still goes somewhere
// with this file missing. Only once a browser has been chosen is the href
// swapped for that browser's scheme -- and the name goes onto the button,
// because a scheme for a browser that is not installed opens nothing and
// the tap would otherwise be a silent no-op.
// The markup carries the plain address, which is the one thing the button
// must not offer: followed in the browser the rewrite rules are installed
// in, it redirects straight back to this page. So the link ships hidden and
// is only revealed once a browser has been picked to hand it to. With no
// choice made -- or none this system has a scheme for -- the copy button
// and the URL below it are the whole of it.
function applyBrowser(id) {
const os = detectOs();
const label = browserById(id)?.label;
for (const link of document.querySelectorAll('.original__open')) {
link.dataset.original ??= link.getAttribute('href');
link.dataset.label ??= link.textContent.trim();
const href = openUrlFor(link.dataset.original, id, os);
link.href = href;
link.textContent = href === link.dataset.original
? link.dataset.label
: `${link.dataset.label} in ${label}`;
link.hidden = href === link.dataset.original;
}
}