mirror of
https://github.com/M66B/FairEmail.git
synced 2024-12-23 00:06:27 +00:00
Embed YouTube
This commit is contained in:
parent
d241aa2ded
commit
a429d2a64d
1 changed files with 20 additions and 0 deletions
|
@ -1616,6 +1616,26 @@ public class HtmlHelper {
|
|||
}, 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) {
|
||||
for (Element e : document.select("a,img"))
|
||||
try {
|
||||
|
|
Loading…
Reference in a new issue