@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/browser/index.js
CHANGED
|
@@ -83,6 +83,7 @@ var SPEAK_REGEX = /(?:https?:\/\/(?:(?:play\.)?3speak\.([a-z]+)\/watch\?v=)|(?:(
|
|
|
83
83
|
var SPEAK_EMBED_REGEX = /^(https?:)?\/\/(?:play\.)?3speak\.([a-z]+)\/(?:embed|watch)\?.+$/i;
|
|
84
84
|
var SPEAK_AUDIO_REGEX = /https?:\/\/audio\.3speak\.tv\/play\?[^\s]+/i;
|
|
85
85
|
var SPEAK_AUDIO_EMBED_REGEX = /^https?:\/\/audio\.3speak\.tv\/play\?.+$/i;
|
|
86
|
+
var LIKETU_AUDIO_REGEX = /^https?:\/\/cdn\.liketu\.com\/.+\.(?:webm|mp3|m4a|ogg|wav)(?:\?.*)?$/i;
|
|
86
87
|
var TWITTER_REGEX = /(?:https?:\/\/(?:(?:twitter\.com\/(.*?)\/status\/(.*))))/gi;
|
|
87
88
|
var SPOTIFY_REGEX = /^https:\/\/open\.spotify\.com\/playlist\/(.*)?$/gi;
|
|
88
89
|
var RUMBLE_REGEX = /^https:\/\/rumble\.com\/embed\/([a-zA-Z0-9-]+)\/\?pub=\w+/;
|
|
@@ -143,6 +144,7 @@ var ALLOWED_ATTRIBUTES = {
|
|
|
143
144
|
"span": ["class", "id", "data-align"],
|
|
144
145
|
"iframe": ["src", "class", "frameborder", "allowfullscreen", "webkitallowfullscreen", "mozallowfullscreen", "sandbox"],
|
|
145
146
|
"video": ["src", "controls", "poster"],
|
|
147
|
+
"audio": ["src", "controls", "preload"],
|
|
146
148
|
"div": ["class", "id", "data-align"],
|
|
147
149
|
"strong": [],
|
|
148
150
|
"b": [],
|
|
@@ -693,7 +695,8 @@ function sanitizeHtml(html) {
|
|
|
693
695
|
}
|
|
694
696
|
if (tag === "source" && name === "srcset" && !isProxyPSrcset(decoded)) return "";
|
|
695
697
|
if (tag === "source" && name === "type" && decodedLower !== "image/avif" && decodedLower !== "image/webp") return "";
|
|
696
|
-
if (tag === "video" && ["src", "poster"].includes(name) && !/^https?:\/\//.test(decodedLower)) return "";
|
|
698
|
+
if ((tag === "video" || tag === "audio") && ["src", "poster"].includes(name) && !/^https?:\/\//.test(decodedLower)) return "";
|
|
699
|
+
if (tag === "audio" && name === "preload" && decodedLower !== "metadata" && decodedLower !== "none") return "";
|
|
697
700
|
if (tag === "img" && ["dynsrc", "lowsrc"].includes(name)) return "";
|
|
698
701
|
if (tag === "span" && name === "class" && decoded.toLowerCase().trim() === "wr") return "";
|
|
699
702
|
if (EMBED_SRC_DATA_ATTRS.has(name) && !isAllowedEmbedSrc(decoded)) return "";
|
|
@@ -1213,14 +1216,15 @@ function a(el, forApp, parentDomain = "ecency.com", seoContext, renderOptions) {
|
|
|
1213
1216
|
el.setAttribute("data-start-time", startTime);
|
|
1214
1217
|
}
|
|
1215
1218
|
if (renderOptions?.embedVideosDirectly) {
|
|
1219
|
+
const directSrc = `https://www.youtube.com/embed/${vid}`;
|
|
1216
1220
|
const wrapper = el.ownerDocument.createElement("span");
|
|
1217
1221
|
wrapper.setAttribute("class", "er-youtube-frame");
|
|
1218
1222
|
wrapper.setAttribute("style", "display:block");
|
|
1219
1223
|
const iframe2 = el.ownerDocument.createElement("iframe");
|
|
1220
1224
|
iframe2.setAttribute("class", "youtube-player");
|
|
1221
|
-
iframe2.setAttribute("src",
|
|
1225
|
+
iframe2.setAttribute("src", directSrc);
|
|
1222
1226
|
iframe2.setAttribute("title", "YouTube video");
|
|
1223
|
-
iframe2.setAttribute("allow", "accelerometer;
|
|
1227
|
+
iframe2.setAttribute("allow", "accelerometer; encrypted-media; gyroscope; picture-in-picture; web-share");
|
|
1224
1228
|
iframe2.setAttribute("allowfullscreen", "");
|
|
1225
1229
|
wrapper.appendChild(iframe2);
|
|
1226
1230
|
el.appendChild(wrapper);
|
|
@@ -1357,12 +1361,13 @@ function a(el, forApp, parentDomain = "ecency.com", seoContext, renderOptions) {
|
|
|
1357
1361
|
el.textContent = "";
|
|
1358
1362
|
}
|
|
1359
1363
|
if (renderOptions?.embedVideosDirectly) {
|
|
1364
|
+
const directSrc = `${videoHref}&autoplay=false`;
|
|
1360
1365
|
const wrapper = el.ownerDocument.createElement("span");
|
|
1361
1366
|
wrapper.setAttribute("class", "er-speak-frame");
|
|
1362
1367
|
wrapper.setAttribute("style", "display:block");
|
|
1363
1368
|
const iframe2 = el.ownerDocument.createElement("iframe");
|
|
1364
1369
|
iframe2.setAttribute("class", "speak-iframe");
|
|
1365
|
-
iframe2.setAttribute("src",
|
|
1370
|
+
iframe2.setAttribute("src", directSrc);
|
|
1366
1371
|
iframe2.setAttribute("title", "3Speak video");
|
|
1367
1372
|
iframe2.setAttribute("allow", "accelerometer; encrypted-media; gyroscope; picture-in-picture; web-share");
|
|
1368
1373
|
iframe2.setAttribute("allowfullscreen", "");
|
|
@@ -1403,6 +1408,17 @@ function a(el, forApp, parentDomain = "ecency.com", seoContext, renderOptions) {
|
|
|
1403
1408
|
el.appendChild(ifr);
|
|
1404
1409
|
return;
|
|
1405
1410
|
}
|
|
1411
|
+
if (href.match(LIKETU_AUDIO_REGEX)) {
|
|
1412
|
+
el.setAttribute("class", "markdown-audio-link markdown-audio-link-liketu");
|
|
1413
|
+
el.removeAttribute("href");
|
|
1414
|
+
el.textContent = "";
|
|
1415
|
+
const audio = el.ownerDocument.createElement("audio");
|
|
1416
|
+
audio.setAttribute("controls", "");
|
|
1417
|
+
audio.setAttribute("preload", "metadata");
|
|
1418
|
+
audio.setAttribute("src", href);
|
|
1419
|
+
el.appendChild(audio);
|
|
1420
|
+
return;
|
|
1421
|
+
}
|
|
1406
1422
|
const matchT = href.match(TWITTER_REGEX);
|
|
1407
1423
|
if (matchT && el.textContent.trim() === href) {
|
|
1408
1424
|
TWITTER_REGEX.lastIndex = 0;
|
|
@@ -1475,7 +1491,7 @@ function a(el, forApp, parentDomain = "ecency.com", seoContext, renderOptions) {
|
|
|
1475
1491
|
}
|
|
1476
1492
|
|
|
1477
1493
|
// src/methods/iframe.method.ts
|
|
1478
|
-
function iframe(el, parentDomain = "ecency.com", forApp = false) {
|
|
1494
|
+
function iframe(el, parentDomain = "ecency.com", forApp = false, renderOptions) {
|
|
1479
1495
|
if (!el || !el.parentNode) {
|
|
1480
1496
|
return;
|
|
1481
1497
|
}
|
|
@@ -1518,7 +1534,12 @@ function iframe(el, parentDomain = "ecency.com", forApp = false) {
|
|
|
1518
1534
|
normalizedSrc = `${normalizedSrc}&mode=iframe`;
|
|
1519
1535
|
}
|
|
1520
1536
|
const hasAutoplay = /[?&]autoplay=/.test(normalizedSrc);
|
|
1521
|
-
let s
|
|
1537
|
+
let s;
|
|
1538
|
+
if (renderOptions?.embedVideosDirectly) {
|
|
1539
|
+
s = hasAutoplay ? normalizedSrc.replace(/([?&]autoplay=)[^&]*/i, "$1false") : `${normalizedSrc}&autoplay=false`;
|
|
1540
|
+
} else {
|
|
1541
|
+
s = hasAutoplay ? normalizedSrc : `${normalizedSrc}&autoplay=true`;
|
|
1542
|
+
}
|
|
1522
1543
|
if (forApp && !/[?&]layout=/.test(s)) {
|
|
1523
1544
|
s = `${s}&layout=mobile`;
|
|
1524
1545
|
}
|
|
@@ -1832,7 +1853,7 @@ function traverse(node, forApp, depth = 0, state = { firstImageFound: false }, p
|
|
|
1832
1853
|
a(child, forApp, parentDomain, seoContext, renderOptions);
|
|
1833
1854
|
}
|
|
1834
1855
|
if (child.nodeName.toLowerCase() === "iframe") {
|
|
1835
|
-
iframe(child, parentDomain, forApp);
|
|
1856
|
+
iframe(child, parentDomain, forApp, renderOptions);
|
|
1836
1857
|
}
|
|
1837
1858
|
if (child.nodeName === "#text") {
|
|
1838
1859
|
text(child, forApp);
|
|
@@ -1857,7 +1878,10 @@ function traverse(node, forApp, depth = 0, state = { firstImageFound: false }, p
|
|
|
1857
1878
|
|
|
1858
1879
|
// src/methods/clean-reply.method.ts
|
|
1859
1880
|
function cleanReply(s) {
|
|
1860
|
-
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) =>
|
|
1881
|
+
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) => {
|
|
1882
|
+
const l = item.toLowerCase();
|
|
1883
|
+
return !(l.includes("posted from liketu speak") && l.includes("auto-transcrib"));
|
|
1884
|
+
}).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>`, "");
|
|
1861
1885
|
}
|
|
1862
1886
|
var domSerializer = domSerializerModule.default || domSerializerModule;
|
|
1863
1887
|
var lolightPromise = null;
|