From a8ff945fbc71dc229023aed7405b06c80a64cf77 Mon Sep 17 00:00:00 2001
From: leprechaun
Date: Sat, 31 Jul 2021 10:32:10 -0300
Subject: [PATCH 1/9] * embedded Rumble video support added.
---
src/consts/regexes.const.ts | 3 ++-
src/markdown-2-html.spec.ts | 43 +++++++++++++++++++++++++++++++-----
src/methods/a.method.ts | 30 +++++++++++++++++++------
src/methods/iframe.method.ts | 22 +++++++++++++-----
4 files changed, 79 insertions(+), 19 deletions(-)
diff --git a/src/consts/regexes.const.ts b/src/consts/regexes.const.ts
index 3ab48db..cdad99d 100644
--- a/src/consts/regexes.const.ts
+++ b/src/consts/regexes.const.ts
@@ -19,4 +19,5 @@ export const ODYSEE_REGEX = /^(https?:)?\/\/odysee.com\/\$\/embed\/.*/i
export const ARCH_REGEX = /^(https?:)?\/\/archive.org\/embed\/.*/i
export const SPEAK_REGEX = /(?:https?:\/\/(?:3speak.([a-z]+)\/watch\?v=)|(?:3speak.([a-z]+)\/embed\?v=))([A-Za-z0-9\_\-\.\/]+)(&.*)?/i
export const TWITTER_REGEX = /(?:https?:\/\/(?:(?:twitter\.com\/(.*?)\/status\/(.*))))/gi
-export const SPOTIFY_REGEX = /^https:\/\/open\.spotify\.com\/playlist\/(.*)?$/gi
\ No newline at end of file
+export const SPOTIFY_REGEX = /^https:\/\/open\.spotify\.com\/playlist\/(.*)?$/gi
+export const RUMBLE_REGEX = /^https:\/\/rumble.com\/embed\/(?[a-zA-Z0-9-]+)\/\?pub=4/
\ No newline at end of file
diff --git a/src/markdown-2-html.spec.ts b/src/markdown-2-html.spec.ts
index a48a167..f9ba7ac 100644
--- a/src/markdown-2-html.spec.ts
+++ b/src/markdown-2-html.spec.ts
@@ -677,7 +677,7 @@ describe('Markdown2Html', () => {
const expected = 'for history refer to this fine post /@offgridlife/proofofbrain-golden-rule-do-to-others-what-you-want-them-to-do-to-you and while you are in the community
'
expect(markdown2Html(input)).toBe(expected)
- })
+ })
it('47 - Should handle Bitchute links', () => {
const input = {
@@ -687,9 +687,9 @@ describe('Markdown2Html', () => {
body: 'https://www.bitchute.com/video/DJJvTZQxMaNK/'
}
const expected = '
'
- expect(markdown2Html(input)).toBe(expected);
+ expect(markdown2Html(input)).toBe(expected)
})
-
+
it('49 - Should handle Bitchute iframes', () => {
const input = {
author: 'foo349',
@@ -698,9 +698,10 @@ describe('Markdown2Html', () => {
body: ''
}
const expected = ''
- expect(markdown2Html(input)).toBe(expected);
+ expect(markdown2Html(input)).toBe(expected)
})
-
+
+
})
describe('Sanitization', () => {
@@ -858,4 +859,36 @@ describe('Markdown2Html', () => {
expect(markdown2Html(input, false, true)).toBe(SNAPSHOT_JSON.markdown_2_html_webp_support_should_render_images_in_webp_format)
})
})
+
+ describe("Rumble support", () => {
+
+ it('Rumble iframes', () => {
+ let expected = ''
+ let input = {
+ author: 'foo350x',
+ permlink: 'bar350x',
+ last_update: '2021-05-10T09:15:50',
+ body: ''
+ }
+ expect(markdown2Html(input)).toBe(expected)
+ })
+
+
+ it('Rumble embed URL', () => {
+ const expected = "
"
+ let input = {
+ author: 'foo350y',
+ permlink: 'bar350y',
+ last_update: '2021-05-10T09:16:50',
+ body: 'https://rumble.com/embed/vhwsp4/?pub=4'
+ }
+ expect(markdown2Html(input)).toBe(expected)
+ })
+
+ // The following canot be done: Convert URLs to the video page like this one
+ // (https://rumble.com/vkhkzl-helping-my-girls-to-cool-down-in-the-heat.html)
+ // to its corresponding embedded URL (https://rumble.com/embed/vhveub/?pub=4).
+ // The relationship seems to be governed by a table.
+
+ })
})
diff --git a/src/methods/a.method.ts b/src/methods/a.method.ts
index e291a41..24bb112 100644
--- a/src/methods/a.method.ts
+++ b/src/methods/a.method.ts
@@ -14,6 +14,7 @@ import {
TWITTER_REGEX,
VIMEO_REGEX,
WHITE_LIST,
+ RUMBLE_REGEX,
YOUTUBE_REGEX,
SPOTIFY_REGEX,
DOMParser
@@ -225,6 +226,21 @@ export function a(el: HTMLElement, forApp: boolean, webp: boolean): void {
return
}
+ const RBmatch = href.match(RUMBLE_REGEX)
+ if (RBmatch && el.textContent.trim() === href) {
+ const vid = RBmatch.groups.id
+ const embedSrc = `https://www.rumble.com/embed/${vid}/?pub=4`
+ el.setAttribute('class', 'markdown-video-link')
+ el.removeAttribute('href')
+
+ el.textContent = ''
+ el.setAttribute('data-embed-src', embedSrc)
+ const play = el.ownerDocument.createElement('span')
+ play.setAttribute('class', 'markdown-video-play')
+ el.appendChild(play)
+ return
+ }
+
const BCmatch = href.match(BITCHUTE_REGEX)
if (BCmatch && el.textContent.trim() === href) {
@@ -241,11 +257,11 @@ export function a(el: HTMLElement, forApp: boolean, webp: boolean): void {
const play = el.ownerDocument.createElement('span')
play.setAttribute('class', 'markdown-video-play')
el.appendChild(play)
- return;
+ return
}
-
+
// If a youtube video
let match = href.match(YOUTUBE_REGEX)
if (match && el.textContent.trim() === href) {
@@ -332,7 +348,7 @@ export function a(el: HTMLElement, forApp: boolean, webp: boolean): void {
if (match && el.textContent.trim() === href) {
const e = SPOTIFY_REGEX.exec(href)
if (e[1]) {
-
+
el.setAttribute('class', 'markdown-audio-link markdown-audio-link-spotify')
el.removeAttribute('href')
@@ -347,7 +363,7 @@ export function a(el: HTMLElement, forApp: boolean, webp: boolean): void {
ifr.setAttribute('sandbox', 'allow-scripts allow-same-origin allow-popups')
el.appendChild(ifr)
- return
+ return
}
}
@@ -367,13 +383,13 @@ export function a(el: HTMLElement, forApp: boolean, webp: boolean): void {
const thumbnail = proxifyImageSrc(imgEls[0].getAttribute('src').replace(/\s+/g, ''), 0, 0, webp ? 'webp' : 'match')
const videoHref = `https://emb.d.tube/#!/${e[2]}/${e[3]}`
- // el.setAttribute('data-video-href', videoHref);
+ // el.setAttribute('data-video-href', videoHref)
el.setAttribute('data-embed-src', videoHref)
const thumbImg = el.ownerDocument.createElement('img')
thumbImg.setAttribute('class', 'no-replace video-thumbnail')
thumbImg.setAttribute('itemprop', 'thumbnailUrl')
-
+
thumbImg.setAttribute('src', thumbnail)
const play = el.ownerDocument.createElement('span')
@@ -399,7 +415,7 @@ export function a(el: HTMLElement, forApp: boolean, webp: boolean): void {
const videoHref = `https://emb.d.tube/#!/${e[2]}/${e[3]}`
- // el.setAttribute('data-video-href', videoHref);
+ // el.setAttribute('data-video-href', videoHref)
el.setAttribute('data-embed-src', videoHref)
const play = el.ownerDocument.createElement('span')
play.setAttribute('class', 'markdown-video-play')
diff --git a/src/methods/iframe.method.ts b/src/methods/iframe.method.ts
index 5660bb3..101eabe 100644
--- a/src/methods/iframe.method.ts
+++ b/src/methods/iframe.method.ts
@@ -1,4 +1,4 @@
-import { ARCH_REGEX, DAPPLR_REGEX, LBRY_REGEX, TRUVVL_REGEX, ODYSEE_REGEX, BITCHUTE_REGEX } from '../consts'
+import { ARCH_REGEX, DAPPLR_REGEX, LBRY_REGEX, TRUVVL_REGEX, ODYSEE_REGEX, BITCHUTE_REGEX, RUMBLE_REGEX } from '../consts'
export function iframe(el: HTMLElement): void {
const src = el.getAttribute('src')
@@ -7,6 +7,12 @@ export function iframe(el: HTMLElement): void {
return
}
+ try {
+
+ if (src.match(BITCHUTE_REGEX)) {
+ return
+ }
+
// Youtube
if (src.match(/^(https?:)?\/\/www.youtube.com\/embed\/.*/i)) {
// strip query string (yt: autoplay=1,controls=0,showinfo=0, etc)
@@ -15,10 +21,6 @@ export function iframe(el: HTMLElement): void {
return
}
- if (src.match(BITCHUTE_REGEX)) {
- return
- }
-
// Vimeo
const m = src.match(/https:\/\/player\.vimeo\.com\/video\/([0-9]+)/)
if (m && m.length === 2) {
@@ -86,7 +88,7 @@ export function iframe(el: HTMLElement): void {
el.setAttribute('allowfullscreen', 'true')
return
}
-
+
// Truvvl
if (src.match(TRUVVL_REGEX)) {
el.setAttribute('src', src)
@@ -104,6 +106,11 @@ export function iframe(el: HTMLElement): void {
return
}
+ if (src.match(RUMBLE_REGEX)) {
+ el.setAttribute('frameborder', '0')
+ return
+ }
+
// ODYSEE
if (src.match(ODYSEE_REGEX)) {
el.setAttribute('src', src)
@@ -116,6 +123,9 @@ export function iframe(el: HTMLElement): void {
el.setAttribute('src', src)
return
}
+ } catch (e) {
+ console.log(e)
+ }
const replaceNode = el.ownerDocument.createElement('div')
replaceNode.setAttribute('class', 'unsupported-iframe')
From e7b55b8e6b3f4d607e4597da67e299da969c1bf8 Mon Sep 17 00:00:00 2001
From: leprechaun
Date: Sat, 31 Jul 2021 22:04:20 -0300
Subject: [PATCH 2/9] * support for brighteon videos added
---
src/consts/regexes.const.ts | 3 ++-
src/markdown-2-html.spec.ts | 39 ++++++++++++++++++++++++++++++++++++
src/methods/a.method.ts | 22 ++++++++++++++++++++
src/methods/iframe.method.ts | 7 ++++++-
4 files changed, 69 insertions(+), 2 deletions(-)
diff --git a/src/consts/regexes.const.ts b/src/consts/regexes.const.ts
index cdad99d..18c871a 100644
--- a/src/consts/regexes.const.ts
+++ b/src/consts/regexes.const.ts
@@ -20,4 +20,5 @@ export const ARCH_REGEX = /^(https?:)?\/\/archive.org\/embed\/.*/i
export const SPEAK_REGEX = /(?:https?:\/\/(?:3speak.([a-z]+)\/watch\?v=)|(?:3speak.([a-z]+)\/embed\?v=))([A-Za-z0-9\_\-\.\/]+)(&.*)?/i
export const TWITTER_REGEX = /(?:https?:\/\/(?:(?:twitter\.com\/(.*?)\/status\/(.*))))/gi
export const SPOTIFY_REGEX = /^https:\/\/open\.spotify\.com\/playlist\/(.*)?$/gi
-export const RUMBLE_REGEX = /^https:\/\/rumble.com\/embed\/(?[a-zA-Z0-9-]+)\/\?pub=4/
\ No newline at end of file
+export const RUMBLE_REGEX = /^https:\/\/rumble\.com\/embed\/(?[a-zA-Z0-9-]+)\/\?pub=4/
+export const BRIGHTEON_REGEX = /^https?:\/\/(www\.)?brighteon\.com\/(?:embed\/)?(?[0-9a-f-]+)/i
\ No newline at end of file
diff --git a/src/markdown-2-html.spec.ts b/src/markdown-2-html.spec.ts
index f9ba7ac..e337548 100644
--- a/src/markdown-2-html.spec.ts
+++ b/src/markdown-2-html.spec.ts
@@ -890,5 +890,44 @@ describe('Markdown2Html', () => {
// to its corresponding embedded URL (https://rumble.com/embed/vhveub/?pub=4).
// The relationship seems to be governed by a table.
+ })
+ describe("Brightreon support", () => {
+
+ it('Brightreon iframes', () => {
+ let expected = ''
+ let input = {
+ author: 'foo351x',
+ permlink: 'bar351x',
+ last_update: '2021-05-10T09:15:50',
+ body: ""
+ }
+ expect(markdown2Html(input)).toBe(expected)
+ })
+
+
+ it('Brightreon embed URL', () => {
+ const expected = "
"
+ let input = {
+ author: 'foo351y',
+ permlink: 'bar351y',
+ last_update: '2021-05-10T09:16:50',
+ body: 'https://www.brighteon.com/embed/5821540656001'
+ }
+ expect(markdown2Html(input)).toBe(expected)
+ })
+
+ it('Brightreon page URL', () => {
+ const expected = "
"
+ let input = {
+ author: 'foo351z',
+ permlink: 'bar351z',
+ last_update: '2021-05-10T09:16:50',
+ body: 'https://www.brighteon.com/5821540656001'
+ }
+ expect(markdown2Html(input)).toBe(expected)
+ })
+
+
+
})
})
diff --git a/src/methods/a.method.ts b/src/methods/a.method.ts
index 24bb112..5f5a032 100644
--- a/src/methods/a.method.ts
+++ b/src/methods/a.method.ts
@@ -15,6 +15,7 @@ import {
VIMEO_REGEX,
WHITE_LIST,
RUMBLE_REGEX,
+ BRIGHTEON_REGEX,
YOUTUBE_REGEX,
SPOTIFY_REGEX,
DOMParser
@@ -226,6 +227,27 @@ export function a(el: HTMLElement, forApp: boolean, webp: boolean): void {
return
}
+ const BNmatch = href.match(BRIGHTEON_REGEX)
+ if (BNmatch && el.textContent.trim() === href) {
+ try {
+ const vid = BNmatch.groups.id
+ const embedSrc = `https://www.brighteon.com/embed/${vid}`
+ el.setAttribute('class', 'markdown-video-link')
+ el.removeAttribute('href')
+
+ el.textContent = ''
+ el.setAttribute('data-embed-src', embedSrc)
+ const play = el.ownerDocument.createElement('span')
+ play.setAttribute('class', 'markdown-video-play')
+ el.appendChild(play)
+ return
+ } catch (e) {
+ console.log(e)
+ console.log({BNmatch})
+ }
+ }
+
+
const RBmatch = href.match(RUMBLE_REGEX)
if (RBmatch && el.textContent.trim() === href) {
const vid = RBmatch.groups.id
diff --git a/src/methods/iframe.method.ts b/src/methods/iframe.method.ts
index 101eabe..9397b16 100644
--- a/src/methods/iframe.method.ts
+++ b/src/methods/iframe.method.ts
@@ -1,4 +1,4 @@
-import { ARCH_REGEX, DAPPLR_REGEX, LBRY_REGEX, TRUVVL_REGEX, ODYSEE_REGEX, BITCHUTE_REGEX, RUMBLE_REGEX } from '../consts'
+import { ARCH_REGEX, DAPPLR_REGEX, LBRY_REGEX, TRUVVL_REGEX, ODYSEE_REGEX, BITCHUTE_REGEX, RUMBLE_REGEX, BRIGHTEON_REGEX } from '../consts'
export function iframe(el: HTMLElement): void {
const src = el.getAttribute('src')
@@ -110,6 +110,11 @@ export function iframe(el: HTMLElement): void {
el.setAttribute('frameborder', '0')
return
}
+
+ if (src.match(BRIGHTEON_REGEX)) {
+ el.setAttribute('frameborder', '0')
+ return
+ }
// ODYSEE
if (src.match(ODYSEE_REGEX)) {
From 2bc5cc68da698b6b646879c7dfbd0bc526ca46c0 Mon Sep 17 00:00:00 2001
From: leprechaun
Date: Tue, 3 Aug 2021 16:22:25 -0300
Subject: [PATCH 3/9] * added support for embedding codes from InfoWars
---
src/consts/regexes.const.ts | 2 ++
src/markdown-2-html.spec.ts | 41 ++++++++++++++++++++++++++++++++++
src/methods/a.method.ts | 35 +++++++++++++++++++++++++++++
src/methods/iframe.method.ts | 12 +++++++++-
src/methods/traverse.method.ts | 31 ++++++++++++++++++++++++-
5 files changed, 119 insertions(+), 2 deletions(-)
diff --git a/src/consts/regexes.const.ts b/src/consts/regexes.const.ts
index 18c871a..3752c88 100644
--- a/src/consts/regexes.const.ts
+++ b/src/consts/regexes.const.ts
@@ -9,6 +9,8 @@ export const COMMUNITY_REGEX = /^https?:\/\/(.*)\/c\/(hive-\d+)(.*)/i
export const YOUTUBE_REGEX = /(?:https?:\/\/)?(?:www\.)?(?:youtube\.com\/watch\?v=|youtu\.be\/)([^& \n<]+)(?:[^ \n<]+)?/g
export const VIMEO_REGEX = /(https?:\/\/)?(www\.)?(?:vimeo)\.com.*(?:videos|video|channels|)\/([\d]+)/i
export const BITCHUTE_REGEX = /^(?:https?:\/\/)?(?:www\.)?bitchute.com\/(?:video|embed)\/([a-z0-9]+)/i
+export const INFOWARS_REGEX = /https:\/\/(?infowars\.com|freeworldnews\.tv)\/watch\?id=(?
"
let input = {
author: 'alexjones1z',
permlink: 'paypalsendingYourDataToADL-' + counter++,
@@ -959,7 +959,7 @@ describe('Markdown2Html', () => {
it('Infowars Embedding code', () => {
const expected = ""
- +"View at freeworldnews.tv"
+ +"View at freeworldnews.tv"
let input = {
author: 'alexjones1z',
permlink: 'paypalsendingYourDataToADL-' + counter++,
diff --git a/src/methods/a.method.ts b/src/methods/a.method.ts
index fb4a2a3..39eabaa 100644
--- a/src/methods/a.method.ts
+++ b/src/methods/a.method.ts
@@ -248,8 +248,10 @@ export function a(el: HTMLElement, forApp: boolean, webp: boolean): void {
// '" frameBorder="0" allowfullscreen>' +
// ' '
const a = el.ownerDocument.createElement('a')
- a.setAttribute('data-href', IWmatch[0])
+ a.setAttribute('href', IWmatch[0])
a.setAttribute('class', "markdown-external-link")
+ a.setAttribute('target', '_blank')
+ a.setAttribute('rel', 'noopener')
a.textContent = 'View at ' + domain
el.parentNode.insertBefore(iframe, el)
el.parentNode.insertBefore(a, el)
From a3ad36b2a6b17b0b36e9dcb594a7e2b4ccc720ab Mon Sep 17 00:00:00 2001
From: leprechaun
Date: Wed, 4 Aug 2021 14:29:05 -0300
Subject: [PATCH 5/9] * allow for banned.video URLs to get embedded
---
src/consts/regexes.const.ts | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/consts/regexes.const.ts b/src/consts/regexes.const.ts
index 8b57fdc..ae78b54 100644
--- a/src/consts/regexes.const.ts
+++ b/src/consts/regexes.const.ts
@@ -9,7 +9,7 @@ export const COMMUNITY_REGEX = /^https?:\/\/(.*)\/c\/(hive-\d+)(.*)/i
export const YOUTUBE_REGEX = /(?:https?:\/\/)?(?:www\.)?(?:youtube\.com\/watch\?v=|youtu\.be\/)([^& \n<]+)(?:[^ \n<]+)?/g
export const VIMEO_REGEX = /(https?:\/\/)?(www\.)?(?:vimeo)\.com.*(?:videos|video|channels|)\/([\d]+)/i
export const BITCHUTE_REGEX = /^(?:https?:\/\/)?(?:www\.)?bitchute.com\/(?:video|embed)\/([a-z0-9]+)/i
-export const INFOWARS_REGEX = /https:\/\/(?infowars\.com|freeworldnews\.tv|2020electioncenter\.com)\/watch\?id=(?[0-9a-f]+)/
+export const INFOWARS_REGEX = /https:\/\/(?banned.video|infowars\.com|freeworldnews\.tv|2020electioncenter\.com)\/watch\?id=(?[0-9a-f]+)/
export const INFOWARS_EMBED_REGEX = /https:\/\/api\.banned\.video\/embed\/(?[0-9a-f]+)/
export const D_TUBE_REGEX = /(https?:\/\/d.tube.#!\/v\/)(\w+)\/(\w+)/g
export const D_TUBE_REGEX2 = /(https?:\/\/d.tube\/v\/)(\w+)\/(\w+)/g
From 371f50583fe2404b1701be77e799c88102a8f5ec Mon Sep 17 00:00:00 2001
From: leprechaun
Date: Thu, 5 Aug 2021 06:41:28 -0300
Subject: [PATCH 6/9] * ignore *~ and *.marks files
---
.gitignore | 3 +++
1 file changed, 3 insertions(+)
diff --git a/.gitignore b/.gitignore
index 7df2d89..343d7f7 100644
--- a/.gitignore
+++ b/.gitignore
@@ -39,3 +39,6 @@ yarn.lock
others
.DS_Store
+*.marks
+*~
+
From eafd53863cb0d8da742c63c041cfdc5d819e9926 Mon Sep 17 00:00:00 2001
From: leprechaun
Date: Thu, 5 Aug 2021 07:52:11 -0300
Subject: [PATCH 7/9] * migrated magic numbers from iframe.method.ts to
regexes.consts.ts
---
src/consts/regexes.const.ts | 10 +++++++++-
src/methods/iframe.method.ts | 21 +++++++++++----------
2 files changed, 20 insertions(+), 11 deletions(-)
diff --git a/src/consts/regexes.const.ts b/src/consts/regexes.const.ts
index ae78b54..adad714 100644
--- a/src/consts/regexes.const.ts
+++ b/src/consts/regexes.const.ts
@@ -7,12 +7,15 @@ export const MENTION_REGEX = /^https?:\/\/(.*)\/(@[\w.\d-]+)$/i
export const COPIED_POST_REGEX = /\/(.*)\/(@[\w.\d-]+)\/(.*)/i
export const COMMUNITY_REGEX = /^https?:\/\/(.*)\/c\/(hive-\d+)(.*)/i
export const YOUTUBE_REGEX = /(?:https?:\/\/)?(?:www\.)?(?:youtube\.com\/watch\?v=|youtu\.be\/)([^& \n<]+)(?:[^ \n<]+)?/g
+export const YOUTUBE_EMBED_REGEX = /^(https?:)?\/\/www.youtube.com\/embed\/.*/i
export const VIMEO_REGEX = /(https?:\/\/)?(www\.)?(?:vimeo)\.com.*(?:videos|video|channels|)\/([\d]+)/i
+export const VIMEO_EMBED_REGEX = /https:\/\/player\.vimeo\.com\/video\/([0-9]+)/
export const BITCHUTE_REGEX = /^(?:https?:\/\/)?(?:www\.)?bitchute.com\/(?:video|embed)\/([a-z0-9]+)/i
export const INFOWARS_REGEX = /https:\/\/(?banned.video|infowars\.com|freeworldnews\.tv|2020electioncenter\.com)\/watch\?id=(?[0-9a-f]+)/
export const INFOWARS_EMBED_REGEX = /https:\/\/api\.banned\.video\/embed\/(?[0-9a-f]+)/
export const D_TUBE_REGEX = /(https?:\/\/d.tube.#!\/v\/)(\w+)\/(\w+)/g
export const D_TUBE_REGEX2 = /(https?:\/\/d.tube\/v\/)(\w+)\/(\w+)/g
+export const D_TUBE_EMBED_REGEX = /^https:\/\/emb.d.tube\/.*/i
export const TWITCH_REGEX = /https?:\/\/(?:www.)?twitch.tv\/(?:(videos)\/)?([a-zA-Z0-9][\w]{3,24})/i
export const DAPPLR_REGEX = /^(https?:)?\/\/[a-z]*\.dapplr.in\/file\/dapplr-videos\/.*/i
export const TRUVVL_REGEX = /^https?:\/\/embed.truvvl.com\/(@[\w.\d-]+)\/(.*)/i
@@ -20,7 +23,12 @@ export const LBRY_REGEX = /^(https?:)?\/\/lbry.tv\/\$\/embed\/.*/i
export const ODYSEE_REGEX = /^(https?:)?\/\/odysee.com\/\$\/embed\/.*/i
export const ARCH_REGEX = /^(https?:)?\/\/archive.org\/embed\/.*/i
export const SPEAK_REGEX = /(?:https?:\/\/(?:3speak.([a-z]+)\/watch\?v=)|(?:3speak.([a-z]+)\/embed\?v=))([A-Za-z0-9\_\-\.\/]+)(&.*)?/i
+export const SPEAK_EMBED_REGEX = /^(https?:)?\/\/3speak.online\/embed\?.*/i
export const TWITTER_REGEX = /(?:https?:\/\/(?:(?:twitter\.com\/(.*?)\/status\/(.*))))/gi
export const SPOTIFY_REGEX = /^https:\/\/open\.spotify\.com\/playlist\/(.*)?$/gi
export const RUMBLE_REGEX = /^https:\/\/rumble\.com\/embed\/(?[a-zA-Z0-9-]+)\/\?pub=4/
-export const BRIGHTEON_REGEX = /^https?:\/\/(www\.)?brighteon\.com\/(?:embed\/)?(?[0-9a-f-]+)/i
\ No newline at end of file
+export const BRIGHTEON_REGEX = /^https?:\/\/(www\.)?brighteon\.com\/(?:embed\/)?(?[0-9a-f-]+)/i
+export const VIMM_EMBED_REGEX = /^https:\/\/www.vimm.tv\/.*/i
+export const SPOTIFY_EMBED_REGEX = /^https:\/\/open\.spotify\.com\/(embed|embed-podcast)\/(playlist|show|episode|track|album)\/(.*)/i
+export const SOUNDCLOUD_EMBED_REGEX = /^https:\/\/w.soundcloud.com\/player\/.*/i
+export const TWITCH_EMBED_REGEX = /^(https?:)?\/\/player.twitch.tv\/.*/i
\ No newline at end of file
diff --git a/src/methods/iframe.method.ts b/src/methods/iframe.method.ts
index c52e695..aefc82e 100644
--- a/src/methods/iframe.method.ts
+++ b/src/methods/iframe.method.ts
@@ -1,5 +1,7 @@
import { ARCH_REGEX, DAPPLR_REGEX, INFOWARS_REGEX, INFOWARS_EMBED_REGEX, LBRY_REGEX, TRUVVL_REGEX,
-ODYSEE_REGEX, BITCHUTE_REGEX, RUMBLE_REGEX, BRIGHTEON_REGEX } from '../consts'
+ODYSEE_REGEX, BITCHUTE_REGEX, RUMBLE_REGEX, BRIGHTEON_REGEX, VIMEO_EMBED_REGEX, SPEAK_EMBED_REGEX,
+VIMM_EMBED_REGEX, D_TUBE_EMBED_REGEX, SPOTIFY_EMBED_REGEX, SOUNDCLOUD_EMBED_REGEX,
+TWITCH_EMBED_REGEX, YOUTUBE_EMBED_REGEX} from '../consts'
export function iframe(el: HTMLElement): void {
const src = el.getAttribute('src')
@@ -12,7 +14,6 @@ export function iframe(el: HTMLElement): void {
const IWmatch = src.match(INFOWARS_EMBED_REGEX)
if (IWmatch) {
- //el.setAttribute('sandbox', 'allow-scripts allow-same-origin allow-popups')
el.setAttribute('allowfullscreen', 'true')
el.setAttribute('frameborder', '0')
return
@@ -24,7 +25,7 @@ export function iframe(el: HTMLElement): void {
}
// Youtube
- if (src.match(/^(https?:)?\/\/www.youtube.com\/embed\/.*/i)) {
+ if (src.match(YOUTUBE_EMBED_REGEX)) {
// strip query string (yt: autoplay=1,controls=0,showinfo=0, etc)
const s = src.replace(/\?.+$/, '')
el.setAttribute('src', s)
@@ -32,7 +33,7 @@ export function iframe(el: HTMLElement): void {
}
// Vimeo
- const m = src.match(/https:\/\/player\.vimeo\.com\/video\/([0-9]+)/)
+ const m = src.match(VIMEO_EMBED_REGEX)
if (m && m.length === 2) {
const s = `https://player.vimeo.com/video/${m[1]}`
el.setAttribute('src', s)
@@ -40,7 +41,7 @@ export function iframe(el: HTMLElement): void {
}
// Twitch
- if (src.match(/^(https?:)?\/\/player.twitch.tv\/.*/i)) {
+ if (src.match(TWITCH_EMBED_REGEX)) {
const parentDomain = 'ecency.com'
const s = `${src}&parent=${parentDomain}&autoplay=false`
el.setAttribute('src', s)
@@ -48,14 +49,14 @@ export function iframe(el: HTMLElement): void {
}
// 3Speak
- if (src.match(/^(https?:)?\/\/3speak.online\/embed\?.*/i)) {
+ if (src.match(SPEAK_EMBED_REGEX)) {
const s = `${src}&autoplay=true`
el.setAttribute('src', s)
return
}
// Spotify
- if (src.match(/^https:\/\/open\.spotify\.com\/(embed|embed-podcast)\/(playlist|show|episode|track|album)\/(.*)/i)) {
+ if (src.match(SPOTIFY_EMBED_REGEX)) {
el.setAttribute('src', src)
el.setAttribute('sandbox', 'allow-scripts allow-same-origin allow-popups')
el.setAttribute('frameborder', '0')
@@ -63,7 +64,7 @@ export function iframe(el: HTMLElement): void {
}
// Soundcloud
- if (src.match(/^https:\/\/w.soundcloud.com\/player\/.*/i)) {
+ if (src.match(SOUNDCLOUD_EMBED_REGEX)) {
const match = src.match(/url=(.+?)&/)
if (match && match.length === 2) {
const s = `https://w.soundcloud.com/player/?url=${match[1]}&auto_play=false&hide_related=false&show_comments=true&show_user=true&show_reposts=false&visual=true`
@@ -73,7 +74,7 @@ export function iframe(el: HTMLElement): void {
}
// Dtube
- if (src.match(/^https:\/\/emb.d.tube\/.*/i)) {
+ if (src.match(D_TUBE_EMBED_REGEX)) {
el.setAttribute('src', src)
el.setAttribute('sandbox', 'allow-scripts allow-same-origin')
el.setAttribute('frameborder', '0')
@@ -82,7 +83,7 @@ export function iframe(el: HTMLElement): void {
}
// VIMM
- if (src.match(/^https:\/\/www.vimm.tv\/.*/i)) {
+ if (src.match(VIMM_EMBED_REGEX)) {
el.setAttribute('src', src)
el.setAttribute('sandbox', 'allow-scripts allow-same-origin allow-popups')
el.setAttribute('frameborder', '0')
From 7b5e031c8d3cd1e8ddda136bbe74318edd168c6b Mon Sep 17 00:00:00 2001
From: leprechaun
Date: Thu, 5 Aug 2021 08:04:01 -0300
Subject: [PATCH 8/9] * handle other TLDs in iframe tags for 3speak
---
src/consts/regexes.const.ts | 2 +-
src/markdown-2-html.spec.ts | 10 ++++++++++
2 files changed, 11 insertions(+), 1 deletion(-)
diff --git a/src/consts/regexes.const.ts b/src/consts/regexes.const.ts
index adad714..f53f4b9 100644
--- a/src/consts/regexes.const.ts
+++ b/src/consts/regexes.const.ts
@@ -23,7 +23,7 @@ export const LBRY_REGEX = /^(https?:)?\/\/lbry.tv\/\$\/embed\/.*/i
export const ODYSEE_REGEX = /^(https?:)?\/\/odysee.com\/\$\/embed\/.*/i
export const ARCH_REGEX = /^(https?:)?\/\/archive.org\/embed\/.*/i
export const SPEAK_REGEX = /(?:https?:\/\/(?:3speak.([a-z]+)\/watch\?v=)|(?:3speak.([a-z]+)\/embed\?v=))([A-Za-z0-9\_\-\.\/]+)(&.*)?/i
-export const SPEAK_EMBED_REGEX = /^(https?:)?\/\/3speak.online\/embed\?.*/i
+export const SPEAK_EMBED_REGEX = /^(https?:)?\/\/3speak.(?:tv|co|online)\/embed\?.*/i
export const TWITTER_REGEX = /(?:https?:\/\/(?:(?:twitter\.com\/(.*?)\/status\/(.*))))/gi
export const SPOTIFY_REGEX = /^https:\/\/open\.spotify\.com\/playlist\/(.*)?$/gi
export const RUMBLE_REGEX = /^https:\/\/rumble\.com\/embed\/(?[a-zA-Z0-9-]+)\/\?pub=4/
diff --git a/src/markdown-2-html.spec.ts b/src/markdown-2-html.spec.ts
index 983a9af..b5b5cb3 100644
--- a/src/markdown-2-html.spec.ts
+++ b/src/markdown-2-html.spec.ts
@@ -425,6 +425,16 @@ describe('Markdown2Html', () => {
const expected = '
Watch on 3Speak
'
expect(markdown2Html(input)).toBe(expected)
+
+ const input2 = {
+ author: 'foo33399',
+ permlink: 'bar32300a',
+ last_update: '2029-05-10T09:15:21',
+ body: ''
+ }
+ const expected2 = ''
+
+ expect(markdown2Html(input2)).toBe(expected2)
})
it('28- Should handle peakd post links', () => {
From 82cc8cd7f8f2bc71261222ed2a3b388513196fcc Mon Sep 17 00:00:00 2001
From: leprechaun
Date: Thu, 5 Aug 2021 19:41:15 -0300
Subject: [PATCH 9/9] * added support for Brand New Tube
---
src/consts/regexes.const.ts | 3 ++-
src/methods/iframe.method.ts | 8 +++++++-
2 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/src/consts/regexes.const.ts b/src/consts/regexes.const.ts
index f53f4b9..11c1fe4 100644
--- a/src/consts/regexes.const.ts
+++ b/src/consts/regexes.const.ts
@@ -31,4 +31,5 @@ export const BRIGHTEON_REGEX = /^https?:\/\/(www\.)?brighteon\.com\/(?:embed\/)?
export const VIMM_EMBED_REGEX = /^https:\/\/www.vimm.tv\/.*/i
export const SPOTIFY_EMBED_REGEX = /^https:\/\/open\.spotify\.com\/(embed|embed-podcast)\/(playlist|show|episode|track|album)\/(.*)/i
export const SOUNDCLOUD_EMBED_REGEX = /^https:\/\/w.soundcloud.com\/player\/.*/i
-export const TWITCH_EMBED_REGEX = /^(https?:)?\/\/player.twitch.tv\/.*/i
\ No newline at end of file
+export const TWITCH_EMBED_REGEX = /^(https?:)?\/\/player.twitch.tv\/.*/i
+export const BRAND_NEW_TUBE_REGEX = /^https:\/\/brandnewtube\.com\/embed\/[a-z0-9]+$/i
\ No newline at end of file
diff --git a/src/methods/iframe.method.ts b/src/methods/iframe.method.ts
index aefc82e..fef9a00 100644
--- a/src/methods/iframe.method.ts
+++ b/src/methods/iframe.method.ts
@@ -1,7 +1,7 @@
import { ARCH_REGEX, DAPPLR_REGEX, INFOWARS_REGEX, INFOWARS_EMBED_REGEX, LBRY_REGEX, TRUVVL_REGEX,
ODYSEE_REGEX, BITCHUTE_REGEX, RUMBLE_REGEX, BRIGHTEON_REGEX, VIMEO_EMBED_REGEX, SPEAK_EMBED_REGEX,
VIMM_EMBED_REGEX, D_TUBE_EMBED_REGEX, SPOTIFY_EMBED_REGEX, SOUNDCLOUD_EMBED_REGEX,
-TWITCH_EMBED_REGEX, YOUTUBE_EMBED_REGEX} from '../consts'
+TWITCH_EMBED_REGEX, YOUTUBE_EMBED_REGEX, BRAND_NEW_TUBE_REGEX} from '../consts'
export function iframe(el: HTMLElement): void {
const src = el.getAttribute('src')
@@ -134,6 +134,12 @@ export function iframe(el: HTMLElement): void {
return
}
+ // Brandnew Tube
+ if (src.match(BRAND_NEW_TUBE_REGEX)) {
+ el.setAttribute('frameborder', '0')
+ return;
+ }
+
// archive.org
if (src.match(ARCH_REGEX)) {
el.setAttribute('src', src)