1
0
Fork 0
mirror of https://github.com/M66B/FairEmail.git synced 2024-12-23 16:25:30 +00:00

Embed YouTube

This commit is contained in:
M66B 2023-05-10 10:47:38 +02:00
parent d241aa2ded
commit a429d2a64d

View file

@ -1616,6 +1616,26 @@ public class HtmlHelper {
}, document); }, document);
} }
static boolean embedYouTube(Document document) {
// https://developers.google.com/youtube/player_parameters
// Requires: setBlockNetworkLoads and setJavaScriptEnabled
boolean has = false;
for (Element a : document.select("a"))
if (a.attr("href").startsWith("https://www.youtube.com/embed/")) {
String link = a.attr("href");
a.tagName("iframe");
a.attr("id", link.substring(link.lastIndexOf("/") + 1));
a.attr("type", "text/html");
a.attr("src", link);
a.attr("frameborder", "0");
a.removeAttr("href");
if (a.text().equals(link))
a.text("");
has = true;
}
return has;
}
static void guessSchemes(Document document) { static void guessSchemes(Document document) {
for (Element e : document.select("a,img")) for (Element e : document.select("a,img"))
try { try {