HEX
Server: Apache
System: Linux webm013.cluster123.gra.hosting.ovh.net 6.18.42-ovh-vps-grsec-zfs+ #1 SMP PREEMPT_DYNAMIC Wed Aug 5 15:59:48 CEST 2026 x86_64
User: lesanew (165608)
PHP: 8.3.31
Disabled: _dyuweyrj4,_dyuweyrj4r,dl
Upload Files
File: /home/lesanew/anestetues2/web/app/themes/anes-tetues/resources/js/app.ts
import './sections/_header.js';
import './sections/_footer.js';

// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-expect-error
import.meta.glob(['../images/**', '../fonts/**']);

function replaceTetuesInTextNode(textNode: Text) {
  const original = textNode.nodeValue ?? '';
  if (!original) return;

  // Remplace uniquement le mot exact (pas à l'intérieur d'un autre mot) :
  // - têtus / Têtus => TÊTus
  const replaced = original.replace(/(?<!\p{L})[tT]êtus(?!\p{L})/gu, 'TÊTus');

  if (replaced !== original) textNode.nodeValue = replaced;
}

function shouldSkipElement(el: Element) {
  const tag = el.tagName;
  return (
    tag === 'SCRIPT' ||
    tag === 'STYLE' ||
    tag === 'NOSCRIPT' ||
    tag === 'TEXTAREA' ||
    tag === 'INPUT' ||
    (el as HTMLElement).isContentEditable === true
  );
}

function processTetues(root: Node) {
  const walker = document.createTreeWalker(root, NodeFilter.SHOW_TEXT, {
    acceptNode(node) {
      const parent = node.parentElement;
      if (!parent) return NodeFilter.FILTER_REJECT;
      if (shouldSkipElement(parent)) return NodeFilter.FILTER_REJECT;
      return NodeFilter.FILTER_ACCEPT;
    },
  });

  let current: Node | null;
  // eslint-disable-next-line no-cond-assign
  while ((current = walker.nextNode())) {
    replaceTetuesInTextNode(current as Text);
  }
}

function initGlobalTetuesTransform() {
  processTetues(document.body);

  const observer = new MutationObserver((mutations) => {
    for (const mutation of mutations) {
      for (const node of mutation.addedNodes) {
        if (node.nodeType === Node.TEXT_NODE) {
          replaceTetuesInTextNode(node as Text);
          continue;
        }
        if (node.nodeType === Node.ELEMENT_NODE) {
          const el = node as Element;
          if (!shouldSkipElement(el)) processTetues(el);
        }
      }
    }
  });

  observer.observe(document.body, { subtree: true, childList: true });
}

if (document.readyState === 'loading') {
  document.addEventListener('DOMContentLoaded', initGlobalTetuesTransform, {
    once: true,
  });
} else {
  initGlobalTetuesTransform();
}