@ecency/render-helper 2.5.12 → 2.5.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/index.js +32 -8
- package/dist/browser/index.js.map +1 -1
- package/dist/node/index.cjs +32 -8
- package/dist/node/index.cjs.map +1 -1
- package/dist/node/index.mjs +32 -8
- package/dist/node/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/node/index.cjs
CHANGED
|
@@ -112,6 +112,7 @@ var SPEAK_REGEX = /(?:https?:\/\/(?:(?:play\.)?3speak\.([a-z]+)\/watch\?v=)|(?:(
|
|
|
112
112
|
var SPEAK_EMBED_REGEX = /^(https?:)?\/\/(?:play\.)?3speak\.([a-z]+)\/(?:embed|watch)\?.+$/i;
|
|
113
113
|
var SPEAK_AUDIO_REGEX = /https?:\/\/audio\.3speak\.tv\/play\?[^\s]+/i;
|
|
114
114
|
var SPEAK_AUDIO_EMBED_REGEX = /^https?:\/\/audio\.3speak\.tv\/play\?.+$/i;
|
|
115
|
+
var LIKETU_AUDIO_REGEX = /^https?:\/\/cdn\.liketu\.com\/.+\.(?:webm|mp3|m4a|ogg|wav)(?:\?.*)?$/i;
|
|
115
116
|
var TWITTER_REGEX = /(?:https?:\/\/(?:(?:twitter\.com\/(.*?)\/status\/(.*))))/gi;
|
|
116
117
|
var SPOTIFY_REGEX = /^https:\/\/open\.spotify\.com\/playlist\/(.*)?$/gi;
|
|
117
118
|
var RUMBLE_REGEX = /^https:\/\/rumble\.com\/embed\/([a-zA-Z0-9-]+)\/\?pub=\w+/;
|
|
@@ -172,6 +173,7 @@ var ALLOWED_ATTRIBUTES = {
|
|
|
172
173
|
"span": ["class", "id", "data-align"],
|
|
173
174
|
"iframe": ["src", "class", "frameborder", "allowfullscreen", "webkitallowfullscreen", "mozallowfullscreen", "sandbox"],
|
|
174
175
|
"video": ["src", "controls", "poster"],
|
|
176
|
+
"audio": ["src", "controls", "preload"],
|
|
175
177
|
"div": ["class", "id", "data-align"],
|
|
176
178
|
"strong": [],
|
|
177
179
|
"b": [],
|
|
@@ -722,7 +724,8 @@ function sanitizeHtml(html) {
|
|
|
722
724
|
}
|
|
723
725
|
if (tag === "source" && name === "srcset" && !isProxyPSrcset(decoded)) return "";
|
|
724
726
|
if (tag === "source" && name === "type" && decodedLower !== "image/avif" && decodedLower !== "image/webp") return "";
|
|
725
|
-
if (tag === "video" && ["src", "poster"].includes(name) && !/^https?:\/\//.test(decodedLower)) return "";
|
|
727
|
+
if ((tag === "video" || tag === "audio") && ["src", "poster"].includes(name) && !/^https?:\/\//.test(decodedLower)) return "";
|
|
728
|
+
if (tag === "audio" && name === "preload" && decodedLower !== "metadata" && decodedLower !== "none") return "";
|
|
726
729
|
if (tag === "img" && ["dynsrc", "lowsrc"].includes(name)) return "";
|
|
727
730
|
if (tag === "span" && name === "class" && decoded.toLowerCase().trim() === "wr") return "";
|
|
728
731
|
if (EMBED_SRC_DATA_ATTRS.has(name) && !isAllowedEmbedSrc(decoded)) return "";
|
|
@@ -1242,14 +1245,15 @@ function a(el, forApp, parentDomain = "ecency.com", seoContext, renderOptions) {
|
|
|
1242
1245
|
el.setAttribute("data-start-time", startTime);
|
|
1243
1246
|
}
|
|
1244
1247
|
if (renderOptions?.embedVideosDirectly) {
|
|
1248
|
+
const directSrc = `https://www.youtube.com/embed/${vid}`;
|
|
1245
1249
|
const wrapper = el.ownerDocument.createElement("span");
|
|
1246
1250
|
wrapper.setAttribute("class", "er-youtube-frame");
|
|
1247
1251
|
wrapper.setAttribute("style", "display:block");
|
|
1248
1252
|
const iframe2 = el.ownerDocument.createElement("iframe");
|
|
1249
1253
|
iframe2.setAttribute("class", "youtube-player");
|
|
1250
|
-
iframe2.setAttribute("src",
|
|
1254
|
+
iframe2.setAttribute("src", directSrc);
|
|
1251
1255
|
iframe2.setAttribute("title", "YouTube video");
|
|
1252
|
-
iframe2.setAttribute("allow", "accelerometer;
|
|
1256
|
+
iframe2.setAttribute("allow", "accelerometer; encrypted-media; gyroscope; picture-in-picture; web-share");
|
|
1253
1257
|
iframe2.setAttribute("allowfullscreen", "");
|
|
1254
1258
|
wrapper.appendChild(iframe2);
|
|
1255
1259
|
el.appendChild(wrapper);
|
|
@@ -1386,12 +1390,13 @@ function a(el, forApp, parentDomain = "ecency.com", seoContext, renderOptions) {
|
|
|
1386
1390
|
el.textContent = "";
|
|
1387
1391
|
}
|
|
1388
1392
|
if (renderOptions?.embedVideosDirectly) {
|
|
1393
|
+
const directSrc = `${videoHref}&autoplay=false`;
|
|
1389
1394
|
const wrapper = el.ownerDocument.createElement("span");
|
|
1390
1395
|
wrapper.setAttribute("class", "er-speak-frame");
|
|
1391
1396
|
wrapper.setAttribute("style", "display:block");
|
|
1392
1397
|
const iframe2 = el.ownerDocument.createElement("iframe");
|
|
1393
1398
|
iframe2.setAttribute("class", "speak-iframe");
|
|
1394
|
-
iframe2.setAttribute("src",
|
|
1399
|
+
iframe2.setAttribute("src", directSrc);
|
|
1395
1400
|
iframe2.setAttribute("title", "3Speak video");
|
|
1396
1401
|
iframe2.setAttribute("allow", "accelerometer; encrypted-media; gyroscope; picture-in-picture; web-share");
|
|
1397
1402
|
iframe2.setAttribute("allowfullscreen", "");
|
|
@@ -1432,6 +1437,17 @@ function a(el, forApp, parentDomain = "ecency.com", seoContext, renderOptions) {
|
|
|
1432
1437
|
el.appendChild(ifr);
|
|
1433
1438
|
return;
|
|
1434
1439
|
}
|
|
1440
|
+
if (href.match(LIKETU_AUDIO_REGEX)) {
|
|
1441
|
+
el.setAttribute("class", "markdown-audio-link markdown-audio-link-liketu");
|
|
1442
|
+
el.removeAttribute("href");
|
|
1443
|
+
el.textContent = "";
|
|
1444
|
+
const audio = el.ownerDocument.createElement("audio");
|
|
1445
|
+
audio.setAttribute("controls", "");
|
|
1446
|
+
audio.setAttribute("preload", "metadata");
|
|
1447
|
+
audio.setAttribute("src", href);
|
|
1448
|
+
el.appendChild(audio);
|
|
1449
|
+
return;
|
|
1450
|
+
}
|
|
1435
1451
|
const matchT = href.match(TWITTER_REGEX);
|
|
1436
1452
|
if (matchT && el.textContent.trim() === href) {
|
|
1437
1453
|
TWITTER_REGEX.lastIndex = 0;
|
|
@@ -1504,7 +1520,7 @@ function a(el, forApp, parentDomain = "ecency.com", seoContext, renderOptions) {
|
|
|
1504
1520
|
}
|
|
1505
1521
|
|
|
1506
1522
|
// src/methods/iframe.method.ts
|
|
1507
|
-
function iframe(el, parentDomain = "ecency.com", forApp = false) {
|
|
1523
|
+
function iframe(el, parentDomain = "ecency.com", forApp = false, renderOptions) {
|
|
1508
1524
|
if (!el || !el.parentNode) {
|
|
1509
1525
|
return;
|
|
1510
1526
|
}
|
|
@@ -1547,7 +1563,12 @@ function iframe(el, parentDomain = "ecency.com", forApp = false) {
|
|
|
1547
1563
|
normalizedSrc = `${normalizedSrc}&mode=iframe`;
|
|
1548
1564
|
}
|
|
1549
1565
|
const hasAutoplay = /[?&]autoplay=/.test(normalizedSrc);
|
|
1550
|
-
let s
|
|
1566
|
+
let s;
|
|
1567
|
+
if (renderOptions?.embedVideosDirectly) {
|
|
1568
|
+
s = hasAutoplay ? normalizedSrc.replace(/([?&]autoplay=)[^&]*/i, "$1false") : `${normalizedSrc}&autoplay=false`;
|
|
1569
|
+
} else {
|
|
1570
|
+
s = hasAutoplay ? normalizedSrc : `${normalizedSrc}&autoplay=true`;
|
|
1571
|
+
}
|
|
1551
1572
|
if (forApp && !/[?&]layout=/.test(s)) {
|
|
1552
1573
|
s = `${s}&layout=mobile`;
|
|
1553
1574
|
}
|
|
@@ -1861,7 +1882,7 @@ function traverse(node, forApp, depth = 0, state = { firstImageFound: false }, p
|
|
|
1861
1882
|
a(child, forApp, parentDomain, seoContext, renderOptions);
|
|
1862
1883
|
}
|
|
1863
1884
|
if (child.nodeName.toLowerCase() === "iframe") {
|
|
1864
|
-
iframe(child, parentDomain, forApp);
|
|
1885
|
+
iframe(child, parentDomain, forApp, renderOptions);
|
|
1865
1886
|
}
|
|
1866
1887
|
if (child.nodeName === "#text") {
|
|
1867
1888
|
text(child, forApp);
|
|
@@ -1886,7 +1907,10 @@ function traverse(node, forApp, depth = 0, state = { firstImageFound: false }, p
|
|
|
1886
1907
|
|
|
1887
1908
|
// src/methods/clean-reply.method.ts
|
|
1888
1909
|
function cleanReply(s) {
|
|
1889
|
-
return (s ? s.split("\n").filter((item) => item.toLowerCase().includes("posted using [partiko") === false).filter((item) => item.toLowerCase().includes("posted using [dapplr") === false).filter((item) => item.toLowerCase().includes("posted using [leofinance") === false).filter((item) => item.toLowerCase().includes("posted via [neoxian") === false).filter((item) => item.toLowerCase().includes("posted using [neoxian") === false).filter((item) => item.toLowerCase().includes("posted via [first context") === false).filter((item) => item.toLowerCase().includes("posted with [stemgeeks") === false).filter((item) => item.toLowerCase().includes("posted using [bilpcoin") === false).filter((item) => item.toLowerCase().includes("posted using [inleo") === false).filter((item) => item.toLowerCase().includes("posted using [sportstalksocial]") === false).filter((item) => item.toLowerCase().includes("<center><sub>[posted using aeneas.blog") === false).filter((item) => item.toLowerCase().includes("<center><sub>posted via [proofofbrain.io") === false).filter((item) => item.toLowerCase().includes("<center>posted on [hypnochain") === false).filter((item) => item.toLowerCase().includes("<center><sub>posted via [weedcash.network") === false).filter((item) => item.toLowerCase().includes("<center>posted on [naturalmedicine.io") === false).filter((item) => item.toLowerCase().includes("<center><sub>posted via [musicforlife.io") === false).filter((item) => item.toLowerCase().includes("if the truvvl embed is unsupported by your current frontend, click this link to view this story") === false).filter((item) => item.toLowerCase().includes("<center><em>posted from truvvl") === false).filter((item) => item.toLowerCase().includes('view this post <a href="https://travelfeed.io/') === false).filter((item) => item.toLowerCase().includes("read this post on travelfeed.io for the best experience") === false).filter((item) => item.toLowerCase().includes('posted via <a href="https://www.dporn.co/"') === false).filter((item) => item.toLowerCase().includes("\u25B6\uFE0F [watch on 3speak](https://3speak") === false).filter((item) => item.toLowerCase().includes("<sup><sub>posted via [inji.com]") === false).filter((item) => item.toLowerCase().includes("view this post on [liketu]") === false).filter((item) =>
|
|
1910
|
+
return (s ? s.split("\n").filter((item) => item.toLowerCase().includes("posted using [partiko") === false).filter((item) => item.toLowerCase().includes("posted using [dapplr") === false).filter((item) => item.toLowerCase().includes("posted using [leofinance") === false).filter((item) => item.toLowerCase().includes("posted via [neoxian") === false).filter((item) => item.toLowerCase().includes("posted using [neoxian") === false).filter((item) => item.toLowerCase().includes("posted via [first context") === false).filter((item) => item.toLowerCase().includes("posted with [stemgeeks") === false).filter((item) => item.toLowerCase().includes("posted using [bilpcoin") === false).filter((item) => item.toLowerCase().includes("posted using [inleo") === false).filter((item) => item.toLowerCase().includes("posted using [sportstalksocial]") === false).filter((item) => item.toLowerCase().includes("<center><sub>[posted using aeneas.blog") === false).filter((item) => item.toLowerCase().includes("<center><sub>posted via [proofofbrain.io") === false).filter((item) => item.toLowerCase().includes("<center>posted on [hypnochain") === false).filter((item) => item.toLowerCase().includes("<center><sub>posted via [weedcash.network") === false).filter((item) => item.toLowerCase().includes("<center>posted on [naturalmedicine.io") === false).filter((item) => item.toLowerCase().includes("<center><sub>posted via [musicforlife.io") === false).filter((item) => item.toLowerCase().includes("if the truvvl embed is unsupported by your current frontend, click this link to view this story") === false).filter((item) => item.toLowerCase().includes("<center><em>posted from truvvl") === false).filter((item) => item.toLowerCase().includes('view this post <a href="https://travelfeed.io/') === false).filter((item) => item.toLowerCase().includes("read this post on travelfeed.io for the best experience") === false).filter((item) => item.toLowerCase().includes('posted via <a href="https://www.dporn.co/"') === false).filter((item) => item.toLowerCase().includes("\u25B6\uFE0F [watch on 3speak](https://3speak") === false).filter((item) => item.toLowerCase().includes("<sup><sub>posted via [inji.com]") === false).filter((item) => item.toLowerCase().includes("view this post on [liketu]") === false).filter((item) => {
|
|
1911
|
+
const l = item.toLowerCase();
|
|
1912
|
+
return !(l.includes("posted from liketu speak") && l.includes("auto-transcrib"));
|
|
1913
|
+
}).filter((item) => item.toLowerCase().includes("[via Inbox]") === false).filter((item) => item.toLowerCase().includes("<sub>[via apps from](") === false).join("\n") : "").replace('Posted via <a href="https://d.buzz" data-link="promote-link">D.Buzz</a>', "").replace('<div class="pull-right"><a href="/@hive.engage"></a></div>', "").replace('<div><a href="https://engage.hivechain.app"></a></div>', "").replace(`<div class="text-center"><img src="https://cdn.steemitimages.com/DQmNp6YwAm2qwquALZw8PdcovDorwaBSFuxQ38TrYziGT6b/A-20.png"><a href="https://bit.ly/actifit-app"><img src="https://cdn.steemitimages.com/DQmQqfpSmcQtfrHAtzfBtVccXwUL9vKNgZJ2j93m8WNjizw/l5.png"></a><a href="https://bit.ly/actifit-ios"><img src="https://cdn.steemitimages.com/DQmbWy8KzKT1UvCvznUTaFPw6wBUcyLtBT5XL9wdbB7Hfmn/l6.png"></a></div>`, "");
|
|
1890
1914
|
}
|
|
1891
1915
|
var domSerializer = domSerializerModule__namespace.default || domSerializerModule__namespace;
|
|
1892
1916
|
var lolightPromise = null;
|