/* Add custom Js code below */
try
{
document.querySelectorAll('div#collapse2 .px-5.py-4.duration-300.ease-in-out >p')[0].innerHTML = '
';
}catch{}
document.addEventListener('DOMContentLoaded', async () => {
try{
document.querySelectorAll('salla-social.s-social-list.hydrated')[0].innerHTML += '';
}catch{}
})
var parent = document.querySelectorAll('.copyright-text p.text-gray-400')[0];
var newElement = document.createElement('div');
var newHTML = 'الرقم الضريبي 302027722200003 | ';
parent.insertAdjacentHTML('afterbegin', newHTML);
observeElementChanges('.s-add-product-button-mini-checkout-content', function(element) {
function waitForShadowRoot(hostElement, timeout = 5000) {
return new Promise((resolve, reject) => {
const startTime = Date.now();
const check = () => {
if (hostElement.shadowRoot) {
resolve(hostElement.shadowRoot);
} else if (Date.now() - startTime > timeout) {
reject(new Error(`Shadow root not found on ${hostElement.tagName} within ${timeout}ms.`));
} else {
setTimeout(check, 50); // Check every 50ms
}
};
check();
});
}
// Usage:
const myElement = document.querySelector('salla-mini-checkout-widget'); // Assuming exists
if (myElement) {
waitForShadowRoot(myElement)
.then(shadowRoot => {
console.log('External script: ShadowRoot loaded (exists)!', shadowRoot);
var style = document.createElement( 'style' )
style.innerHTML = '.s-fast-checkout-button.outline { border: 1px solid var(--color-primary) !important; color: #fff !important; height: 100%; background-color: var(--color-primary) !important; }'
shadowRoot.appendChild( style )
// Now you can query elements inside it
})
.catch(error => console.error(error.message));
}/*
var shadowRoot=document.querySelector('salla-mini-checkout-widget').shadowRoot
var style = document.createElement( 'style' )
style.innerHTML = '.s-fast-checkout-button.outline {border: 1px solid #ffa41c!important; color: #ffa41c!important; }'
shadowRoot.appendChild( style )*/
})
function observeElementChanges(selector, callback, changeType = 'created') {
const observer = new MutationObserver(function(mutationsList, observer) {
for (const mutation of mutationsList) {
// التعامل مع الإنشاء (created)
if (changeType === 'created' || changeType === 'both' || changeType === 'all') {
if (mutation.type === 'childList') {
for (const node of mutation.addedNodes) {
if (node.nodeType === 1) { // التأكد من أنه عنصر HTML
// التحقق إذا كان العنصر المضاف نفسه يطابق المحدد
if (node.matches(selector)) {
callback(node, 'created');
}
// التحقق إذا كان أي من أحفاد العنصر المضاف يطابق المحدد
const matchingDescendants = node.querySelectorAll(selector);
matchingDescendants.forEach(descendant => {
callback(descendant, 'created');
});
}
}
}
}
// التعامل مع التعديل (attributes)
if ((changeType === 'attributes' || changeType === 'both' || changeType === 'all') && mutation.type === 'attributes') {
const targetElement = mutation.target;
if (targetElement.nodeType === 1 && targetElement.matches(selector)) {
callback(targetElement, 'attributes', mutation.attributeName);
}
}
// التعامل مع تغيير النص (text / characterData)
if ((changeType === 'text' || changeType === 'both' || changeType === 'all') && mutation.type === 'characterData') {
const parentElement = mutation.target.parentElement;
// يجب أن نتحقق من العنصر الأب لأن characterDataMutations تحدث على TextNode
if (parentElement && parentElement.nodeType === 1 && parentElement.matches(selector)) {
callback(parentElement, 'text');
}
}
}
});
// إعداد خيارات المراقبة
const observerOptions = { childList: true, subtree: true };
if (changeType === 'attributes' || changeType === 'both' || changeType === 'all') {
observerOptions.attributes = true;
// observerOptions.attributeFilter = ['class', 'id', 'data-status']; // لتصفية خصائص معينة
}
if (changeType === 'text' || changeType === 'both' || changeType === 'all') {
observerOptions.characterData = true; // لمراقبة تغييرات محتوى النص
}
// بدء المراقبة على جسم المستند (document.body)
observer.observe(document.body, observerOptions);
// التحقق من وجود العنصر بالفعل عند استدعاء الدالة لأول مرة (فقط لـ 'created')
if (changeType === 'created' || changeType === 'both' || changeType === 'all') {
document.querySelectorAll(selector).forEach(existingElement => {
callback(existingElement, 'created');
});
}
}
const header = document.querySelector('header.khayal-store-header');
const scrollThreshold = 100; // Pixels to scroll before header appears
const scrollThreshold_bf = 90;
window.addEventListener('scroll', () => {
if (window.scrollY > scrollThreshold) {
document.body.classList.add('show_header');
} else {
document.body.classList.remove('show_header');
}
if (window.scrollY > scrollThreshold_bf) {
document.body.classList.add('show_header_bf');
} else {
document.body.classList.remove('show_header_bf');
}
});