Remove YouTube embedding in the chat (#1080)

* Remove YouTube embedding in the chat

* Remove youtube-lite dependency

* Implelment Feedback
This commit is contained in:
Pankaj Patil
2021-06-07 23:27:13 +05:30
committed by GitHub
parent 5e198bcec6
commit 4bee6408b4
6 changed files with 2 additions and 336 deletions

View File

@@ -122,10 +122,7 @@ function getMessageWithEmbeds(message) {
var anchors = container.getElementsByTagName('a');
for (var i = 0; i < anchors.length; i++) {
const url = anchors[i].href;
if (getYoutubeIdFromURL(url)) {
const youtubeID = getYoutubeIdFromURL(url);
embedText += getYoutubeEmbedFromID(youtubeID);
} else if (url.indexOf('instagram.com/p/') > -1) {
if (url.indexOf('instagram.com/p/') > -1) {
embedText += getInstagramEmbedFromURL(url);
}
}
@@ -142,26 +139,6 @@ function getMessageWithEmbeds(message) {
return message + embedText;
}
function getYoutubeIdFromURL(url) {
try {
var regExp = /^.*(youtu.be\/|v\/|u\/\w\/|embed\/|watch\?v=|\&v=)([^#\&\?]*).*/;
var match = url.match(regExp);
if (match && match[2].length == 11) {
return match[2];
} else {
return null;
}
} catch (e) {
console.log(e);
return null;
}
}
function getYoutubeEmbedFromID(id) {
return `<div class="chat-embed youtube-embed"><lite-youtube videoid="${id}" /></div>`;
}
function getInstagramEmbedFromURL(url) {
const urlObject = new URL(url.replace(/\/$/, ''));
urlObject.pathname += '/embed';