From 9e13694b2150bad352a151a0e3fae8eada7516bf Mon Sep 17 00:00:00 2001 From: Pavel Djundik Date: Fri, 21 Aug 2020 10:16:54 +0300 Subject: [PATCH] Skip video/audio embeds if og:type exists but does not specify it --- src/plugins/irc-events/link.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/plugins/irc-events/link.js b/src/plugins/irc-events/link.js index 841f0500..4f5772e7 100644 --- a/src/plugins/irc-events/link.js +++ b/src/plugins/irc-events/link.js @@ -134,6 +134,19 @@ function parseHtmlMedia($, preview, client) { } let foundMedia = false; + const openGraphType = $('meta[property="og:type"]').attr("content"); + + // Certain news websites may include video and audio tags, + // despite actually being an article (as indicated by og:type). + // If there is og:type tag, we will only select video or audio if it matches + if ( + openGraphType && + !openGraphType.startsWith("video") && + !openGraphType.startsWith("music") + ) { + reject(); + return; + } ["video", "audio"].forEach((type) => { if (foundMedia) {