mirror of
https://github.com/bitsocialnet/5chan.git
synced 2026-08-03 07:41:04 +02:00
fix(react): address Doctor findings (#1143)
Accessibility/semantics pass aligned with React Doctor: role-based spans/divs become real buttons, role=status becomes <output>, modals use native <dialog>, author/peer flags render as <img>, and embed/challenge iframes are sandboxed. Includes review follow-ups: correct button chrome/centering/themed dialog colors and focus rings, the missing aria-label i18n keys (all languages), the Yandex image-search URL, clearer .bso setup steps, a keyboard-accessible image-search dropdown, and removal of the post-edit ('comment edited') display (mod edits unchanged).
This commit is contained in:
@@ -0,0 +1,60 @@
|
||||
export const youtubeHosts = new Set<string>([
|
||||
'youtube.com',
|
||||
'www.youtube.com',
|
||||
'youtu.be',
|
||||
'www.youtu.be',
|
||||
'm.youtube.com',
|
||||
'music.youtube.com',
|
||||
// working Invidious instances - https://docs.invidious.io/instances/ - https://uptime.invidious.io/
|
||||
'yewtu.be',
|
||||
'inv.nadeko.net',
|
||||
'yt.artemislena.eu',
|
||||
'invidious.nerdvpn.de',
|
||||
]);
|
||||
|
||||
export const xHosts = new Set<string>(['twitter.com', 'www.twitter.com', 'x.com', 'www.x.com']);
|
||||
|
||||
export const getXTweetId = (parsedUrl: URL): string | undefined => {
|
||||
const pathParts = parsedUrl.pathname.split('/').filter(Boolean);
|
||||
const statusIndex = pathParts.findIndex((part) => part === 'status' || part === 'statuses');
|
||||
const statusId = statusIndex === -1 ? undefined : pathParts[statusIndex + 1];
|
||||
|
||||
return statusId && /^\d+$/.test(statusId) ? statusId : undefined;
|
||||
};
|
||||
|
||||
export const redditHosts = new Set<string>(['reddit.com', 'www.reddit.com', 'old.reddit.com']);
|
||||
export const twitchHosts = new Set<string>(['twitch.tv', 'www.twitch.tv']);
|
||||
export const tiktokHosts = new Set<string>(['tiktok.com', 'www.tiktok.com']);
|
||||
export const instagramHosts = new Set<string>(['instagram.com', 'www.instagram.com']);
|
||||
export const odyseeHosts = new Set<string>(['odysee.com', 'www.odysee.com']);
|
||||
export const bitchuteHosts = new Set<string>(['bitchute.com', 'www.bitchute.com']);
|
||||
export const streamableHosts = new Set<string>(['streamable.com', 'www.streamable.com']);
|
||||
export const spotifyHosts = new Set<string>(['spotify.com', 'www.spotify.com', 'open.spotify.com']);
|
||||
export const soundcloudHosts = new Set<string>(['soundcloud.com', 'www.soundcloud.com', 'on.soundcloud.com', 'api.soundcloud.com', 'w.soundcloud.com']);
|
||||
|
||||
const canEmbedHosts = new Set<string>([
|
||||
...youtubeHosts,
|
||||
...xHosts,
|
||||
...redditHosts,
|
||||
...twitchHosts,
|
||||
...tiktokHosts,
|
||||
...instagramHosts,
|
||||
...odyseeHosts,
|
||||
...bitchuteHosts,
|
||||
...soundcloudHosts,
|
||||
...streamableHosts,
|
||||
...spotifyHosts,
|
||||
]);
|
||||
|
||||
export const canEmbed = (parsedUrl: URL): boolean => {
|
||||
if (xHosts.has(parsedUrl.host)) {
|
||||
return Boolean(getXTweetId(parsedUrl));
|
||||
}
|
||||
|
||||
if (redditHosts.has(parsedUrl.host)) {
|
||||
// Reddit posts are not embeddable if the URL does not include '/comments/'
|
||||
return parsedUrl.pathname.includes('/comments/');
|
||||
}
|
||||
|
||||
return canEmbedHosts.has(parsedUrl.host) || (parsedUrl.host.startsWith('yt.') && parsedUrl.searchParams.has('v'));
|
||||
};
|
||||
Reference in New Issue
Block a user