easter-egg-quest 1.0.26 → 1.0.28

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.
@@ -1094,14 +1094,19 @@ class HiddenEntry {
1094
1094
  }
1095
1095
  _findReplacementTextTarget(host) {
1096
1096
  const triggerLength = "start hunt".length;
1097
+ const minReplaceLength = 5;
1097
1098
  const textTargets = [];
1098
1099
  const walker = document.createTreeWalker(host, NodeFilter.SHOW_TEXT, {
1099
1100
  acceptNode: (node) => {
1100
1101
  const parent = node.parentElement;
1101
- const text = this._normalizeComparableText(node.textContent ?? "");
1102
+ const rawText = node.textContent ?? "";
1103
+ const text = this._normalizeComparableText(rawText);
1102
1104
  if (!parent || text.length === 0) return NodeFilter.FILTER_REJECT;
1103
1105
  if (parent.closest("[data-eeq], script, style, noscript")) return NodeFilter.FILTER_REJECT;
1106
+ if (this._isIconLikeTarget(parent)) return NodeFilter.FILTER_REJECT;
1104
1107
  if (!isElementVisible(parent)) return NodeFilter.FILTER_REJECT;
1108
+ if (text.length < minReplaceLength) return NodeFilter.FILTER_REJECT;
1109
+ if (!this._hasAllowedTextSeparators(rawText)) return NodeFilter.FILTER_REJECT;
1105
1110
  if (Math.abs(text.length - triggerLength) > 10) return NodeFilter.FILTER_REJECT;
1106
1111
  return NodeFilter.FILTER_ACCEPT;
1107
1112
  }
@@ -1131,6 +1136,21 @@ class HiddenEntry {
1131
1136
  _normalizeComparableText(text) {
1132
1137
  return text.replace(/\s+/g, " ").trim();
1133
1138
  }
1139
+ _hasAllowedTextSeparators(text) {
1140
+ const normalized = this._normalizeComparableText(text);
1141
+ return normalized.includes(" ") || normalized.includes(".");
1142
+ }
1143
+ _isIconLikeTarget(parent) {
1144
+ const tag = parent.tagName.toLowerCase();
1145
+ const className = parent.className.toString().toLowerCase();
1146
+ const role = (parent.getAttribute("role") ?? "").toLowerCase();
1147
+ const ariaHidden = parent.getAttribute("aria-hidden");
1148
+ if (tag === "mat-icon" || tag === "svg" || tag === "i") return true;
1149
+ if (className.includes("icon") || className.includes("mat-icon")) return true;
1150
+ if (role === "img" || ariaHidden === "true") return true;
1151
+ if (parent.querySelector("svg, mat-icon")) return true;
1152
+ return false;
1153
+ }
1134
1154
  _restoreReplacedText() {
1135
1155
  if (this._replacedTextNode) {
1136
1156
  this._replacedTextNode.textContent = this._replacedTextContent;