From c8c95a3cf06c1ddaaf71e77c32e1e37bc4ef2c22 Mon Sep 17 00:00:00 2001 From: WastedMeerkat Date: Tue, 19 Oct 2021 04:54:20 -0500 Subject: [PATCH] Fixed Twitch.tv embeds VOD embeds were broken due to a new URL scheme (legacy support maintained) Clip embed support has been added --- src/Linkification/Embedding.coffee | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/Linkification/Embedding.coffee b/src/Linkification/Embedding.coffee index 912cc13d3..3dbd1ba1c 100644 --- a/src/Linkification/Embedding.coffee +++ b/src/Linkification/Embedding.coffee @@ -422,12 +422,15 @@ Embedding = text: (_) -> _.title , key: 'TwitchTV' - regExp: /^\w+:\/\/(?:www\.|secure\.)?twitch\.tv\/(\w[^#\&\?]*)/ + regExp: /^\w+:\/\/(?:www\.|secure\.|clips\.)?twitch\.tv\/(\w[^#\&\?]*)/ el: (a) -> - m = a.dataset.uid.match /(\w+)(?:\/v\/(\d+))?/ - url = "//player.twitch.tv/?#{if m[2] then "video=v#{m[2]}" else "channel=#{m[1]}"}&autoplay=false&parent=#{location.hostname}" - if (time = a.dataset.href.match /\bt=(\w+)/) - url += "&time=#{time[1]}" + if a.dataset.href.match(/^\w+:\/\/(www\.|secure\.|clips\.)?twitch\.tv/)[1] is 'clips.' + url = "//clips.twitch.tv/embed?clip=#{a.dataset.uid}&parent=#{location.hostname}" + else + m = a.dataset.uid.match /(\w+)(?:\/(?:v\/)?(\d+))?/ + url = "//player.twitch.tv/?#{if m[2] then "video=v#{m[2]}" else "channel=#{m[1]}"}&autoplay=false&parent=#{location.hostname}" + if (time = a.dataset.href.match /\bt=(\w+)/) + url += "&time=#{time[1]}" el = $.el 'iframe', src: url el.setAttribute "allowfullscreen", "true"