Ameeba Security Research

Defensive CVE and exploit intelligence

Ameeba Blog Search
<script> document.addEventListener(“DOMContentLoaded”, () => { const searchBar = document.getElementById(“search-bar”); const searchAPI = “https://www.ameeba.com/wp-json/wp/v2/posts?search=”; let debounceTimeout = null; // Debounce to prevent excessive API calls searchBar.addEventListener(“input”, () => { clearTimeout(debounceTimeout); debounceTimeout = setTimeout(() => { const query = searchBar.value.trim(); if (query.length > 0) { fetchPosts(query); } else { removeSuggestions(); } }, 300); }); // Fetch posts using WordPress REST API async function fetchPosts(query) { try { const response = await fetch(`${searchAPI}${encodeURIComponent(query)}`); if (!response.ok) throw new Error(“Failed to fetch posts”); const posts = await response.json(); showSuggestions(posts); } catch (error) { console.error(“Error fetching posts:”, error); } } // Display dropdown suggestions function showSuggestions(posts) { removeSuggestions(); const suggestions = document.createElement(“ul”); suggestions.id = “suggestions”; if (posts.length > 0) { posts.forEach((post) => { const listItem = document.createElement(“li”); listItem.textContent = post.title.rendered; listItem.addEventListener(“click”, () => { searchBar.value = post.title.rendered; window.location.href = post.link; // Redirect to the post }); suggestions.appendChild(listItem); }); } else { const noMatch = document.createElement(“li”); noMatch.textContent = “No search result matches”; noMatch.classList.add(“no-match”); suggestions.appendChild(noMatch); } searchBar.parentNode.appendChild(suggestions); } // Remove dropdown suggestions function removeSuggestions() { const existingSuggestions = document.getElementById(“suggestions”); if (existingSuggestions) { existingSuggestions.remove(); } } // Handle Enter key to perform an explicit search searchBar.addEventListener(“keydown”, (event) => { if (event.key === “Enter”) { event.preventDefault(); const query = searchBar.value.trim(); if (query.length > 0) { window.location.href = `https://www.ameeba.com/blog/?s=${encodeURIComponent(query)}`; } } }); // Hide suggestions when the search bar loses focus searchBar.addEventListener(“blur”, () => { setTimeout(() => { removeSuggestions(); }, 200); }); }); </script>
TRENDING · 1 WEEK
Attack Vector
Vendor
Severity