61 lines
2.0 KiB
JavaScript
61 lines
2.0 KiB
JavaScript
/**
|
|
* WEVAL UI GUARDIAN v2.0 — Anti-regression for chatbot position + footer links
|
|
* Loaded LAST on every page.
|
|
*/
|
|
(function(){
|
|
"use strict";
|
|
if(window.__wevalGuardianDone) return;
|
|
window.__wevalGuardianDone = true;
|
|
|
|
function fixBubbles() {
|
|
// Chatbot toggle = bottom-right ONLY widget
|
|
var chatBtn = document.querySelector(".chat-toggle-btn");
|
|
if(chatBtn) {
|
|
chatBtn.style.cssText += ";position:fixed !important;bottom:20px !important;right:20px !important;left:auto !important;z-index:9999 !important;";
|
|
}
|
|
// Chat widget panel = bottom-right
|
|
var chatWidget = document.querySelector(".chat-widget");
|
|
if(chatWidget) {
|
|
chatWidget.style.cssText += ";right:20px !important;left:auto !important;";
|
|
}
|
|
// KILL any Booking WEVAL floating button that might exist (from cache)
|
|
var calBtn = document.querySelector(".wr-booking-float");
|
|
if(calBtn) calBtn.remove();
|
|
}
|
|
|
|
function fixFooter() {
|
|
document.querySelectorAll(".wv-footer-services a, .wv-fs-col a").forEach(function(a) {
|
|
var href = a.getAttribute("href");
|
|
if(!href) return;
|
|
if(href === "/blog" || href.startsWith("/blog/")) {
|
|
a.setAttribute("href", "/actualites");
|
|
}
|
|
// Force React SPA navigation
|
|
if(!a.__guardFixed && href.startsWith("/")) {
|
|
a.__guardFixed = true;
|
|
a.addEventListener("click", function(e) {
|
|
e.preventDefault();
|
|
var h = this.getAttribute("href");
|
|
window.location.href = h;
|
|
window.scrollTo(0, 0);
|
|
});
|
|
}
|
|
});
|
|
}
|
|
|
|
function guard() { fixBubbles(); fixFooter(); }
|
|
|
|
if(document.readyState === "complete") guard();
|
|
else window.addEventListener("load", guard);
|
|
|
|
var count = 0;
|
|
var interval = setInterval(function() { guard(); count++; if(count >= 10) clearInterval(interval); }, 3000);
|
|
|
|
if(window.MutationObserver) {
|
|
var obs = new MutationObserver(function() { guard(); });
|
|
obs.observe(document.body || document.documentElement, { childList: true, subtree: true });
|
|
setTimeout(function() { obs.disconnect(); }, 60000);
|
|
}
|
|
console.log("[WEVAL-GUARDIAN] v2.0 — chatbot right, no booking, footer SPA nav");
|
|
})();
|