@ecency/render-helper 2.5.41 → 2.5.43

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.
@@ -871,6 +871,15 @@ function sanitizeHtml(html, options) {
871
871
  return preserveImageDimensions ? enforceImageDimensionPair(withoutBareSource) : withoutBareSource;
872
872
  }
873
873
 
874
+ // src/methods/internal-thumbnail.ts
875
+ var internalThumbnails = /* @__PURE__ */ new WeakSet();
876
+ function markInternalThumbnail(el) {
877
+ internalThumbnails.add(el);
878
+ }
879
+ function isInternalThumbnail(el) {
880
+ return internalThumbnails.has(el);
881
+ }
882
+
874
883
  // src/methods/img.method.ts
875
884
  var IMAGE_SIZES = "(max-width: 768px) 100vw, 700px";
876
885
  function wrapInPicture(el, rawUrl) {
@@ -945,32 +954,40 @@ function img(el, state, forApp = true, renderOptions) {
945
954
  if (isAvatar || imageIndex !== 0) {
946
955
  el.removeAttribute("fetchpriority");
947
956
  }
948
- const cls = el.getAttribute("class") || "";
949
- const shouldReplace = !cls.includes("no-replace");
957
+ const shouldReplace = !isInternalThumbnail(el);
950
958
  const base = trimTrailingSlash(getProxyBase());
951
959
  const hasAlreadyProxied = src.startsWith(`${base}/p/`) || src.startsWith(`${base}/u/`) || new RegExp(`^${base.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}/\\d+x\\d+/`).test(src);
952
960
  if (shouldReplace && !hasAlreadyProxied) {
953
961
  const proxified = proxifyImageSrc(decodedSrc, 0, 0, "match", { forceProxy: true });
954
962
  if (proxified) {
955
963
  el.setAttribute("src", proxified);
956
- const srcset = buildSrcSet(decodedSrc);
957
- if (srcset) {
958
- el.setAttribute("srcset", srcset);
964
+ const srcset2 = buildSrcSet(decodedSrc);
965
+ if (srcset2) {
966
+ el.setAttribute("srcset", srcset2);
959
967
  el.setAttribute("sizes", IMAGE_SIZES);
960
968
  }
961
969
  if (!forApp) {
962
970
  wrapInPicture(el, decodedSrc);
963
971
  }
972
+ } else if (/^https?:\/\//i.test(decodedSrc)) {
973
+ el.removeAttribute("src");
974
+ el.removeAttribute("srcset");
975
+ el.removeAttribute("sizes");
964
976
  }
965
977
  } else if (shouldReplace && hasAlreadyProxied) {
966
978
  if (src.startsWith(`${base}/p/`)) {
967
- const srcset = buildSrcSet(src);
968
- if (srcset) {
969
- el.setAttribute("srcset", srcset);
979
+ const srcset2 = buildSrcSet(src);
980
+ if (srcset2) {
981
+ el.setAttribute("srcset", srcset2);
970
982
  el.setAttribute("sizes", IMAGE_SIZES);
971
983
  }
972
984
  }
973
985
  }
986
+ const srcset = shouldReplace ? el.getAttribute("srcset") : null;
987
+ if (srcset && srcset.split(",").some((c) => !c.trim().startsWith(`${base}/`))) {
988
+ el.removeAttribute("srcset");
989
+ el.removeAttribute("sizes");
990
+ }
974
991
  }
975
992
  function createImageHTML(src, isLCP, forApp = true) {
976
993
  const decoded = decodeImageSrc(src);
@@ -1423,6 +1440,7 @@ function a(el, forApp, parentDomain = "ecency.com", seoContext, renderOptions) {
1423
1440
  } else {
1424
1441
  const thumbImg = el.ownerDocument.createElement("img");
1425
1442
  thumbImg.setAttribute("class", "no-replace video-thumbnail");
1443
+ markInternalThumbnail(thumbImg);
1426
1444
  thumbImg.setAttribute("itemprop", "thumbnailUrl");
1427
1445
  thumbImg.setAttribute("src", thumbnail);
1428
1446
  const play = el.ownerDocument.createElement("span");
@@ -1512,6 +1530,7 @@ function a(el, forApp, parentDomain = "ecency.com", seoContext, renderOptions) {
1512
1530
  const thumbnail = proxifyImageSrc(src.replace(/\s+/g, ""), 0, 0, "match");
1513
1531
  const thumbImg = el.ownerDocument.createElement("img");
1514
1532
  thumbImg.setAttribute("class", "no-replace video-thumbnail");
1533
+ markInternalThumbnail(thumbImg);
1515
1534
  thumbImg.setAttribute("itemprop", "thumbnailUrl");
1516
1535
  thumbImg.setAttribute("src", thumbnail);
1517
1536
  el.appendChild(thumbImg);
@@ -1572,6 +1591,7 @@ function a(el, forApp, parentDomain = "ecency.com", seoContext, renderOptions) {
1572
1591
  const thumbnail = proxifyImageSrc(src.replace(/\s+/g, ""), 0, 0, "match");
1573
1592
  const thumbImg = el.ownerDocument.createElement("img");
1574
1593
  thumbImg.setAttribute("class", "no-replace video-thumbnail");
1594
+ markInternalThumbnail(thumbImg);
1575
1595
  thumbImg.setAttribute("itemprop", "thumbnailUrl");
1576
1596
  thumbImg.setAttribute("src", thumbnail);
1577
1597
  el.appendChild(thumbImg);
@@ -2036,6 +2056,7 @@ function text(node, forApp, renderOptions) {
2036
2056
  }
2037
2057
  const thumbImg = node.ownerDocument.createElement("img");
2038
2058
  thumbImg.setAttribute("class", "no-replace video-thumbnail");
2059
+ markInternalThumbnail(thumbImg);
2039
2060
  thumbImg.setAttribute("src", thumbnail);
2040
2061
  anchor.appendChild(thumbImg);
2041
2062
  const play = node.ownerDocument.createElement("span");
@@ -2107,13 +2128,16 @@ function traverse(node, forApp, depth = 0, state = { firstImageFound: false }, p
2107
2128
  // src/methods/clean-reply.method.ts
2108
2129
  function cleanReply(s) {
2109
2130
  const pre = s ? s.replace(
2110
- /(^|\n)-{3,}[ \t]*\n+(?=[^\n]*(?:originally posted through \[scrobble\.life|\*posted via lumen))/i,
2131
+ /(^|\n)-{3,}[ \t]*\n+(?=[^\n]*(?:originally posted through \[scrobble\.life|\*posted via lumen)|[ \t]*▶\uFE0F?[ \t]*\[watch on 3speak\.tv\]\(https:\/\/3speak\.tv\/watch[^)\s]*\)[^\S\n]*(?:\n|$))/i,
2111
2132
  "$1"
2112
2133
  ) : s;
2113
2134
  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) => {
2114
2135
  const l = item.toLowerCase();
2115
2136
  return !(l.includes("posted from liketu speak") && l.includes("auto-transcrib"));
2116
- }).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("[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">![](https://i.imgur.com/XsrNmcl.png)</a></div>', "").replace('<div><a href="https://engage.hivechain.app">![](https://i.imgur.com/XsrNmcl.png)</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>`, "");
2137
+ }).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) => {
2138
+ const l = item.toLowerCase();
2139
+ return !(l.includes("_posted from liketu clips") && l.includes("short video, trimmed"));
2140
+ }).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">![](https://i.imgur.com/XsrNmcl.png)</a></div>', "").replace('<div><a href="https://engage.hivechain.app">![](https://i.imgur.com/XsrNmcl.png)</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>`, "");
2117
2141
  }
2118
2142
 
2119
2143
  // ../../node_modules/.pnpm/remarkable@2.0.1/node_modules/remarkable/dist/esm/index.js