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