/* ========================================
Custom JavaScript Styles
======================================== */
// ============================================
// 1. Video Banner Section
// ============================================
const headerSec = document.querySelector(".index main#main-content");
if (headerSec) {
const newSection = document.createElement("section");
newSection.setAttribute("class", "video-banner");
newSection.innerHTML = `
`;
headerSec.prepend(newSection);
}
// ============================================
// 2. WhatsApp Floating Button
// ============================================
const WHATSAPP_NUMBER = '966544486458';
function createWhatsAppButton() {
const whatsappBtn = document.createElement('a');
whatsappBtn.href = `https://api.whatsapp.com/send/?phone=${WHATSAPP_NUMBER}&text&type=phone_number&app_absent=0`;
whatsappBtn.target = '_blank';
whatsappBtn.rel = 'noopener noreferrer';
whatsappBtn.className = 'whatsapp-float';
whatsappBtn.setAttribute('aria-label', 'تواصل عبر واتساب');
whatsappBtn.innerHTML = `
`;
const style = document.createElement('style');
style.textContent = `
.whatsapp-float {
position: fixed;
width: 60px;
height: 60px;
bottom: 30px;
right: 30px;
background-color: #25d366;
color: #fff;
border-radius: 50%;
text-align: center;
font-size: 30px;
box-shadow: 2px 2px 15px rgba(0, 0, 0, 0.3);
z-index: 9999;
display: flex;
align-items: center;
justify-content: center;
transition: all 0.3s ease;
text-decoration: none;
animation: pulse 2s infinite;
}
.whatsapp-float:hover {
background-color: #128c7e;
transform: scale(1.1);
box-shadow: 2px 2px 20px rgba(0, 0, 0, 0.4);
}
.whatsapp-float svg {
width: 38px;
height: 38px;
filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.2));
}
@keyframes pulse {
0% {
box-shadow: 0 0 0 0 rgba(37, 211, 102, 0.7);
}
50% {
box-shadow: 0 0 0 15px rgba(37, 211, 102, 0);
}
100% {
box-shadow: 0 0 0 0 rgba(37, 211, 102, 0);
}
}
@media screen and (max-width: 768px) {
.whatsapp-float {
width: 50px;
height: 50px;
bottom: 7rem;
right: 20px;
}
.whatsapp-float svg {
width: 32px;
height: 32px;
}
}
`;
document.head.appendChild(style);
document.body.appendChild(whatsappBtn);
}
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', createWhatsAppButton);
} else {
createWhatsAppButton();
}
// ============================================
// 3. Product Features Icons
// ============================================
(function() {
'use strict';
function addFeatureIcons() {
const targetElement = document.querySelector('.product-single div.main-content.md\\:sticky.md\\:overflow-hidden.top-24.w-full.md\\:w-2\\/4.md\\:pb-16 > div.product__description.p-2.px-5.sm\\:p-1.leading-7.mb-3');
if (!targetElement || document.querySelector('.armor-features')) {
return;
}
const featuresDiv = document.createElement('div');
featuresDiv.className = 'armor-features';
featuresDiv.innerHTML = `
+1,200 سيارة محمية بـ Armor
مختار من مراكز حماية معتمدة
95% من العملاء يعيدوا الشراء أو يرشحوه
`;
const separator = document.createElement('hr');
separator.className = 'armor-separator';
const style = document.createElement('style');
style.textContent = `
.armor-separator {
border: none;
border-top: 2px solid #2d2d2d;
margin: 1.5rem 0;
width: 100%;
}
.armor-features {
display: flex;
flex-direction: column;
gap: 1rem;
margin-top: 1.5rem;
padding: 1.25rem;
background: linear-gradient(135deg, #1a1a1a 0%, #2d2d2d 100%);
border-radius: 12px;
border: 2px solid #404040;
}
.armor-feature-item {
display: flex;
align-items: center;
gap: 0.75rem;
padding: 0.5rem;
transition: transform 0.2s ease;
}
.armor-feature-item:hover {
transform: translateX(-5px);
}
.armor-feature-item:hover .armor-icon {
transform: scale(1.1);
box-shadow: 0 6px 16px rgba(128, 128, 128, 0.4);
}
.armor-icon {
font-size: 1.5rem;
flex-shrink: 0;
display: inline-flex;
align-items: center;
justify-content: center;
width: 45px;
height: 45px;
border-radius: 50%;
background: linear-gradient(135deg, #3a3a3a 0%, #2a2a2a 100%);
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
border: 2px solid #505050;
transition: all 0.3s ease;
}
.armor-icon svg {
width: 24px;
height: 24px;
color: #ffffff;
}
.armor-text {
font-size: 0.95rem;
color: #e0e0e0;
font-weight: 500;
line-height: 1.5;
}
.armor-feature-item:nth-child(1) .armor-icon {
background: linear-gradient(135deg, #505050 0%, #606060 100%);
border-color: #707070;
}
.armor-feature-item:nth-child(1) .armor-icon svg {
color: #ffffff;
}
.armor-feature-item:nth-child(2) .armor-icon {
background: linear-gradient(135deg, #3a3a3a 0%, #4a4a4a 100%);
border-color: #606060;
}
.armor-feature-item:nth-child(2) .armor-icon svg {
color: #d0d0d0;
}
.armor-feature-item:nth-child(3) .armor-icon {
background: linear-gradient(135deg, #2a2a2a 0%, #3a3a3a 100%);
border-color: #505050;
}
.armor-feature-item:nth-child(3) .armor-icon svg {
color: #c0c0c0;
}
@keyframes iconPulse {
0%, 100% { transform: scale(1); }
50% { transform: scale(1.05); }
}
.armor-icon {
animation: iconPulse 3s ease-in-out infinite;
}
.armor-feature-item:nth-child(1) .armor-icon {
animation-delay: 0s;
}
.armor-feature-item:nth-child(2) .armor-icon {
animation-delay: 0.5s;
}
.armor-feature-item:nth-child(3) .armor-icon {
animation-delay: 1s;
}
@media screen and (max-width: 640px) {
.armor-features {
padding: 1rem;
gap: 0.75rem;
}
.armor-icon {
width: 40px;
height: 40px;
}
.armor-icon svg {
width: 20px;
height: 20px;
}
.armor-text {
font-size: 0.875rem;
}
}
`;
if (!document.querySelector('#armor-features-style')) {
style.id = 'armor-features-style';
document.head.appendChild(style);
}
targetElement.after(separator);
separator.after(featuresDiv);
console.log('✅ تم إضافة أيقونات المميزات بنجاح');
}
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', addFeatureIcons);
} else {
addFeatureIcons();
}
const observer = new MutationObserver(function() {
if (!document.querySelector('.armor-features')) {
addFeatureIcons();
}
});
observer.observe(document.body, {
childList: true,
subtree: true
});
})();
// ============================================
// 4. Countdown Timer (25% Discount)
// ============================================
(function() {
'use strict';
const OFFER_DURATION = 2 * 24 * 60 * 60 * 1000;
function getOfferEndTime() {
let endTime = localStorage.getItem('armor_offer_end_time');
const now = new Date().getTime();
if (!endTime || now >= parseInt(endTime)) {
endTime = now + OFFER_DURATION;
localStorage.setItem('armor_offer_end_time', endTime);
}
return parseInt(endTime);
}
function updateCountdown(element) {
const endTime = getOfferEndTime();
const now = new Date().getTime();
const distance = endTime - now;
if (distance < 0) {
localStorage.removeItem('armor_offer_end_time');
return updateCountdown(element);
}
const days = Math.floor(distance / (1000 * 60 * 60 * 24));
const hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
const minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
const seconds = Math.floor((distance % (1000 * 60)) / 1000);
const daysEl = element.querySelector('.countdown-days');
const hoursEl = element.querySelector('.countdown-hours');
const minutesEl = element.querySelector('.countdown-minutes');
const secondsEl = element.querySelector('.countdown-seconds');
if (daysEl) daysEl.textContent = days.toString().padStart(2, '0');
if (hoursEl) hoursEl.textContent = hours.toString().padStart(2, '0');
if (minutesEl) minutesEl.textContent = minutes.toString().padStart(2, '0');
if (secondsEl) secondsEl.textContent = seconds.toString().padStart(2, '0');
}
function createOfferHTML() {
return `
`;
}
function addStyles() {
if (document.querySelector('#armor-countdown-styles')) {
return;
}
const style = document.createElement('style');
style.id = 'armor-countdown-styles';
style.textContent = `
.armor-countdown-container {
width: 100%;
margin: 2rem 0;
padding: 0;
}
.armor-countdown-content {
background: linear-gradient(135deg, #1a1a1a 0%, #2d2d2d 100%);
border-radius: 16px;
padding: 2rem;
box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
position: relative;
overflow: hidden;
border: 2px solid #404040;
}
.armor-countdown-container.product-page .armor-countdown-content {
background: transparent;
box-shadow: none;
border: none;
padding: 1rem 0;
}
.armor-countdown-content::before {
content: '';
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: linear-gradient(45deg, rgba(255,255,255,0.03) 25%, transparent 25%, transparent 75%, rgba(255,255,255,0.03) 75%, rgba(255,255,255,0.03)),
linear-gradient(45deg, rgba(255,255,255,0.03) 25%, transparent 25%, transparent 75%, rgba(255,255,255,0.03) 75%, rgba(255,255,255,0.03));
background-size: 60px 60px;
background-position: 0 0, 30px 30px;
opacity: 0.5;
pointer-events: none;
}
.armor-countdown-container.product-page .armor-countdown-content::before {
display: none;
}
.armor-countdown-header {
display: flex;
flex-direction: column;
align-items: center;
text-align: center;
gap: 1rem;
margin-bottom: 1rem;
position: relative;
z-index: 1;
}
.armor-fire-icon {
font-size: 3rem;
animation: fireFlicker 1.5s ease-in-out infinite;
flex-shrink: 0;
}
@keyframes fireFlicker {
0%, 100% { transform: scale(1) rotate(0deg); }
25% { transform: scale(1.1) rotate(-5deg); }
50% { transform: scale(1.05) rotate(5deg); }
75% { transform: scale(1.15) rotate(-3deg); }
}
.armor-countdown-title h3 {
color: white;
font-size: 1.5rem;
font-weight: bold;
margin: 0 0 0.5rem 0;
text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
text-align: center;
}
.armor-countdown-container.product-page .armor-countdown-title h3 {
color: #1a1a1a;
text-shadow: none;
}
.armor-discount-text {
color: white;
font-size: 1.1rem;
margin: 0;
font-weight: 600;
text-align: center;
}
.armor-countdown-container.product-page .armor-discount-text {
color: #1a1a1a;
}
.discount-percentage {
font-size: 1.8rem;
font-weight: bold;
color: #ffffff;
background: linear-gradient(135deg, #606060 0%, #808080 100%);
padding: 0.2rem 0.8rem;
border-radius: 8px;
text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
animation: pulse 1.5s ease-in-out infinite;
display: inline-block;
}
@keyframes pulse {
0%, 100% { transform: scale(1); }
50% { transform: scale(1.1); }
}
.armor-countdown-timer {
position: relative;
z-index: 1;
}
.countdown-label {
color: white;
font-size: 1rem;
text-align: center;
margin-bottom: 0.5rem;
font-weight: 600;
text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.2);
}
.armor-countdown-container.product-page .countdown-label {
color: #1a1a1a;
text-shadow: none;
}
.countdown-boxes {
display: flex;
justify-content: center;
align-items: center;
gap: 0.5rem;
flex-wrap: wrap;
flex-direction: row-reverse;
}
.countdown-box {
background: linear-gradient(135deg, #3a3a3a 0%, #2a2a2a 100%);
border-radius: 12px;
padding: 0.75rem 1rem;
min-width: 70px;
text-align: center;
box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
transition: transform 0.3s ease;
border: 1px solid #505050;
}
.armor-countdown-container.product-page .countdown-box {
background: transparent;
box-shadow: none;
border: none;
}
.countdown-box:hover {
transform: translateY(-5px);
border-color: #707070;
}
.countdown-value {
font-size: 2rem;
font-weight: bold;
color: #ffffff;
line-height: 1;
margin-bottom: 0.25rem;
font-family: 'Courier New', monospace;
text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}
.armor-countdown-container.product-page .countdown-value {
color: #1a1a1a;
text-shadow: none;
}
.countdown-unit {
font-size: 0.75rem;
color: #b0b0b0;
font-weight: 600;
text-transform: uppercase;
}
.armor-countdown-container.product-page .countdown-unit {
color: #1a1a1a;
}
.countdown-separator {
font-size: 2rem;
color: white;
font-weight: bold;
padding: 0 0.25rem;
text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
}
.armor-countdown-container.product-page .countdown-separator {
color: #1a1a1a;
text-shadow: none;
}
@media screen and (max-width: 640px) {
.armor-countdown-content {
padding: 1rem;
}
.armor-countdown-container.product-page .armor-countdown-content {
padding: 0.5rem 0;
}
.armor-fire-icon {
font-size: 2.5rem;
}
.armor-countdown-title h3 {
font-size: 1.25rem;
}
.armor-discount-text {
font-size: 1rem;
}
.discount-percentage {
font-size: 1.5rem;
}
.countdown-boxes {
gap: 0.35rem;
}
.countdown-box {
padding: 0.5rem 0.75rem;
min-width: 60px;
}
.countdown-value {
font-size: 1.5rem;
}
.countdown-unit {
font-size: 0.65rem;
}
.countdown-separator {
font-size: 1.5rem;
padding: 0 0.15rem;
}
}
`;
document.head.appendChild(style);
}
function addToHomePage() {
const videoBanner = document.querySelector('section.video-banner');
if (!videoBanner || document.querySelector('.armor-countdown-container.home-page')) {
return;
}
const offerDiv = document.createElement('div');
offerDiv.className = 'armor-countdown-wrapper home-page';
offerDiv.innerHTML = createOfferHTML();
offerDiv.querySelector('.armor-countdown-container').classList.add('home-page');
videoBanner.insertAdjacentElement('afterend', offerDiv);
setInterval(() => updateCountdown(offerDiv), 1000);
updateCountdown(offerDiv);
console.log('✅ تم إضافة العرض في الصفحة الرئيسية');
}
function addToProductPage() {
const targetElement = document.querySelector('div.main-content.md\\:sticky.md\\:overflow-hidden.top-24.w-full.md\\:w-2\\/4.md\\:pb-16 > div.product__description.p-2.px-5.sm\\:p-1.leading-7.mb-3');
if (!targetElement || document.querySelector('.armor-countdown-container.product-page')) {
return;
}
const offerDiv = document.createElement('div');
offerDiv.className = 'armor-countdown-wrapper product-page';
offerDiv.innerHTML = createOfferHTML();
offerDiv.querySelector('.armor-countdown-container').classList.add('product-page');
targetElement.insertAdjacentElement('beforebegin', offerDiv);
setInterval(() => updateCountdown(offerDiv), 1000);
updateCountdown(offerDiv);
console.log('✅ تم إضافة العرض في صفحة المنتج فوق الوصف');
}
function init() {
addStyles();
addToHomePage();
addToProductPage();
}
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', init);
} else {
init();
}
const observer = new MutationObserver(function() {
if (!document.querySelector('.armor-countdown-container.home-page')) {
addToHomePage();
}
if (!document.querySelector('.armor-countdown-container.product-page')) {
addToProductPage();
}
});
observer.observe(document.body, {
childList: true,
subtree: true
});
})();
// ============================================
// 5. Dynamic Reviews Counter
// ============================================
(function() {
'use strict';
const STORAGE_KEY = 'reviews_counter_data';
const INITIAL_COUNT = 30;
const MIN_DAILY_INCREASE = 1;
const MAX_DAILY_INCREASE = 3;
function getCurrentDate() {
const now = new Date();
return `${now.getFullYear()}-${now.getMonth() + 1}-${now.getDate()}`;
}
function getRandomIncrease(min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}
function calculateCurrentCount() {
try {
let data = localStorage.getItem(STORAGE_KEY);
if (!data) {
data = {
startDate: getCurrentDate(),
lastUpdate: getCurrentDate(),
currentCount: INITIAL_COUNT
};
localStorage.setItem(STORAGE_KEY, JSON.stringify(data));
return INITIAL_COUNT;
}
data = JSON.parse(data);
const today = getCurrentDate();
if (data.lastUpdate === today) {
return data.currentCount;
}
const lastUpdateDate = new Date(data.lastUpdate);
const todayDate = new Date(today);
const daysDiff = Math.floor((todayDate - lastUpdateDate) / (1000 * 60 * 60 * 24));
let newCount = data.currentCount;
for (let i = 0; i < daysDiff; i++) {
newCount += getRandomIncrease(MIN_DAILY_INCREASE, MAX_DAILY_INCREASE);
}
data.currentCount = newCount;
data.lastUpdate = today;
localStorage.setItem(STORAGE_KEY, JSON.stringify(data));
return newCount;
} catch (e) {
console.error('خطأ في حساب العدد:', e);
return INITIAL_COUNT;
}
}
let isAdded = false;
function addNewReviewsCount() {
if (isAdded) return;
try {
const ratingsWrapper = document.querySelector('.s-rating-stars-wrapper');
if (!ratingsWrapper) {
return;
}
const existingCustomElement = ratingsWrapper.querySelector('.custom-reviews-count');
if (existingCustomElement) {
return;
}
const newSpan = document.createElement('span');
newSpan.className = 'custom-reviews-count';
newSpan.style.color = 'rgba(107, 114, 128, var(--tw-text-opacity, 1))';
newSpan.style.fontSize = '1.1rem';
newSpan.style.fontWeight = '500';
newSpan.style.marginRight = '8px';
const currentCount = calculateCurrentCount();
newSpan.textContent = `(${currentCount} تقييم)`;
ratingsWrapper.appendChild(newSpan);
isAdded = true;
console.log('✅ تم إضافة العدد الجديد:', currentCount);
} catch (e) {
console.error('خطأ في الإضافة:', e);
}
}
function init() {
setTimeout(addNewReviewsCount, 300);
setTimeout(addNewReviewsCount, 800);
setTimeout(addNewReviewsCount, 1500);
}
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', init);
} else {
init();
}
})();
// ============================================
// 6. Animated Top Banner
// ============================================
(function() {
'use strict';
const banner = document.createElement('div');
banner.id = 'banner_';
banner.className = 'banner_';
const link = document.createElement('a');
link.href = 'https://armorpd.com/%D8%AF%D8%B1%D8%B9-%D8%AD%D9%85%D8%A7%D9%8A%D8%A9-%D8%B2%D8%AC%D8%A7%D8%AC-%D8%A7%D9%84%D8%B3%D9%8A%D8%A7%D8%B1%D9%87/p2075802963';
link.className = 'banner-link';
const content = document.createElement('div');
content.className = 'banner-content';
const animatedText = document.createElement('div');
animatedText.className = 'text-animation';
animatedText.innerHTML = `
🔥 أرمور..... خط الدفاع الأول 🔥 خصم 25% لفترة محدودة! 🛍️
🔥 أرمور..... خط الدفاع الأول 🔥 خصم 25% لفترة محدودة! 🛍️
🔥 أرمور..... خط الدفاع الأول 🔥 خصم 25% لفترة محدودة! 🛍️
🔥 أرمور..... خط الدفاع الأول 🔥 خصم 25% لفترة محدودة! 🛍️
`;
content.appendChild(animatedText);
link.appendChild(content);
banner.appendChild(link);
const header = document.querySelector('header.store-header');
if (header) {
header.parentNode.insertBefore(banner, header);
}
})();