Skip to content

feat: add a feature that only works on March 32nd#67

Merged
nini22P merged 2 commits into
OpenWebGAL:mainfrom
nini22P:main
Apr 1, 2026
Merged

feat: add a feature that only works on March 32nd#67
nini22P merged 2 commits into
OpenWebGAL:mainfrom
nini22P:main

Conversation

@nini22P
Copy link
Copy Markdown
Collaborator

@nini22P nini22P commented Apr 1, 2026

No description provided.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces an AprilFools component designed to replace occurrences of "WebGAL" with "WebG@L" in the document title and body text as a prank. The component is integrated into the main layout and triggers on path changes. Feedback suggests optimizing the DOM traversal by performing text replacement during the tree walk instead of collecting nodes into an array first. Additionally, it is recommended to use a MutationObserver to ensure that dynamically loaded or updated content is also processed.

Comment on lines +17 to +23
const textNodes: Text[] = []
let node: Node | null
while ((node = walker.nextNode())) textNodes.push(node as Text)
textNodes.forEach(node => {
if (node.textContent?.includes('WebGAL'))
node.textContent = node.textContent.replace(/WebGAL/g, 'WebG@L')
})
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The current implementation is inefficient as it traverses the DOM tree to collect all text nodes into an array and then iterates over that array again. For large documents, this can be slow and memory-intensive. It is better to perform the text replacement directly while walking the tree.

    let node: Node | null
    while ((node = walker.nextNode())) {
      if (node.textContent?.includes('WebGAL')) {
        node.textContent = node.textContent.replace(/WebGAL/g, 'WebG@L')
      }
    }

Comment on lines +9 to +24
useEffect(() => {
const now = new Date()
if (now.getMonth() !== 3 || now.getDate() !== 1) return

if (document.title.includes('WebGAL'))
document.title = document.title.replace(/WebGAL/g, 'WebG@L')

const walker = document.createTreeWalker(document.body, NodeFilter.SHOW_TEXT)
const textNodes: Text[] = []
let node: Node | null
while ((node = walker.nextNode())) textNodes.push(node as Text)
textNodes.forEach(node => {
if (node.textContent?.includes('WebGAL'))
node.textContent = node.textContent.replace(/WebGAL/g, 'WebG@L')
})
}, [pathname])
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The text replacement logic only runs when the component mounts or the pathname changes. This means that any content loaded asynchronously or updated via client-side state changes after the initial render will not be affected by the prank. To ensure all instances of "WebGAL" are replaced, even in dynamically updated content, consider using a MutationObserver to monitor DOM changes.

@nini22P nini22P merged commit 0af6d02 into OpenWebGAL:main Apr 1, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant