diff --git a/js/plugins.js b/js/plugins.js index 2dcabc4..d7e4952 100644 --- a/js/plugins.js +++ b/js/plugins.js @@ -553,8 +553,48 @@ plugins.factory('userPlugins', function() { } }); + /* + * TikTok embedded player + * Very similar to twitter + */ + var tikTokPlugin = new UrlPlugin('TikTok', function(url) { + var regex = /^https?:\/\/(www\.)?tiktok\.com\/(.+)/i, + match = url.match(regex); + + if (match){ + + return function() { + + var element = this.getElement(); + + GetEmbedContent( "https://www.tiktok.com/oembed?url=" + url, element); + + function GetEmbedContent(embedurl, element) + { + fetch(embedurl) + .then(function(response) { + return response.json(); + }) + .then(function(data) { + // separate the HTML into content and script tag + var scriptIndex = data.html.indexOf("