From 2ea1de77ab4851f8024c546d9f14bb84d47a1d3e Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Fri, 25 Oct 2024 05:01:33 +0300 Subject: embed: Tiktok videos --- vnext/src/utils/embed.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'vnext/src/utils') diff --git a/vnext/src/utils/embed.js b/vnext/src/utils/embed.js index d020dbc2..6a5c9c95 100644 --- a/vnext/src/utils/embed.js +++ b/vnext/src/utils/embed.js @@ -314,6 +314,24 @@ function getEmbeddableLinkTypes() { return div } }, + { + name: 'Tiktok', + id: 'embed_tiktok', + className: 'tiktok compact', + re: /https?:\/\/www\.?tiktok\.com\/(\S+)/i, + makeNode: function(aNode, reResult, div) { + const tiktok_url = reResult[0] + fetch('https://www.tiktok.com/oembed?url=' + tiktok_url) + .then(response => response.json()) + .then(json => { + div.innerHTML = json.html + let script = document.createElement('script') + script.src = 'https://www.tiktok.com/embed.js' + div.appendChild(script) + }).catch(console.log) + return div + } + }, ] } -- cgit v1.2.3