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:
+8
-11
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -47,7 +47,7 @@ export function browsersFor(os) {
|
||||
return BROWSERS.filter((browser) => browser.id === 'default' || browser[os]);
|
||||
}
|
||||
|
||||
export function browserById(id) {
|
||||
function browserById(id) {
|
||||
return BROWSERS.find((browser) => browser.id === id);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user