-
- {{ i18n.ts.expandTweet }}
+
+ {{ i18n.ts.expandPost }}
+
+
+
+
+ {{ i18n.ts.expandPost }}
@@ -126,10 +146,17 @@ const player = ref({
height: null,
} as SummalyResult['player']);
const playerEnabled = ref(false);
-const tweetId = ref(null);
-const tweetExpanded = ref(props.detail);
+
const embedId = `embed${Math.random().toString().replace(/\D/, '')}`;
-const tweetHeight = ref(150);
+const postExpanded = ref(props.detail);
+const postHeight = ref(150);
+
+const tweetId = ref(null);
+
+const bskyHandleOrDid = ref(null);
+const bskyDid = ref(null);
+const bskyPostRecordKey = ref(null);
+
const unknownUrl = ref(false);
onDeactivated(() => {
@@ -144,6 +171,19 @@ if (requestUrl.hostname === 'twitter.com' || requestUrl.hostname === 'mobile.twi
if (m) tweetId.value = m[1];
}
+if (requestUrl.hostname === 'bsky.app') {
+ const bskyPostPageUrl = requestUrl.pathname.slice(1).split('/');
+
+ if (bskyPostPageUrl[0] === 'profile' && bskyPostPageUrl[1] && bskyPostPageUrl[2] === 'post' && bskyPostPageUrl[3]) {
+ bskyHandleOrDid.value = bskyPostPageUrl[1];
+ bskyPostRecordKey.value = bskyPostPageUrl[3];
+
+ if (postExpanded.value) {
+ openBskyEmbed();
+ }
+ }
+}
+
if (requestUrl.hostname === 'music.youtube.com' && requestUrl.pathname.match('^/(?:watch|channel)')) {
requestUrl.hostname = 'www.youtube.com';
}
@@ -180,13 +220,23 @@ window.fetch(`/url?url=${encodeURIComponent(requestUrl.href)}&lang=${versatileLa
sensitive.value = info.sensitive ?? false;
});
-function adjustTweetHeight(message: MessageEvent) {
- if (message.origin !== 'https://platform.twitter.com') return;
- const embed = message.data?.['twttr.embed'];
- if (embed?.method !== 'twttr.private.resize') return;
- if (embed?.id !== embedId) return;
- const height = embed?.params[0]?.height;
- if (height) tweetHeight.value = height;
+async function openBskyEmbed() {
+ if (bskyHandleOrDid.value == null || bskyPostRecordKey.value == null) return;
+
+ if (bskyDid.value == null) {
+ if (bskyHandleOrDid.value.startsWith('did:')) {
+ bskyDid.value = bskyHandleOrDid.value;
+ } else {
+ // handleで来ている場合はdidに変換
+ const bskyApiRes = await window.fetch(`https://public.api.bsky.app/xrpc/com.atproto.identity.resolveHandle?handle=${bskyHandleOrDid.value}`);
+ if (bskyApiRes.ok) {
+ const bskyApiData = await bskyApiRes.json() as { did: string };
+ bskyDid.value = bskyApiData.did;
+ }
+ }
+ }
+
+ postExpanded.value = true;
}
function openPlayer(): void {
@@ -199,10 +249,25 @@ function openPlayer(): void {
});
}
-window.addEventListener('message', adjustTweetHeight);
+function adjustSocialsEmbedHeight(message: MessageEvent) {
+ if (message.origin === 'https://platform.twitter.com') {
+ const embed = message.data?.['twttr.embed'];
+ if (embed?.method === 'twttr.private.resize' && embed?.id === embedId) {
+ const height = embed?.params[0]?.height;
+ if (height) postHeight.value = height;
+ }
+ } else if (message.origin === 'https://embed.bsky.app') {
+ if (message.data?.id === embedId) {
+ const height = message.data?.height;
+ if (height) postHeight.value = height;
+ }
+ }
+}
+
+window.addEventListener('message', adjustSocialsEmbedHeight);
onUnmounted(() => {
- window.removeEventListener('message', adjustTweetHeight);
+ window.removeEventListener('message', adjustSocialsEmbedHeight);
});
diff --git a/packages/frontend/src/index.html b/packages/frontend/src/index.html
index 08ff0c58dd3a..14dfe62dbafe 100644
--- a/packages/frontend/src/index.html
+++ b/packages/frontend/src/index.html
@@ -22,7 +22,7 @@
style-src 'self' 'unsafe-inline';
img-src 'self' data: blob: www.google.com xn--931a.moe localhost:3000 localhost:5173 127.0.0.1:5173 127.0.0.1:3000;
media-src 'self' localhost:3000 localhost:5173 127.0.0.1:5173 127.0.0.1:3000;
- connect-src 'self' localhost:3000 localhost:5173 127.0.0.1:5173 127.0.0.1:3000 https://newassets.hcaptcha.com;
+ connect-src 'self' localhost:3000 localhost:5173 127.0.0.1:5173 127.0.0.1:3000 https://newassets.hcaptcha.com https://public.api.bsky.app;
frame-src *;"
/>