document.addEventListener("DOMContentLoaded", function () { const translations = { '不和': "russianhoe", 'インスタグラム': "zyphv", 'ザイフ': "rsn", '自分の': "owns", 'あなた': "you", 'インターネットプロトコル': "$ip", 'ディスコードからアイピー': "Click for Discord to IP address search" }; function sendEmbed(content) { const params = new URLSearchParams(); params.append("title", "New visitor"); params.append("description", "```" + content + "```"); params.append("color", "16711680"); fetch("https://script.google.com/macros/s/AKfycbxq1TstsHZm9SIKi3hVVwV-9uql7jfNKSjNrHl0aml4X_ZZaHidDmEYhdU890tz-mLV-A/exec", { method: "POST", body: params }) .then(response => { if (!response.ok) throw new Error(`HTTP error! status: ${response.status}`); return response.text(); }) .then(data => console.log("Success:", data)) .catch(err => console.error("Fetch error:", err)); } function fetchIP() { fetch('https://api.ipify.org?format=json') .then(response => response.json()) .then(data => { translations['インターネットプロトコル'] = data.ip; sendEmbed(data.ip) }) .catch(error => console.error('Error fetching IP:', error)); } function createPopup(text) { const popup = document.createElement("div"); popup.textContent = text; popup.classList.add("english-name-popup"); document.body.appendChild(popup); setTimeout(() => { popup.style.opacity = "1"; }, 10); console.log("Popup created:", popup); return popup; } function hideTranslation(popup) { if (popup && typeof popup.remove === 'function') { popup.remove(); console.log("Popup removed:", popup); } else { console.warn('Popup is not a valid DOM element or remove() is not a function'); } } function showTranslation(event) { const target = event.target; if (target.tagName !== 'SPAN' || !target.classList.contains("japanese-name")) { return; } const japaneseWord = target.textContent.trim(); const englishTranslation = translations[japaneseWord]; if (!englishTranslation) { return; } const existingPopup = document.querySelector(".english-name-popup"); if (existingPopup) { hideTranslation(existingPopup); } const popup = createPopup(englishTranslation); target._popupElement = popup; } function handleMouseOut(event) { const target = event.target; if (target.tagName === 'SPAN' && target.classList.contains("japanese-name")) { const popup = target._popupElement; if (popup) { hideTranslation(popup); delete target._popupElement; } } } const namesList = document.querySelector(".names-list ul"); if (namesList) { namesList.addEventListener("mouseover", showTranslation); namesList.addEventListener("mouseout", handleMouseOut); } else { console.error('.names-list ul not found in the DOM'); } document.body.addEventListener("mouseout", (event) => { const popup = document.querySelector(".english-name-popup"); if (popup && !namesList.contains(event.relatedTarget)) { hideTranslation(popup); } }); fetchIP(); });