nicht gefunden. Fallback auf div[role='heading'].");
}
let leftOffset = 60;
let topOffset = 15;
if (targetDiv) {
const rect = targetDiv.getBoundingClientRect();
leftOffset = rect.right + 10;
topOffset = rect.top + (rect.height / 2) - 18;
console.log("🛠️ DEBUG: Ziel-
gefunden. Position:", { left: leftOffset, top: topOffset });
} else {
console.warn("⚠️ Kein Ziel-
gefunden. Fallback-Position.");
}
buttonContainer.style.position = "fixed";
buttonContainer.style.top = `${topOffset}px`;
buttonContainer.style.left = `${leftOffset}px`;
buttonContainer.style.zIndex = "10000";
buttonContainer.style.display = "flex";
buttonContainer.style.alignItems = "center";
buttonContainer.style.visibility = "visible";
const buttonsConfig = [
{
icon: "🔍",
title: "Start manual search",
onClick: () => {
console.log("🔍 Manuelle Suche gestartet.");
if (!isScriptActivated) {
isScriptActivated = true;
console.log("🛠️ DEBUG: Skript durch Lupen-Klick aktiviert.");
observeForNewPosts();
}
startRefinedSearchForLastReadPost();
},
},
{
icon: "📂",
title: "Load last read position from file",
onClick: () => {
console.log("📂 Lade Leseposition aus Datei...");
loadLastReadPostFromFile();
},
},
{
icon: isDownloadEnabled ? "💾" : "⛔",
title: isDownloadEnabled ? "Download der Leseposition aktiviert (Klicken zum Deaktivieren)" : "Download der Leseposition deaktiviert (Klicken zum Aktivieren)",
onClick: () => {
toggleDownloadStatus();
},
isDownloadButton: true,
},
];
buttonsConfig.forEach(({ icon, title, onClick, isDownloadButton }) => {
const button = createButton(icon, title, onClick);
if (isDownloadButton) {
downloadButton = button;
button.style.backgroundColor = isDownloadEnabled ? "rgba(0, 128, 0, 0.9)" : "rgba(255, 0, 0, 0.9)";
}
buttonContainer.appendChild(button);
});
document.body.appendChild(buttonContainer);
console.log("🛠️ DEBUG: Button-Container erstellt:", buttonContainer);
} catch (err) {
console.error("❌ Fehler beim Erstellen der Buttons:", err);
showPopup("❌ Fehler beim Anzeigen der Buttons.");
}
}, 10000);
}
function createButton(icon, title, onClick) {
const button = document.createElement("div");
button.style.width = "36px";
button.style.height = "36px";
button.style.backgroundColor = "rgba(0, 0, 0, 0.9)";
button.style.color = "#ffffff";
button.style.borderRadius = "50%";
button.style.display = "flex";
button.style.justifyContent = "center";
button.style.alignItems = "center";
button.style.cursor = "pointer";
button.style.fontSize = "18px";
button.style.boxShadow = "0 0 10px rgba(255, 255, 255, 0.5)";
button.style.transition = "transform 0.2s, box-shadow 0.3s";
button.style.zIndex = "10001";
button.style.visibility = "visible";
button.style.marginRight = "8px"; // Abstand zwischen Buttons
button.textContent = icon;
button.title = title;
button.addEventListener("click", () => {
button.style.boxShadow = "0 0 20px rgba(255, 255, 255, 0.8)";
button.style.transform = "scale(0.9)";
setTimeout(() => {
button.style.boxShadow = "0 0 10px rgba(255, 255, 255, 0.5)";
button.style.transform = "scale(1)";
}, 300);
onClick();
});
button.addEventListener("mouseenter", () => {
button.style.boxShadow = "0 0 15px rgba(255, 255, 255, 0.7)";
button.style.transform = "scale(1.1)";
});
button.addEventListener("mouseleave", () => {
button.style.boxShadow = "0 0 10px rgba(255, 255, 255, 0.5)";
button.style.transform = "scale(1)";
});
return button;
}
function showPopup(message, duration = 3000) {
const popup = document.createElement("div");
popup.style.position = "fixed";
popup.style.bottom = "20px";
popup.style.right = "20px";
popup.style.backgroundColor = "rgba(0, 0, 0, 0.9)";
popup.style.color = "#ffffff";
popup.style.padding = "10px 20px";
popup.style.borderRadius = "8px";
popup.style.fontSize = "14px";
popup.style.boxShadow = "0 0 10px rgba(255, 255, 255, 0.8)";
popup.style.zIndex = "10000";
popup.style.maxWidth = "400px";
popup.style.whiteSpace = "pre-wrap";
popup.textContent = message;
document.body.appendChild(popup);
setTimeout(() => {
popup.remove();
}, duration);
}
})();