Merge pull request #1140 from AStove/ImproveEmbed
Improve Tik Tok Embed
This commit is contained in:
commit
b943455d99
@ -558,8 +558,8 @@ plugins.factory('userPlugins', function() {
|
|||||||
* Very similar to twitter
|
* Very similar to twitter
|
||||||
*/
|
*/
|
||||||
var tikTokPlugin = new UrlPlugin('TikTok', function(url) {
|
var tikTokPlugin = new UrlPlugin('TikTok', function(url) {
|
||||||
var regex = /^https?:\/\/(www\.)?tiktok\.com\/@(.+)\/video\/(.+)/i,
|
var regex = /^https?:\/\/(?:www\.)?tiktok\.com\/@(?:.+)\/video\/(?:.+)\/?$|^https?:\/\/vm\.tiktok\.com\/[a-zA-Z1-9]{7}\/?$/i;
|
||||||
match = url.match(regex);
|
var match = url.match(regex);
|
||||||
|
|
||||||
if (match) {
|
if (match) {
|
||||||
|
|
||||||
@ -571,12 +571,12 @@ plugins.factory('userPlugins', function() {
|
|||||||
return response.json();
|
return response.json();
|
||||||
})
|
})
|
||||||
.then(function(data) {
|
.then(function(data) {
|
||||||
// separate the HTML into content and script tag
|
// Separate the HTML into content and script tag
|
||||||
var scriptIndex = data.html.indexOf("<script ");
|
var scriptIndex = data.html.indexOf("<script ");
|
||||||
var content = data.html.substr(0, scriptIndex);
|
var content = data.html.substr(0, scriptIndex);
|
||||||
|
|
||||||
element.innerHTML = content;
|
element.innerHTML = content;
|
||||||
|
// Change the width so we get the deskop version of the embed
|
||||||
|
element.children[0].style.maxWidth = "650px";
|
||||||
// The script tag needs to be generated manually or the browser won't load it
|
// The script tag needs to be generated manually or the browser won't load it
|
||||||
var scriptElem = document.createElement('script');
|
var scriptElem = document.createElement('script');
|
||||||
// Hardcoding the URL here, I don't suppose it's going to change anytime soon
|
// Hardcoding the URL here, I don't suppose it's going to change anytime soon
|
||||||
|
Loading…
Reference in New Issue
Block a user