@ecency/render-helper 2.5.42 → 2.5.44
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/README.md +2 -2
- package/dist/browser/index.js +36 -15
- package/dist/browser/index.js.map +1 -1
- package/dist/node/index.cjs +36 -15
- package/dist/node/index.cjs.map +1 -1
- package/dist/node/index.mjs +36 -15
- package/dist/node/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/node/index.cjs
CHANGED
|
@@ -549,13 +549,13 @@ function extractYtStartTime(url) {
|
|
|
549
549
|
try {
|
|
550
550
|
const urlObj = new URL(url);
|
|
551
551
|
const params = new URLSearchParams(urlObj.search);
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
return params.get("start") || "";
|
|
552
|
+
const m = /^(?:(\d{1,7})h)?(?:(\d{1,7})m)?(?:(\d{1,7})s?)?$/i.exec(params.get("t") || "");
|
|
553
|
+
if (m && (m[1] || m[2] || m[3])) {
|
|
554
|
+
const seconds = +(m[1] || 0) * 3600 + +(m[2] || 0) * 60 + +(m[3] || 0);
|
|
555
|
+
if (seconds <= 9999999) return "" + seconds;
|
|
557
556
|
}
|
|
558
|
-
|
|
557
|
+
const start = params.get("start") || "";
|
|
558
|
+
return /^\d{1,7}$/.test(start) ? "" + +start : "";
|
|
559
559
|
} catch (error) {
|
|
560
560
|
return "";
|
|
561
561
|
}
|
|
@@ -898,6 +898,15 @@ function sanitizeHtml(html, options) {
|
|
|
898
898
|
return preserveImageDimensions ? enforceImageDimensionPair(withoutBareSource) : withoutBareSource;
|
|
899
899
|
}
|
|
900
900
|
|
|
901
|
+
// src/methods/internal-thumbnail.ts
|
|
902
|
+
var internalThumbnails = /* @__PURE__ */ new WeakSet();
|
|
903
|
+
function markInternalThumbnail(el) {
|
|
904
|
+
internalThumbnails.add(el);
|
|
905
|
+
}
|
|
906
|
+
function isInternalThumbnail(el) {
|
|
907
|
+
return internalThumbnails.has(el);
|
|
908
|
+
}
|
|
909
|
+
|
|
901
910
|
// src/methods/img.method.ts
|
|
902
911
|
var IMAGE_SIZES = "(max-width: 768px) 100vw, 700px";
|
|
903
912
|
function wrapInPicture(el, rawUrl) {
|
|
@@ -972,32 +981,40 @@ function img(el, state, forApp = true, renderOptions) {
|
|
|
972
981
|
if (isAvatar || imageIndex !== 0) {
|
|
973
982
|
el.removeAttribute("fetchpriority");
|
|
974
983
|
}
|
|
975
|
-
const
|
|
976
|
-
const shouldReplace = !cls.includes("no-replace");
|
|
984
|
+
const shouldReplace = !isInternalThumbnail(el);
|
|
977
985
|
const base = trimTrailingSlash(getProxyBase());
|
|
978
986
|
const hasAlreadyProxied = src.startsWith(`${base}/p/`) || src.startsWith(`${base}/u/`) || new RegExp(`^${base.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}/\\d+x\\d+/`).test(src);
|
|
979
987
|
if (shouldReplace && !hasAlreadyProxied) {
|
|
980
988
|
const proxified = proxifyImageSrc(decodedSrc, 0, 0, "match", { forceProxy: true });
|
|
981
989
|
if (proxified) {
|
|
982
990
|
el.setAttribute("src", proxified);
|
|
983
|
-
const
|
|
984
|
-
if (
|
|
985
|
-
el.setAttribute("srcset",
|
|
991
|
+
const srcset2 = buildSrcSet(decodedSrc);
|
|
992
|
+
if (srcset2) {
|
|
993
|
+
el.setAttribute("srcset", srcset2);
|
|
986
994
|
el.setAttribute("sizes", IMAGE_SIZES);
|
|
987
995
|
}
|
|
988
996
|
if (!forApp) {
|
|
989
997
|
wrapInPicture(el, decodedSrc);
|
|
990
998
|
}
|
|
999
|
+
} else if (/^https?:\/\//i.test(decodedSrc)) {
|
|
1000
|
+
el.removeAttribute("src");
|
|
1001
|
+
el.removeAttribute("srcset");
|
|
1002
|
+
el.removeAttribute("sizes");
|
|
991
1003
|
}
|
|
992
1004
|
} else if (shouldReplace && hasAlreadyProxied) {
|
|
993
1005
|
if (src.startsWith(`${base}/p/`)) {
|
|
994
|
-
const
|
|
995
|
-
if (
|
|
996
|
-
el.setAttribute("srcset",
|
|
1006
|
+
const srcset2 = buildSrcSet(src);
|
|
1007
|
+
if (srcset2) {
|
|
1008
|
+
el.setAttribute("srcset", srcset2);
|
|
997
1009
|
el.setAttribute("sizes", IMAGE_SIZES);
|
|
998
1010
|
}
|
|
999
1011
|
}
|
|
1000
1012
|
}
|
|
1013
|
+
const srcset = shouldReplace ? el.getAttribute("srcset") : null;
|
|
1014
|
+
if (srcset && srcset.split(",").some((c) => !c.trim().startsWith(`${base}/`))) {
|
|
1015
|
+
el.removeAttribute("srcset");
|
|
1016
|
+
el.removeAttribute("sizes");
|
|
1017
|
+
}
|
|
1001
1018
|
}
|
|
1002
1019
|
function createImageHTML(src, isLCP, forApp = true) {
|
|
1003
1020
|
const decoded = decodeImageSrc(src);
|
|
@@ -1450,6 +1467,7 @@ function a(el, forApp, parentDomain = "ecency.com", seoContext, renderOptions) {
|
|
|
1450
1467
|
} else {
|
|
1451
1468
|
const thumbImg = el.ownerDocument.createElement("img");
|
|
1452
1469
|
thumbImg.setAttribute("class", "no-replace video-thumbnail");
|
|
1470
|
+
markInternalThumbnail(thumbImg);
|
|
1453
1471
|
thumbImg.setAttribute("itemprop", "thumbnailUrl");
|
|
1454
1472
|
thumbImg.setAttribute("src", thumbnail);
|
|
1455
1473
|
const play = el.ownerDocument.createElement("span");
|
|
@@ -1539,6 +1557,7 @@ function a(el, forApp, parentDomain = "ecency.com", seoContext, renderOptions) {
|
|
|
1539
1557
|
const thumbnail = proxifyImageSrc(src.replace(/\s+/g, ""), 0, 0, "match");
|
|
1540
1558
|
const thumbImg = el.ownerDocument.createElement("img");
|
|
1541
1559
|
thumbImg.setAttribute("class", "no-replace video-thumbnail");
|
|
1560
|
+
markInternalThumbnail(thumbImg);
|
|
1542
1561
|
thumbImg.setAttribute("itemprop", "thumbnailUrl");
|
|
1543
1562
|
thumbImg.setAttribute("src", thumbnail);
|
|
1544
1563
|
el.appendChild(thumbImg);
|
|
@@ -1599,6 +1618,7 @@ function a(el, forApp, parentDomain = "ecency.com", seoContext, renderOptions) {
|
|
|
1599
1618
|
const thumbnail = proxifyImageSrc(src.replace(/\s+/g, ""), 0, 0, "match");
|
|
1600
1619
|
const thumbImg = el.ownerDocument.createElement("img");
|
|
1601
1620
|
thumbImg.setAttribute("class", "no-replace video-thumbnail");
|
|
1621
|
+
markInternalThumbnail(thumbImg);
|
|
1602
1622
|
thumbImg.setAttribute("itemprop", "thumbnailUrl");
|
|
1603
1623
|
thumbImg.setAttribute("src", thumbnail);
|
|
1604
1624
|
el.appendChild(thumbImg);
|
|
@@ -2063,6 +2083,7 @@ function text(node, forApp, renderOptions) {
|
|
|
2063
2083
|
}
|
|
2064
2084
|
const thumbImg = node.ownerDocument.createElement("img");
|
|
2065
2085
|
thumbImg.setAttribute("class", "no-replace video-thumbnail");
|
|
2086
|
+
markInternalThumbnail(thumbImg);
|
|
2066
2087
|
thumbImg.setAttribute("src", thumbnail);
|
|
2067
2088
|
anchor.appendChild(thumbImg);
|
|
2068
2089
|
const play = node.ownerDocument.createElement("span");
|
|
@@ -2140,7 +2161,7 @@ function cleanReply(s) {
|
|
|
2140
2161
|
return (pre ? pre.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) => {
|
|
2141
2162
|
const l = item.toLowerCase();
|
|
2142
2163
|
return !(l.includes("posted from liketu speak") && l.includes("auto-transcrib"));
|
|
2143
|
-
}).filter((item) => item.toLowerCase().includes("originally posted through [scrobble.life") === false).filter((item) => item.toLowerCase().includes("*posted via lumen") === false).filter((item) => item.toLowerCase().includes("<sub>posted via [hivesuite](") === false).filter((item) => !/^[ \t]*▶\uFE0F?[ \t]*\[watch on 3speak\.tv\]\(https:\/\/3speak\.tv\/watch[^)\s]*\)\s*$/i.test(item)).filter((item) => item.toLowerCase().includes('view this post <a href="https://travelfeed.com/') === false).filter((item) => {
|
|
2164
|
+
}).filter((item) => item.toLowerCase().includes("originally posted through [scrobble.life") === false).filter((item) => item.toLowerCase().includes("*posted via lumen") === false).filter((item) => item.toLowerCase().includes("<sub>posted via [hivesuite](") === false).filter((item) => !/^\s*<sub>\[via hivesuite\]\(https:\/\/hivesuite\.app\/[^)\s]*\)<\/sub>\s*$/i.test(item)).filter((item) => !/^[ \t]*▶\uFE0F?[ \t]*\[watch on 3speak\.tv\]\(https:\/\/3speak\.tv\/watch[^)\s]*\)\s*$/i.test(item)).filter((item) => item.toLowerCase().includes('view this post <a href="https://travelfeed.com/') === false).filter((item) => {
|
|
2144
2165
|
const l = item.toLowerCase();
|
|
2145
2166
|
return !(l.includes("_posted from liketu clips") && l.includes("short video, trimmed"));
|
|
2146
2167
|
}).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>`, "");
|