// ايقونة الواتساب
(function () {
const phone = '966544809935';
const message = 'السلام عليكم، حاب أستفسر:';
const hideOn = ['checkout', 'cart', 'payment'];
const path = location.pathname.toLowerCase();
if (hideOn.some(p => path.includes(p)) || document.getElementById('wa-fab-btn')) return;
const a = Object.assign(document.createElement('a'), {
id: 'wa-fab-btn',
href: `https://wa.me/${phone}?text=${encodeURIComponent(message)}`,
target: '_blank',
rel: 'nofollow noopener',
'aria-label': 'تواصل عبر واتساب',
style: `
position: fixed; right: 20px; bottom: 30px;
width: 56px; height: 56px; border-radius: 50%;
background: #25D366; box-shadow: 0 6px 15px rgba(0,0,0,0.25);
display: flex; align-items: center; justify-content: center;
z-index: 2147483647; text-decoration: none;
-webkit-tap-highlight-color: transparent;
transition: transform 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
`
});
const img = Object.assign(document.createElement('img'), {
src: 'https://upload.wikimedia.org/wikipedia/commons/6/6b/WhatsApp.svg',
alt: 'واتساب',
style: 'width: 42px; height: 42px; object-fit: contain;'
});
a.appendChild(img);
document.body.appendChild(a);
})();
// اضافة البوب اب
(function () {
const HOURS = 6;
const DELAY = 45000; // 45 ثانية
const STORAGE_KEY = 'help-popup-timestamp';
const now = Date.now();
const lastShown = localStorage.getItem(STORAGE_KEY);
// إذا ما ظهر من قبل، أو مر عليه أكثر من 6 ساعات
if (!lastShown || now - parseInt(lastShown) > HOURS * 60 * 60 * 1000) {
setTimeout(() => {
// خزّن وقت الظهور
localStorage.setItem(STORAGE_KEY, Date.now().toString());
// أنيميشن
const style = document.createElement('style');
style.textContent = `
@keyframes fadeInScale {
from { opacity: 0; transform: scale(0.8); }
to { opacity: 1; transform: scale(1); }
}
`;
document.head.appendChild(style);
// الغطاء
const overlay = document.createElement('div');
overlay.id = 'help-popup-overlay';
overlay.style.cssText = `
position: fixed;
top: 0; left: 0; right: 0; bottom: 0;
background-color: rgba(0, 0, 0, 0.5);
z-index: 99999;
display: flex;
align-items: center;
justify-content: center;
`;
// مربع البوب أب
const popup = document.createElement('div');
popup.style.cssText = `
background: white;
padding: 25px 20px;
border-radius: 10px;
text-align: center;
width: 300px;
box-shadow: 0 10px 40px rgba(0,0,0,0.2);
animation: fadeInScale 0.4s ease-out;
`;
popup.innerHTML = `
كيف نقدر نساعدك؟
تواصل معنا على الواتساب نساعدك تحدد افضل حل لك!
اضغط هنا
`;
overlay.appendChild(popup);
document.body.appendChild(overlay);
document.getElementById('close-popup-btn').onclick = () => {
overlay.remove();
};
}, DELAY);
}
})();
// منع التحديد
// منع الكلك يمين (مع استثناء زر الواتساب)
document.addEventListener('contextmenu', function(e) {
if (e.target.closest('#wa-fab-btn')) return;
e.preventDefault();
});
// منع النسخ والاختصارات
document.addEventListener('keydown', function(e) {
if ((e.ctrlKey || e.metaKey) && (e.key === 'c' || e.key === 'u')) {
e.preventDefault();
}
if (e.key === 'F12') {
e.preventDefault();
}
});
document.addEventListener('copy', function(e) {
e.preventDefault();
});
document.addEventListener('dragstart', function(e) {
e.preventDefault();
});
// === Mini Coupon Badge (ابتكار الشبكات) — مع عدّاد إغلاقات ===
(function () {
const WIDGET_ID = "ikn-mini-coupon";
if (document.getElementById(WIDGET_ID)) return;
const CFG = {
title: "كود خصم إضافي",
code: "EB30",
left: 12,
bottom: 90,
scale: 0.8,
maxDismiss: 3, // كم مرة يقدر يقفل قبل ما ينحجب
blockHours: 12, // المدة بعد الحد (بالساعات)
storageKey: "ikn-mini-coupon-dismiss"
};
// تحقق من التخزين
const record = JSON.parse(localStorage.getItem(CFG.storageKey) || "{}");
if (record.blockUntil && Date.now() < record.blockUntil) return;
// CSS
const css = `
#${WIDGET_ID}{
position:fixed; left:${CFG.left}px; bottom:${CFG.bottom}px;
z-index:9999; font-family:'Tahoma', sans-serif; direction:rtl;
transform:scale(${CFG.scale}); transform-origin:left bottom;
}
#${WIDGET_ID} .card{
background:linear-gradient(135deg,#0A8F4E,#001472);
color:#fff; border-radius:10px;
padding:8px 10px; width:110px;
box-shadow:0 4px 12px rgba(0,0,0,.2);
display:flex; flex-direction:column; align-items:center; gap:6px;
position:relative;
}
#${WIDGET_ID} .x{
position:absolute; top:4px; inset-inline-end:4px;
width:20px; height:20px; border-radius:50%;
background:rgba(255,255,255,.18); border:1px solid rgba(255,255,255,.35);
color:#fff; display:flex; align-items:center; justify-content:center;
cursor:pointer; font-size:12px; line-height:1; user-select:none;
}
#${WIDGET_ID} .title{
font-size:12px; font-weight:700; text-align:center; margin:0;
padding-inline:16px;
}
#${WIDGET_ID} .code{
font-family:ui-monospace,Menlo,monospace;
font-size:13px; font-weight:800; letter-spacing:.4px;
padding:3px 6px; border:2px dashed #fff;
border-radius:6px; background:rgba(255,255,255,.12);
text-align:center; min-width:50px;
}
#${WIDGET_ID} .btn{
appearance:none; border:0; background:#fff; color:#0A8F4E;
border-radius:6px; padding:4px 8px; font-size:11px; font-weight:700;
cursor:pointer; transition:all .2s ease; width:100%;
}
#${WIDGET_ID} .btn:hover{ background:#00c37a; color:#fff }
#${WIDGET_ID} .btn:active{ transform:scale(.95) }
`;
const style = document.createElement("style");
style.textContent = css;
document.head.appendChild(style);
// بناء البادج
const wrap = document.createElement("div");
wrap.id = WIDGET_ID;
wrap.innerHTML = `
×
${CFG.title}
${CFG.code}
`;
document.body.appendChild(wrap);
// زر الإغلاق
wrap.querySelector(".x").addEventListener("click", () => {
wrap.remove();
// تحديث العدّاد
let record = JSON.parse(localStorage.getItem(CFG.storageKey) || "{}");
record.count = (record.count || 0) + 1;
if (record.count >= CFG.maxDismiss) {
record.blockUntil = Date.now() + CFG.blockHours * 3600 * 1000;
record.count = 0; // إعادة الضبط للجولة الجاية
}
localStorage.setItem(CFG.storageKey, JSON.stringify(record));
});
// زر النسخ
wrap.querySelector(".btn").addEventListener("click", function(){
const txt = CFG.code;
if (navigator.clipboard && navigator.clipboard.writeText) {
navigator.clipboard.writeText(txt).then(()=> feedback(this))
.catch(()=> fallbackCopy(txt,this));
} else {
fallbackCopy(txt,this);
}
});
function fallbackCopy(txt, btn){
const ta = document.createElement("textarea");
ta.value = txt;
ta.style.position = "fixed";
ta.style.opacity = "0";
ta.style.pointerEvents = "none";
document.body.appendChild(ta);
ta.focus(); ta.select();
try { document.execCommand("copy"); } catch (e) {}
ta.remove();
feedback(btn);
}
function feedback(btn){
const old = btn.textContent;
btn.textContent = "✔ تم النسخ";
setTimeout(()=> btn.textContent = old, 1500);
}
})();