From 488544d71f1d1b0348336081babdfd24a9113444 Mon Sep 17 00:00:00 2001 From: Branch Master Prime Date: Sun, 5 Jan 2025 13:55:37 -0500 Subject: [PATCH] Added support for bluesky expandos (#5546) --- chrome/beta/manifest.json | 3 ++- chrome/manifest.json | 3 ++- firefox/beta/manifest.json | 3 ++- firefox/manifest.json | 3 ++- lib/modules/hosts/bluesky.js | 31 +++++++++++++++++++++++++++++++ lib/modules/hosts/index.js | 2 ++ 6 files changed, 41 insertions(+), 4 deletions(-) create mode 100644 lib/modules/hosts/bluesky.js diff --git a/chrome/beta/manifest.json b/chrome/beta/manifest.json index 98401c7570..0bcd4c23ae 100644 --- a/chrome/beta/manifest.json +++ b/chrome/beta/manifest.json @@ -91,7 +91,8 @@ "https://redditenhancementsuite.com/oauth", "https://accounts.google.com/signin/oauth", "https://www.dropbox.com/oauth2/authorize", - "https://login.live.com/oauth20_authorize.srf" + "https://login.live.com/oauth20_authorize.srf", + "https://embed.bsky.app/oembed" ], "web_accessible_resources": [ { diff --git a/chrome/manifest.json b/chrome/manifest.json index eda8586bbe..316432e07d 100644 --- a/chrome/manifest.json +++ b/chrome/manifest.json @@ -91,7 +91,8 @@ "https://redditenhancementsuite.com/oauth", "https://accounts.google.com/signin/oauth", "https://www.dropbox.com/oauth2/authorize", - "https://login.live.com/oauth20_authorize.srf" + "https://login.live.com/oauth20_authorize.srf", + "https://embed.bsky.app/oembed" ], "web_accessible_resources": [ { diff --git a/firefox/beta/manifest.json b/firefox/beta/manifest.json index 3e5b278d00..e240f15ccd 100644 --- a/firefox/beta/manifest.json +++ b/firefox/beta/manifest.json @@ -91,7 +91,8 @@ "https://api.steampowered.com/ISteamRemoteStorage/GetPublishedFileDetails/*", "https://www.googleapis.com/drive/v3/*", "https://*.redd.it/*", - "https://www.flickr.com/services/oembed" + "https://www.flickr.com/services/oembed", + "https://embed.bsky.app/oembed" ], "web_accessible_resources": [ "prompt.html", diff --git a/firefox/manifest.json b/firefox/manifest.json index 3e5b278d00..e240f15ccd 100644 --- a/firefox/manifest.json +++ b/firefox/manifest.json @@ -91,7 +91,8 @@ "https://api.steampowered.com/ISteamRemoteStorage/GetPublishedFileDetails/*", "https://www.googleapis.com/drive/v3/*", "https://*.redd.it/*", - "https://www.flickr.com/services/oembed" + "https://www.flickr.com/services/oembed", + "https://embed.bsky.app/oembed" ], "web_accessible_resources": [ "prompt.html", diff --git a/lib/modules/hosts/bluesky.js b/lib/modules/hosts/bluesky.js new file mode 100644 index 0000000000..f999c4592a --- /dev/null +++ b/lib/modules/hosts/bluesky.js @@ -0,0 +1,31 @@ +/* @flow */ + +import $ from 'jquery'; +import { Host } from '../../core/host'; +import { ajax } from '../../environment'; + +export default new Host('bluesky', { + name: 'bluesky', + logo: 'https://bsky.app/static/favicon.png', + permissions: ['https://embed.bsky.app/oembed'], + domains: ['bsky.app'], + detect: ({ href }) => (/^^https?:\/\/(bsky)\.app\/profile\/[\w.-]+\/post+/i).exec(href), + async handleLink(href) { + const post = await ajax({ + url: 'https://embed.bsky.app/oembed', + query: { url: href }, + type:'json', + }); + + // Script requires element to be attached to document when starting + const $dummy = $('
'); + + return { + type: 'GENERIC_EXPANDO', + muted: true, + expandoClass: 'selftext', + generate: () => $dummy[0], + onAttach: () => { $dummy.html(post.html); }, + }; + }, +}); \ No newline at end of file diff --git a/lib/modules/hosts/index.js b/lib/modules/hosts/index.js index f60496ffbe..05bd56a59b 100644 --- a/lib/modules/hosts/index.js +++ b/lib/modules/hosts/index.js @@ -4,6 +4,7 @@ import adultswim from './adultswim'; import archilogic from './archilogic'; import archiveis from './archiveis'; import bime from './bime'; +import bluesky from './bluesky'; import clyp from './clyp'; import codepen from './codepen'; import coub from './coub'; @@ -91,6 +92,7 @@ export { archilogic, archiveis, bime, + bluesky, clyp, codepen, coub,