نقد و بررسی
وی کازئین طلایی کوین لورن KL 2kg — KL GOLD CASEIN 2KG
کازئین طلایی کوین لورن KL 2kg — KL GOLD CASEIN 2KG
۱. معرفی محصول و شرکت تولیدکننده — توضیح حرفهای و جامع
KL GOLD CASEIN 2KG یک پروتئین کازئین میسلار شبانهاثر است که توسط برند کوین لورن (Kevin Loren / KL) طراحی و تولید شده تا نیازهای ورزشکاران حرفهای و علاقهمندان به حفظ تودهٔ عضلانی در فاز استراحت را بهصورت علمی و عملی برآورده سازد. این محصول در بستهبندی ۲ کیلوگرمی عرضه میشود که با دوز معمول ۳۰ گرم بهازای هر سروینگ، معادل حدود ۶۰–۶۵ سروینگ است؛ بنابراین برای ورزشکاران منظم و کسانی که به ریکاوری شبانه اهمیت میدهند، یک انتخاب اقتصادی و کارآمد محسوب میشود.
کازئین میسلار بهدلیل ساختار مولکولی و توانایی تشکیل ژل در محیط معده، آزادسازی آهسته و پیوستهٔ آمینواسیدها را فراهم میآورد؛ این ویژگی باعث میشود که در طول خواب یا فواصل طولانی بین وعدهها، سطح آمینواسیدهای خون پایدار بماند و فرآیند سنتز پروتئین عضلانی (MPS) حفظ شود. KL GOLD CASEIN با تمرکز بر خلوص پروتئینی، طعمپذیری و حلالیت مناسب، ترکیبی از کازئین میسلار با حداقل افزودنیهای غیرضروری ارائه میدهد تا تجربهٔ مصرفی مطلوب و اثربخشی بالایی داشته باشد.
این محصول برای ورزشکارانی که در دورهٔ حجم یا کات قرار دارند، برای افراد مسن که میخواهند از تحلیل عضلانی جلوگیری کنند، و برای هر کسی که به دنبال یک منبع پروتئینی با آزادسازی طولانیمدت است، مناسب است. بستهٔ ۲ کیلوگرمی برای باشگاهدوستان، مربیان و فروشگاهها نیز مقرونبهصرفه است. فرمول KL GOLD CASEIN بهگونهای طراحی شده که با پروتکلهای تمرینی مدرن و رژیمهای متنوع سازگار باشد؛ از جمله ترکیب با وی پروتئین برای دورههای ریکاوری سریع و شبانه، یا استفادهٔ تنها بهعنوان میانوعدهٔ سیرکننده در رژیمهای کاهش وزن.
در عمل، مصرف منظم کازئین قبل از خواب میتواند کیفیت ریکاوری را بهبود دهد، درد عضلانی پس از تمرین را کاهش دهد و به حفظ تودهٔ بدون چربی کمک کند. KL GOLD CASEIN با استانداردهای کنترل کیفیت تولید میشود و برای اطمینان از شفافیت، اطلاعات تغذیهای و ترکیبات بهصورت کامل روی لیبل درج شده است. این محصول برای کسانی که به دنبال یک راهکار علمی و عملی برای بهینهسازی ریکاوری شبانه هستند، یک گزینهٔ حرفهای و قابلاعتماد است.
(توضیحات بالا بهصورت اوریجینال و نگارش اختصاصی تهیه شده و بر پایهٔ اصول علمی و تجربهٔ کاربردی در ورزش و تغذیه نوشته شده است.)
۲. نوع و هدف مکمل
| نوع | هدف |
|---|---|
| کازئین میسلار (Micellar Casein) | آزادسازی آهستهٔ آمینواسیدها؛ ریکاوری شبانه؛ حفظ تودهٔ عضلانی؛ کاهش تحلیل در فواصل طولانی |
۳. ترکیبات اصلی
| ترکیب | نقش |
|---|---|
| کازئین میسلار خالص | منبع پروتئین با آزادسازی آهسته |
| گلوتامین (مقدار کم) | پشتیبانی ریکاوری و بازسازی |
| آرژنین (مقدار کم) | پشتیبانی جریان خون و ریکاوری |
| طعمدهندهها و امولسیفایرها | طعم و حلالیت بهتر |
| بدون کافئین، بدون نیترات | مناسب مصرف شبانه |
۴. روش مصرف (طبق دستورالعمل روی محصول)
| الگو | توضیح |
|---|---|
| دوز پیشنهادی | ۱ سروینگ (۳۰–۳۵ گرم) در ۲۰۰–۳۰۰ میلیلیتر آب یا شیر |
| زمان مصرف | یک بار قبل خواب؛ در صورت نیاز یک سروینگ پس از تمرین |
| نکته | با قاشق مدرج داخل بسته مصرف شود؛ از افزایش خودسرانهٔ دوز خودداری کنید |
۵. ده روش مصرف برای ورزشکاران، میکس با غذا و شرایط خاص
| رشته | روش پیشنهادی | نکته |
|---|---|---|
| بدنسازی (حجم) | ۱ سروینگ قبل خواب + وی بعد تمرین | حفظ آنابولیسم شبانه |
| بدنسازی (کات) | ۱ سروینگ قبل خواب بهعنوان میانوعدهٔ کمکالری | کمک به سیری و حفظ عضله |
| کراسفیت | ۱ سروینگ عصر برای ریکاوری | ترکیب با کربوهیدرات ساده پس از تمرین سنگین |
| دویدن استقامتی | ۱ سروینگ شبانه | کاهش تحلیل عضلانی در دورهٔ بازیابی |
| رزمی/بوکس | ۱ سروینگ قبل خواب | حفظ قدرت در دورهٔ مسابقات |
| فوتبال | ۱ سروینگ شب قبل مسابقه | ریکاوری و حفظ انرژی عضلانی |
| شنا | ۱ سروینگ بعد تمرین سنگین | ترکیب با پروتئین وی برای ریکاوری سریع+طولانی |
| تمرین صبح | وی صبح؛ کازئین شب | تفکیک منابع برای جذب سریع و طولانی |
| تمرین عصر | کازئین ۳۰–۶۰ دقیقه قبل خواب | اجتناب از مصرف خیلی نزدیک به خواب |
| تمرین شب | آخرین دوز حداقل 2 ساعت قبل خواب | اجتناب از اختلال خواب |
میکس با غذا
اسموتی شبانه: 1 سروینگ کازئین + 1 موز + 1 قاشق کرهٔ بادام + آب یا شیر گیاهی؛ اوتمیل شبانه: مخلوط با جو پرک و مغزها؛ پنکیک پروتئینی: جایگزین آرد تا پروتئین بالا رود.
افراد با بیماریهای خاص
افراد با بیماری کلیوی، حساسیت به شیر یا لاکتوز، یا مصرف داروهای خاص باید قبل از مصرف با پزشک مشورت کنند.
۶. روش مصرف برای رژیمهای مختلف
| رژیم | پیشنهاد |
|---|---|
| کتو | مخلوط با شیر نارگیلی یا آب؛ توجه به کربوهیدرات طعمدهنده |
| روزهداری متناوب | در بازهٔ تغذیه مصرف شود؛ قبل خواب در صورت بازهٔ تغذیه |
| وگان | محصول لبنی است؛ برای وگانها نامناسب |
| کاهش وزن | بهعنوان میانوعدهٔ سیرکننده قبل خواب |
۷. سن مجاز و چه اشخاصی مجاز به مصرف نیستند
| موضوع | توضیح |
|---|---|
| حداقل سن | ۱۸ سال |
| افراد غیرمجاز | کودکان، زنان باردار یا شیرده بدون مشورت پزشک، بیماران کلیوی یا حساسیت به شیر |
| افراد مسن | قابل مصرف با مشورت پزشک؛ ممکن است نیاز به تنظیم دوز باشد |
۸. چک کردن تداخل با مکملهای دیگر
| سازگار | نیاز به احتیاط |
|---|---|
| پروتئین وی، کراتین، BCAA | مجموع پروتئین روزانه را محاسبه کنید؛ مصرف همزمان چند منبع پروتئینی ممکن است نیاز به تنظیم داشته باشد |
| مولتیویتامینها | در صورت وجود کلسیم/فسفر بالا، تداخل جذب ممکن است رخ دهد |
۹. مطالعات و گواهیهای مستقل
| نوع مدرک | توضیح |
|---|---|
| مطالعات بالینی | مطالعات متعددی نشان دادهاند که مصرف کازئین قبل خواب میتواند سنتز پروتئین عضلانی را در طول شب افزایش دهد و به ریکاوری کمک کند. |
| گواهیهای کیفیت | برای اطمینان از کیفیت، به دنبال گواهیهای NSF, Informed‑Choice یا Labdoor روی لیبل محصول باشید. |
۱۰. اطلاعات نگهداری
| شرایط | توضیح |
|---|---|
| دمای نگهداری | ۱۵–۲۵ °C، دور از یخزدگی |
| نور | دور از نور مستقیم خورشید |
| رطوبت | دور از رطوبت و بخار آشپزخانه/حمام |
| درب بسته | پس از هر بار مصرف درب را محکم ببندید |
۱۱. پرسشهای متداول
۱۲. جدول ارزش غذایی (نمونه دقیق هر سروینگ ~30g)
| ماده | مقدار در هر سروینگ | %DV (تقریبی) |
|---|---|---|
| پروتئین | 24 g | — |
| چربی | 1.5 g | — |
| کربوهیدرات | 3 g | — |
| نمک | 0.2 g | — |
| گلوتامین (تقریبی) | 1.2 g | — |
| کافئین | 0 mg | 0% |
| نیترات | 0 mg | 0% |
توجه: مقادیر دقیق بسته به فرمول تولیدکننده ممکن است متفاوت باشد؛ همواره لیبل محصول را بررسی کنید.
۱۳. نمودار مقایسهای — KL GOLD CASEIN در برابر ۵ مکمل مشابه
| محصول | دوز | پمپ | تمرکز/ریکاوری | حجم (بسته) |
|---|---|---|---|---|
| KL GOLD CASEIN | 30 g | کم | بالا (شبانه) | 2 kg |
| Casein Pro A | 30 g | کم | متوسط | 1.8 kg |
| Night Protein B | 35 g | کم | بالا | 2 kg |
| SlowRelease C | 30 g | کم | متوسط | 1.5 kg |
| Ultra Casein D | 40 g | کم | بالا | 2.2 kg |
۱۴. علم پشت فرمول
کازئین میسلار با تشکیل ماتریکس ژلاتینی در معده، جذب پروتئین را بهصورت آهسته و پیوسته انجام میدهد؛ این فرآیند باعث میشود سطح آمینواسیدهای خون در طول شب پایدار بماند و سنتز پروتئین عضلانی (MPS) حفظ شود. برخلاف پروتئینهای سریعالجذب مانند وی، کازئین برای فازهای طولانیمدت (مثلاً خواب) مناسبتر است. این محصول نیتریک اکساید پیشتمرین ندارد؛ اگر هدف افزایش پمپ عضلانی است، از مکملهای حاوی سیترولین یا نیترات استفاده کنید که با افزایش تولید نیتریک اکساید باعث گشاد شدن عروق و افزایش جریان خون میشوند.
۱۵. خرید و لینکهای مرتبط
برای مشاهده محصولات مرتبط و مکملهای مکمل توصیهشده از لینکهای زیر استفاده کنید:
// FAQ accordion behavior (compact, single-open)
document.querySelectorAll(‘.faq-q’).forEach(q=>{
q.addEventListener(‘click’, ()=>{
const a = q.nextElementSibling;
const open = a.style.display === ‘block’;
document.querySelectorAll(‘.faq-a’).forEach(x=>x.style.display=’none’);
if(!open) a.style.display = ‘block’;
});
});
<!–
Advanced Structured Data + Meta Generator
– Place in product description HTML or in if possible.
– Replace placeholders like [YOUR_DOMAIN], [PRODUCT_NAME], etc.
– JSON-LD is visible in page source (standard). Do not cloak content.
–>
(function(){
try{
const c = document.getElementById(‘sd-advanced’);
if(!c) return;
const d = c.dataset;
const domain = (d.domain||”).replace(//$/,”);
const productUrl = d.url || (domain + ‘/product/’ + (d.sku||’product’));
const name = d.name || document.title || ‘Product’;
const description = d.desc || ”;
const image = d.image || (domain + ‘/assets/default-product.jpg’);
const imgW = parseInt(d.imageWidth||1200,10);
const imgH = parseInt(d.imageHeight||1200,10);
const sku = d.sku || ”;
const gtin = d.gtin || ”;
const brand = d.brand || ”;
const price = d.price || ”;
const currency = d.currency || ‘IRR’;
const priceValidUntil = d.pricevaliduntil || ”;
const availability = d.availability || ‘InStock’;
const category = d.category || ‘Supplements’;
const categoryUrl = d.categoryUrl || (domain + ‘/category/supplements’);
// Upsert canonical
if(!document.querySelector(‘link[rel=”canonical”]’)){
const link = document.createElement(‘link’);
link.rel = ‘canonical’;
link.href = productUrl;
document.head.appendChild(link);
}
// Upsert meta description (do not overwrite if intentionally set server-side)
if(!document.querySelector(‘meta[name=”description”]’)){
const m = document.createElement(‘meta’);
m.name = ‘description’;
m.content = description;
document.head.appendChild(m);
}
// OpenGraph & Twitter (only add if missing)
function addIfMissing(selector, tagName, attrs){
if(!document.head.querySelector(selector)){
const el = document.createElement(tagName);
for(const k in attrs) el.setAttribute(k, attrs[k]);
document.head.appendChild(el);
}
}
addIfMissing(‘meta[property=”og:type”]’,’meta’,{property:’og:type’,content:’product’});
addIfMissing(‘meta[property=”og:title”]’,’meta’,{property:’og:title’,content:name});
addIfMissing(‘meta[property=”og:description”]’,’meta’,{property:’og:description’,content:description});
addIfMissing(‘meta[property=”og:image”]’,’meta’,{property:’og:image’,content:image});
addIfMissing(‘meta[name=”twitter:card”]’,’meta’,{name:’twitter:card’,content:’summary_large_image’});
addIfMissing(‘meta[name=”twitter:title”]’,’meta’,{name:’twitter:title’,content:name});
addIfMissing(‘meta[name=”twitter:description”]’,’meta’,{name:’twitter:description’,content:description});
addIfMissing(‘meta[name=”twitter:image”]’,’meta’,{name:’twitter:image’,content:image});
// Preload image for LCP
if(!document.head.querySelector(‘link[rel=”preload”][href=”‘+image+'”]’)){
const pl = document.createElement(‘link’);
pl.rel = ‘preload’;
pl.as = ‘image’;
pl.href = image;
document.head.appendChild(pl);
}
// Build JSON-LD graph
const graph = [];
// Organization (minimal)
graph.push({
“@type”:”Organization”,
“@id”: domain + “/#org”,
“name”: brand || document.title || “Brand”,
“url”: domain,
“logo”: domain + “/assets/logo.png”,
“sameAs”: [ /* add official social profiles if any */ ]
});
// WebSite + SearchAction
graph.push({
“@type”:”WebSite”,
“@id”: domain + “/#website”,
“url”: domain,
“name”: document.title || name,
“potentialAction”: {
“@type”:”SearchAction”,
“target”: domain + “/search?q={search_term_string}”,
“query-input”:”required name=search_term_string”
}
});
// Product with ImageObject and Offer
const product = {
“@type”:”Product”,
“@id”: productUrl + “#product”,
“name”: name,
“description”: description,
“image”: [{
“@type”:”ImageObject”,
“url”: image,
“width”: imgW,
“height”: imgH
}],
“sku”: sku,
“brand”: { “@type”:”Brand”, “name”: brand || “Brand” },
“category”: category,
“offers”: {
“@type”:”Offer”,
“url”: productUrl,
“priceCurrency”: currency,
“price”: price || “”,
“priceValidUntil”: priceValidUntil || undefined,
“availability”: “https://schema.org/” + (availability || “InStock”),
“itemCondition”: “https://schema.org/NewCondition”,
“seller”: { “@type”:”Organization”, “name”: brand || “Seller” }
},
“isAccessibleForFree”: false,
“mainEntityOfPage”: { “@type”:”WebPage”, “@id”: productUrl }
};
if(gtin) product.gtin13 = gtin;
graph.push(product);
// AggregateRating & Reviews (if provided)
try{
const reviews = JSON.parse(c.dataset.reviews || ‘[]’);
if(reviews.length){
const agg = {
“@type”:”AggregateRating”,
“ratingValue”: (function(){
const sum = reviews.reduce((s,r)=>s + (Number(r.rating)||0),0);
return (sum / reviews.length).toFixed(1);
})(),
“reviewCount”: reviews.length
};
product.aggregateRating = agg;
product.review = reviews.map(r => ({
“@type”:”Review”,
“author”: { “@type”:”Person”, “name”: r.author || “کاربر” },
“datePublished”: r.date || new Date().toISOString().split(‘T’)[0],
“reviewBody”: r.body || r.reviewBody || “”,
“reviewRating”: { “@type”:”Rating”, “ratingValue”: String(r.rating || r.reviewRating || 5) }
}));
}
}catch(e){ /* ignore parse errors */ }
// Breadcrumb
graph.push({
“@type”:”BreadcrumbList”,
“itemListElement”:[
{ “@type”:”ListItem”,”position”:1,”name”:”خانه”,”item”:domain },
{ “@type”:”ListItem”,”position”:2,”name”:category,”item”:categoryUrl },
{ “@type”:”ListItem”,”position”:3,”name”:name,”item”:productUrl }
]
});
// FAQ
try{
const faq = JSON.parse(c.dataset.faq || ‘[]’);
if(faq.length){
const faqEntity = { “@type”:”FAQPage”, “mainEntity”: [] };
faq.forEach(it=>{
if(it.q && it.a){
faqEntity.mainEntity.push({
“@type”:”Question”,
“name”: it.q,
“acceptedAnswer”: { “@type”:”Answer”, “text”: it.a }
});
}
});
if(faqEntity.mainEntity.length) graph.push(faqEntity);
}
}catch(e){ /* ignore */ }
// Speakable (for voice assistants) – minimal
graph.push({
“@type”:”WebPage”,
“@id”: productUrl + “#webpage”,
“url”: productUrl,
“name”: name,
“isAccessibleForFree”: true,
“speakable”: {
“@type”:”SpeakableSpecification”,
“xpath”: [“/html/head/title”,”/html/body//h1″]
}
});
// Insert JSON-LD
const ld = { “@context”:”https://schema.org”, “@graph”: graph };
const s = document.createElement(‘script’);
s.type = ‘application/ld+json’;
s.text = JSON.stringify(ld, null, 2);
document.body.appendChild(s);
// Lightweight telemetry for debugging (no external calls)
console.info(‘SD advanced injected for’, name);
}catch(err){
console.error(‘SD advanced error’, err);
}
})();
/*
SD Advanced Ultimate
– Client-side injector + returns JSON-LD string for server-side use (window.__sd_advanced_jsonld)
– Modules: variants, sellers, shipping, returns, nutrition, video+transcript, faq, qa, reviews, hreflang, embeddings hook
– Dynamic price/inventory via API with localStorage cache
– Telemetry hooks via window.dispatchEvent and dataLayer
– Preconnect/resource hints and OG/Twitter meta injection
*/
(function(){
try{
const c = document.getElementById(‘sd-advanced’);
if(!c) return;
const d = c.dataset;
// ———- Helpers ———-
const safeParse = s => { try{ return JSON.parse(s); }catch(e){ return null; } };
const pick = (k, alt) => (d[k] !== undefined ? d[k] : (alt===undefined? ” : alt));
const domain = (pick(‘domain’) || window.location.origin).replace(//$/,”);
const productUrl = pick(‘url’) || (domain + ‘/product/’ + (pick(‘sku’) || ‘product’));
const name = pick(‘name’) || document.title || ‘Product’;
const description = pick(‘desc’) || ”;
const images = safeParse(d.images || d[‘images’]) || [ pick(‘image’) || (domain + ‘/assets/default-product.jpg’) ];
const imgW = parseInt(pick(‘imageWidth’) || pick(‘image-width’) || 1200,10);
const imgH = parseInt(pick(‘imageHeight’) || pick(‘image-height’) || 1200,10);
const sku = pick(‘sku’) || ”;
const gtin = pick(‘gtin’) || ”;
const brand = pick(‘brand’) || ”;
const priceStatic = pick(‘price’) || ”;
const currency = pick(‘currency’) || ‘IRR’;
const priceValidUntil = pick(‘priceValidUntil’) || pick(‘pricevaliduntil’) || ”;
const availabilityStatic = pick(‘availability’) || ‘InStock’;
const category = pick(‘category’) || ‘Supplements’;
const categoryUrl = pick(‘categoryUrl’) || pick(‘category-url’) || (domain + ‘/category/supplements’);
// Complex fields
const variants = safeParse(d.variants || d[‘variants’]) || [];
const sellers = safeParse(d.sellers || d[‘sellers’]) || [];
const faq = safeParse(d.faq || d[‘faq’]) || [];
const reviews = safeParse(d.reviews || d[‘reviews’]) || [];
const qa = safeParse(d.qa || d[‘qa’]) || [];
const shipping = safeParse(d.shipping || d[‘shipping’]) || {};
const returns = safeParse(d.return || d[‘return’]) || {};
const nutrition = safeParse(d.nutrition || d[‘nutrition’]) || {};
const video = safeParse(d.video || d[‘video’]) || {};
const priceApi = pick(‘priceApi’) || pick(‘price-api’) || ”;
const inventoryApi = pick(‘inventoryApi’) || pick(‘inventory-api’) || ”;
const hreflangMap = safeParse(d.hreflang || d[‘hreflang’]) || {};
const disableTelemetry = (pick(‘disableTelemetry’) === ‘true’);
const disableEmbeddings = (pick(‘disableEmbeddings’) === ‘true’);
// Sanitization
const sanitizeStr = s => (typeof s === ‘string’ ? s.replace(/[u0000-u001Fu007F]/g,”).trim() : s);
const sanitizeObj = o => {
if(!o || typeof o !== ‘object’) return o;
const r = Array.isArray(o) ? [] : {};
for(const k in o){
const v = o[k];
if(typeof v === ‘string’) r[k] = sanitizeStr(v);
else if(typeof v === ‘object’) r[k] = sanitizeObj(v);
else r[k] = v;
}
return r;
};
const safeName = sanitizeStr(name);
const safeDesc = sanitizeStr(description);
const safeImages = images.map(i=>sanitizeStr(i));
const safeVariants = (Array.isArray(variants) ? variants.map(v=>sanitizeObj(v)) : []);
const safeSellers = (Array.isArray(sellers) ? sellers.map(s=>sanitizeObj(s)) : []);
const safeFaq = (Array.isArray(faq) ? faq.map(f=>sanitizeObj(f)) : []);
const safeReviews = (Array.isArray(reviews) ? reviews.map(r=>sanitizeObj(r)) : []);
const safeQa = (Array.isArray(qa) ? qa.map(q=>sanitizeObj(q)) : []);
const safeShipping = sanitizeObj(shipping);
const safeReturns = sanitizeObj(returns);
const safeNutrition = sanitizeObj(nutrition);
const safeVideo = sanitizeObj(video);
// Fetch with timeout
const fetchWithTimeout = (url, opts={}, timeout=4000) => {
return new Promise((resolve,reject)=>{
const timer = setTimeout(()=> reject(new Error(‘timeout’)), timeout);
fetch(url, opts).then(r=>{ clearTimeout(timer); if(!r.ok) return reject(new Error(‘http ‘+r.status)); return r.json(); }).then(resolve).catch(reject);
});
};
// Simple localStorage cache
const cacheGet = (k) => {
try{ const s = localStorage.getItem(k); if(!s) return null; const p = JSON.parse(s); if(p.exp && Date.now()>p.exp) { localStorage.removeItem(k); return null; } return p.v; }catch(e){ return null; }
};
const cacheSet = (k,v,ttl=300000) => { try{ localStorage.setItem(k, JSON.stringify({v:v, exp: Date.now()+ttl})); }catch(e){} };
// Telemetry hook
const telemetry = (evt, payload) => {
if(disableTelemetry) return;
try{
window.dispatchEvent(new CustomEvent(‘sd-advanced-event’, {detail:{event:evt,payload:payload}}));
if(window.dataLayer && Array.isArray(window.dataLayer)) window.dataLayer.push({event:’sd_advanced_’+evt, payload: payload});
if(window.console && console.debug) console.debug(‘sd_advanced_event’, evt, payload);
}catch(e){}
};
// Preconnect/resource hints
(function addResourceHints(){
// preconnect to domain and common CDNs if images hosted elsewhere
const hosts = new Set([new URL(domain).host]);
safeImages.forEach(u=>{ try{ hosts.add(new URL(u).host); }catch(e){} });
if(safeVideo && safeVideo.url) try{ hosts.add(new URL(safeVideo.url).host); }catch(e){}
hosts.forEach(h=>{
if(!document.head.querySelector(‘link[rel=”preconnect”][href*=”‘+h+'”]’)){
const l = document.createElement(‘link’); l.rel=’preconnect’; l.href = (location.protocol+’//’+h); l.crossOrigin = ”; document.head.appendChild(l);
}
});
// dns-prefetch
hosts.forEach(h=>{
if(!document.head.querySelector(‘link[rel=”dns-prefetch”][href*=”‘+h+'”]’)){
const l = document.createElement(‘link’); l.rel=’dns-prefetch’; l.href = (location.protocol+’//’+h); document.head.appendChild(l);
}
});
})();
// Insert canonical if missing
if(!document.querySelector(‘link[rel=”canonical”]’)){
const link = document.createElement(‘link’); link.rel=’canonical’; link.href = productUrl; document.head.appendChild(link);
}
// hreflang tags
(function addHreflang(){
if(hreflangMap && typeof hreflangMap === ‘object’){
Object.keys(hreflangMap).forEach(lang=>{
const url = hreflangMap[lang];
if(!document.head.querySelector(‘link[rel=”alternate”][hreflang=”‘+lang+'”]’)){
const l = document.createElement(‘link’); l.rel=’alternate’; l.hreflang = lang; l.href = url; document.head.appendChild(l);
}
});
}
})();
// Meta description
if(!document.querySelector(‘meta[name=”description”]’) && safeDesc){
const m = document.createElement(‘meta’); m.name = ‘description’; m.content = safeDesc; document.head.appendChild(m);
}
// OG/Twitter
(function addOG(){
const addMeta = (sel, tag, attrs) => { if(!document.head.querySelector(sel)){ const el = document.createElement(tag); Object.keys(attrs).forEach(k=>el.setAttribute(k, attrs[k])); document.head.appendChild(el); } };
addMeta(‘meta[property=”og:type”]’,’meta’,{property:’og:type’,content:’product’});
addMeta(‘meta[property=”og:title”]’,’meta’,{property:’og:title’,content:safeName});
addMeta(‘meta[property=”og:description”]’,’meta’,{property:’og:description’,content:safeDesc});
addMeta(‘meta[property=”og:image”]’,’meta’,{property:’og:image’,content:safeImages[0]});
addMeta(‘meta[name=”twitter:card”]’,’meta’,{name:’twitter:card’,content:’summary_large_image’});
addMeta(‘meta[name=”twitter:title”]’,’meta’,{name:’twitter:title’,content:safeName});
addMeta(‘meta[name=”twitter:description”]’,’meta’,{name:’twitter:description’,content:safeDesc});
addMeta(‘meta[name=”twitter:image”]’,’meta’,{name:’twitter:image’,content:safeImages[0]});
// og:image:width/height
addMeta(‘meta[property=”og:image:width”]’,’meta’,{property:’og:image:width’,content:String(imgW)});
addMeta(‘meta[property=”og:image:height”]’,’meta’,{property:’og:image:height’,content:String(imgH)});
})();
// Preload best image
if(safeImages[0] && !document.head.querySelector(‘link[rel=”preload”][href=”‘+safeImages[0]+'”]’)){
const pl = document.createElement(‘link’); pl.rel=’preload’; pl.as=’image’; pl.href = safeImages[0]; document.head.appendChild(pl);
}
// ———- Build JSON-LD graph ———-
const graph = [];
// Organization
graph.push({
“@type”:”Organization”,
“@id”: domain + “/#org”,
“name”: brand || document.title || “Brand”,
“url”: domain,
“logo”: domain + “/assets/logo.png”,
“sameAs”: []
});
// WebSite + SearchAction + Sitelinks SearchBox
graph.push({
“@type”:”WebSite”,
“@id”: domain + “/#website”,
“url”: domain,
“name”: document.title || safeName,
“potentialAction”: {
“@type”:”SearchAction”,
“target”: domain + “/search?q={search_term_string}”,
“query-input”:”required name=search_term_string”
}
});
// Product base
const product = {
“@type”:”Product”,
“@id”: productUrl + “#product”,
“name”: safeName,
“description”: safeDesc,
“image”: safeImages.map(u=>({“@type”:”ImageObject”,”url”:u,”width”:imgW,”height”:imgH})),
“sku”: sanitizeStr(sku),
“brand”: { “@type”:”Brand”, “name”: brand || “Brand” },
“category”: category,
“offers”: [],
“isAccessibleForFree”: false,
“mainEntityOfPage”: { “@type”:”WebPage”, “@id”: productUrl }
};
if(gtin) product.gtin13 = sanitizeStr(gtin);
// Primary static offer
if(priceStatic){
product.offers.push({
“@type”:”Offer”,
“url”: productUrl,
“priceCurrency”: currency,
“price”: priceStatic,
“priceValidUntil”: priceValidUntil || undefined,
“availability”: “https://schema.org/” + (availabilityStatic || “InStock”),
“itemCondition”: “https://schema.org/NewCondition”,
“seller”: { “@type”:”Organization”, “name”: brand || “Seller” }
});
}
// Sellers / Marketplace offers
if(Array.isArray(safeSellers) && safeSellers.length){
safeSellers.forEach(s => {
const sellerOffer = {
“@type”:”Offer”,
“url”: productUrl + (s.sellerId ? (‘?seller=’ + encodeURIComponent(s.sellerId)) : ”),
“priceCurrency”: currency,
“price”: priceStatic || ”,
“availability”: “https://schema.org/” + (availabilityStatic || “InStock”),
“itemCondition”: “https://schema.org/NewCondition”,
“seller”: { “@type”:”Organization”, “name”: s.name || ‘Seller’ }
};
if(s.rating) sellerOffer.seller = Object.assign({}, sellerOffer.seller, {“aggregateRating”: {“@type”:”AggregateRating”,”ratingValue”: String(s.rating)}} );
product.offers.push(sellerOffer);
});
}
// Variants
if(Array.isArray(safeVariants) && safeVariants.length){
product.hasVariant = [];
safeVariants.forEach((v, idx) => {
const vSku = v.sku || (sku + ‘-‘ + (idx+1));
const vImages = (v.images && v.images.length) ? v.images.map(i=>sanitizeStr(i)) : safeImages;
const vOffer = {
“@type”:”Offer”,
“url”: productUrl + (v.sku ? (‘#’ + encodeURIComponent(v.sku)) : ”),
“priceCurrency”: v.currency || currency,
“price”: v.price || priceStatic || ”,
“availability”: “https://schema.org/” + (v.availability || availabilityStatic || ‘InStock’),
“itemCondition”: “https://schema.org/NewCondition”,
“sku”: vSku,
“seller”: { “@type”:”Organization”, “name”: brand || “Seller” }
};
product.offers.push(vOffer);
const variantProduct = {
“@type”:”Product”,
“@id”: productUrl + ‘#variant-‘ + encodeURIComponent(vSku),
“name”: safeName + (v.properties ? (‘ – ‘ + Object.values(v.properties).join(‘ / ‘)) : ”),
“sku”: vSku,
“image”: vImages.map(u=>({“@type”:”ImageObject”,”url”:u,”width”:imgW,”height”:imgH})),
“offers”: vOffer,
“additionalProperty”: []
};
if(v.properties){
Object.keys(v.properties).forEach(k=>{
variantProduct.additionalProperty.push({“@type”:”PropertyValue”,”name”:sanitizeStr(k),”value”:sanitizeStr(v.properties[k])});
});
}
product.hasVariant.push({“@type”:”Product”,”@id”: variantProduct[‘@id’]});
graph.push(variantProduct);
});
}
// Shipping details attach to offers
if(safeShipping && Object.keys(safeShipping).length){
const ship = {
“@type”:”OfferShippingDetails”,
“shippingDestination”: Array.isArray(safeShipping.regions) ? safeShipping.regions.map(r=>({“@type”:”DefinedRegion”,”addressCountry”:r})) : undefined,
“shippingRate”: safeShipping.price ? {“@type”:”MonetaryAmount”,”value”:safeShipping.price,”currency”:safeShipping.currency || currency} : undefined,
“deliveryTime”: safeShipping.leadTime ? {“@type”:”ShippingDeliveryTime”,”handlingTime”: safeShipping.leadTime} : undefined
};
product.offers = product.offers.map(o => Object.assign({}, o, {“shippingDetails”: ship}));
}
// Return policy
if(safeReturns && Object.keys(safeReturns).length){
product.returnPolicy = {
“@type”:”MerchantReturnPolicy”,
“returnPolicyCategory”: safeReturns.policy || ‘https://schema.org/MerchantReturnFiniteReturnWindow’,
“returnFees”: safeReturns.fees || ‘https://schema.org/FreeReturn’,
“returnMethod”: safeReturns.method || undefined,
“merchantReturnDays”: safeReturns.days || undefined
};
}
// Nutrition
if(safeNutrition && Object.keys(safeNutrition).length){
product.nutrition = Object.assign({“@type”:”NutritionInformation”}, safeNutrition);
}
// VideoObject with transcript
if(safeVideo && safeVideo.url){
const vobj = {
“@type”:”VideoObject”,
“name”: safeName + ‘ – video’,
“description”: safeDesc,
“thumbnailUrl”: safeVideo.thumbnail || safeImages[0],
“uploadDate”: safeVideo.uploadDate || undefined,
“duration”: safeVideo.duration || undefined,
“contentUrl”: safeVideo.url,
“embedUrl”: safeVideo.embed || undefined
};
if(safeVideo.transcript) vobj.transcript = safeVideo.transcript;
graph.push(vobj);
}
// Reviews and AggregateRating
if(Array.isArray(safeReviews) && safeReviews.length){
const revs = safeReviews.map(r => ({
“@type”:”Review”,
“author”: {“@type”:”Person”,”name”: r.author || ‘کاربر’},
“datePublished”: r.date || new Date().toISOString().split(‘T’)[0],
“reviewBody”: r.body || r.reviewBody || ”,
“reviewRating”: {“@type”:”Rating”,”ratingValue”: String(r.rating || r.reviewRating || 5)}
}));
product.review = revs;
const sum = safeReviews.reduce((s,r)=> s + (Number(r.rating)||0), 0);
const avg = (sum / safeReviews.length) || 0;
product.aggregateRating = {“@type”:”AggregateRating”,”ratingValue”: avg.toFixed(1),”reviewCount”: safeReviews.length};
}
// Q&A as Question/Answer
if(Array.isArray(safeQa) && safeQa.length){
const qlist = safeQa.map(q => {
const obj = {
“@type”:”Question”,
“name”: q.q || q.question || ”,
“acceptedAnswer”: {“@type”:”Answer”,”text”: q.a || q.answer || ”}
};
if(q.author) obj.author = {“@type”:”Person”,”name”: q.author};
if(q.date) obj.datePublished = q.date;
return obj;
});
graph.push({“@type”:”FAQPage”,”mainEntity”: qlist});
}
// FAQ
if(Array.isArray(safeFaq) && safeFaq.length){
const faqEntity = {“@type”:”FAQPage”,”mainEntity”:[]};
safeFaq.forEach(it=>{
if(it.q && it.a){
faqEntity.mainEntity.push({
“@type”:”Question”,
“name”: it.q,
“acceptedAnswer”: {“@type”:”Answer”,”text”: it.a}
});
}
});
if(faqEntity.mainEntity.length) graph.push(faqEntity);
}
// Breadcrumb
graph.push({
“@type”:”BreadcrumbList”,
“itemListElement”:[
{ “@type”:”ListItem”,”position”:1,”name”:”خانه”,”item”:domain },
{ “@type”:”ListItem”,”position”:2,”name”:category,”item”:categoryUrl },
{ “@type”:”ListItem”,”position”:3,”name”:safeName,”item”:productUrl }
]
});
// Speakable
graph.push({
“@type”:”WebPage”,
“@id”: productUrl + “#webpage”,
“url”: productUrl,
“name”: safeName,
“isAccessibleForFree”: true,
“speakable”: {
“@type”:”SpeakableSpecification”,
“xpath”: [“/html/head/title”,”/html/body//h1″]
}
});
// ———- Dynamic price/inventory fetch ———-
const dynamic = { price: priceStatic, availability: availabilityStatic, inventory: null };
const tryDynamic = async () => {
try{
if(priceApi){
const cacheKey = ‘sd_price_’+sku;
const cached = cacheGet(cacheKey);
if(cached) dynamic.price = cached.price;
else {
const res = await fetchWithTimeout(priceApi, {method:’GET’, credentials:’same-origin’}, 4000);
if(res && (res.price || res.price === 0)) { dynamic.price = String(res.price); cacheSet(cacheKey, {price: String(res.price)}, 300000); telemetry(‘price_api_ok’,{sku:sku,price:dynamic.price}); }
}
}
}catch(e){ telemetry(‘price_api_error’,{sku:sku,error:String(e)}); }
try{
if(inventoryApi){
const cacheKey = ‘sd_inv_’+sku;
const cached = cacheGet(cacheKey);
if(cached) { dynamic.inventory = cached.inventory; dynamic.availability = cached.availability || dynamic.availability; }
else {
const res = await fetchWithTimeout(inventoryApi, {method:’GET’, credentials:’same-origin’}, 4000);
if(res && (res.inventory !== undefined)) {
dynamic.inventory = res.inventory;
dynamic.availability = res.inventory>0 ? ‘InStock’ : ‘OutOfStock’;
cacheSet(cacheKey, {inventory: res.inventory, availability: dynamic.availability}, 300000);
telemetry(‘inventory_api_ok’,{sku:sku,inventory:res.inventory});
}
}
}
}catch(e){ telemetry(‘inventory_api_error’,{sku:sku,error:String(e)}); }
};
// ———- Inject JSON-LD and expose for server-side ———-
const injectJsonLd = (graphObj) => {
const ld = {“@context”:”https://schema.org”,”@graph”: graphObj};
const s = document.createElement(‘script’);
s.type = ‘application/ld+json’;
s.text = JSON.stringify(ld, null, 2);
document.body.appendChild(s);
return JSON.stringify(ld);
};
// ———- Embeddings hook (server-side recommended) ———-
// This client-side hook only signals that embeddings should be generated server-side.
const embeddingsHook = (payload) => {
if(disableEmbeddings) return;
try{
// Dispatch event so site can capture and send to server for vectorization
window.dispatchEvent(new CustomEvent(‘sd-advanced-embeddings’, {detail: payload}));
// Expose for server capture
window.__sd_advanced_embeddings_payload = payload;
}catch(e){}
};
// ———- Main execution ———-
(async function main(){
telemetry(‘start’,{sku:sku});
await tryDynamic();
// update offers with dynamic price/availability if present
if(dynamic.price){
product.offers = product.offers.map(o => Object.assign({}, o, {“price”: dynamic.price, “priceCurrency”: currency}));
}
if(dynamic.availability){
product.offers = product.offers.map(o => Object.assign({}, o, {“availability”: “https://schema.org/” + dynamic.availability}));
}
if(dynamic.inventory !== null) product.inventoryLevel = {“@type”:”QuantitativeValue”,”value”: Number(dynamic.inventory)};
// attach shipping/return already done earlier
graph.push(product);
// Prepare embeddings payload (title, desc, faq, reviews, transcript)
const embedPayload = {
id: sku || productUrl,
title: safeName,
description: safeDesc,
faq: safeFaq,
reviews: safeReviews,
qa: safeQa,
transcript: (safeVideo && safeVideo.transcript) ? safeVideo.transcript : ”
};
embeddingsHook(embedPayload);
// Inject JSON-LD into DOM
const jsonldString = injectJsonLd(graph);
// Expose JSON-LD for server-side capture or debugging
window.__sd_advanced_jsonld = jsonldString;
telemetry(‘injected’,{sku:sku,length: jsonldString.length});
})();
if(window.console && console.info) console.info(‘SD advanced ultimate initialized for’, safeName);
}catch(err){
if(window.console && console.error) console.error(‘SD advanced ultimate error’, err);
}
})();
<div id="sd-ultimate-pro" style="display:none"
data-domain="https://fit.rointansupplement.ir"
data-url="https://fit.rointansupplement.ir/programs/plan-123"
data-name="برنامه تمرین و تغذیه شخصی"
data-desc="برنامه تمرینی و تغذیه شخصیسازیشده؛ شامل برنامه هفتگی، کالری هدف و پیگیری پیشرفت."
data-images='["https://fit.rointansupplement.ir/media/plan-123-1.jpg","https://fit.rointansupplement.ir/media/plan-123-2.jpg"]'
data-image-width="1200"
data-image-height="800"
data-sku="PLAN-123"
data-gtin=""
data-brand="Rointan Fitness"
data-category="برنامه تمرینی"
data-price="49.99"
data-currency="USD"
data-priceValidUntil="2026-12-31"
data-availability="Online"
data-faq='[{"q":"آیا برنامه برای مبتدیان مناسب است؟","a":"بله؛ برنامه شامل سطوح مختلف و ویدیوهای آموزشی است."}]'
data-qa='[{"q":"آیا نیاز به تجهیزات دارم؟","a":"برای بسیاری از تمرینها نیازی به تجهیزات نیست.","author":"مربی"}]'
data-reviews='[{"author":"کاربر A","date":"2025-06-01","rating":5,"body":"نتایج عالی در 8 هفته"}]'
data-video='{"url":"https://fit.rointansupplement.ir/media/plan-123-intro.mp4","thumbnail":"https://fit.rointansupplement.ir/media/plan-123-thumb.jpg","duration":"PT3M20S","uploadDate":"2025-06-01","transcript":"https://fit.rointansupplement.ir/media/plan-123-transcript.txt"}'
data-tools='[{"type":"SoftwareApplication","name":"BMI Calculator","url":"https://fit.rointansupplement.ir/tools/bmi","description":"محاسبه BMI"},{"type":"SoftwareApplication","name":"Calorie Calculator","url":"https://fit.rointansupplement.ir/tools/calorie","description":"محاسبه کالری هدف"}]'
data-hreflang='{"fa":"https://fit.rointansupplement.ir/fa/programs/plan-123","en":"https://fit.rointansupplement.ir/en/programs/plan-123"}'
data-price-api="/api/proxy/price/PLAN-123"
data-inventory-api=”/api/proxy/inventory/PLAN-123″
data-signed-jsonld-api=”/api/signed-jsonld/PLAN-123″
data-public-key-pem=”—–BEGIN PUBLIC KEY—–nMIIBIjANBgkq…n—–END PUBLIC KEY—–”
data-embeddings-endpoint=”/api/embeddings/ingest”
data-telemetry-endpoint=”/api/telemetry”
data-disable-telemetry=”false”
data-disable-embeddings=”false”
data-disable-signed-check=”false”
data-max-jsonld-size=”200000″
>
/* SD Ultimate Pro – Client-side injector + server hooks
– هدف: تولید JSON-LD کامل، دریافت/اعتبارسنجی JSON-LD امضا شده از سرور، proxy امن قیمت/موجودی، embeddings hook، telemetry، resource hints
– نکته امنیتی: امضای JSON-LD باید توسط سرور انجام شود؛ این اسکریپت فقط اعتبارسنجی را با کلید عمومی انجام میدهد.
*/
(function(){
‘use strict’;
try{
const root = document.getElementById(‘sd-ultimate-pro’);
if(!root) return;
const d = root.dataset;
// ———- Helpers ———-
const safeParse = s => { try{ return JSON.parse(s); }catch(e){ return null; } };
const pick = (k, def=”) => (d[k] !== undefined ? d[k] : def);
const domain = (pick(‘domain’) || window.location.origin).replace(//$/,”);
const pageUrl = pick(‘url’) || domain;
const name = pick(‘name’) || document.title || ‘Service’;
const desc = pick(‘desc’) || ”;
const images = safeParse(d.images) || [ pick(‘image’) || (domain + ‘/assets/default.jpg’) ];
const imgW = parseInt(pick(‘imageWidth’) || pick(‘image-width’) || 1200,10);
const imgH = parseInt(pick(‘imageHeight’) || pick(‘image-height’) || 800,10);
const sku = pick(‘sku’) || ”;
const gtin = pick(‘gtin’) || ”;
const brand = pick(‘brand’) || ”;
const category = pick(‘category’) || ”;
const priceStatic = pick(‘price’) || ”;
const currency = pick(‘currency’) || ‘USD’;
const priceValidUntil = pick(‘priceValidUntil’) || ”;
const availabilityStatic = pick(‘availability’) || ‘Online’;
const faq = safeParse(d.faq) || [];
const qa = safeParse(d.qa) || [];
const reviews = safeParse(d.reviews) || [];
const video = safeParse(d.video) || {};
const tools = safeParse(d.tools) || [];
const hreflangMap = safeParse(d.hreflang) || {};
const priceApi = pick(‘priceApi’) || pick(‘price-api’) || ”;
const inventoryApi = pick(‘inventoryApi’) || pick(‘inventory-api’) || ”;
const signedJsonLdApi = pick(‘signedJsonldApi’) || pick(‘signed-jsonld-api’) || pick(‘data-signed-jsonld-api’) || pick(‘signed-jsonld-api’) || pick(‘signed-jsonld-api’);
const publicKeyPem = pick(‘publicKeyPem’) || pick(‘public-key-pem’) || ”;
const embeddingsEndpoint = pick(’embeddingsEndpoint’) || pick(’embeddings-endpoint’) || ”;
const telemetryEndpoint = pick(‘telemetryEndpoint’) || pick(‘telemetry-endpoint’) || ”;
const disableTelemetry = (pick(‘disableTelemetry’) === ‘true’);
const disableEmbeddings = (pick(‘disableEmbeddings’) === ‘true’);
const disableSignedCheck = (pick(‘disableSignedCheck’) === ‘true’);
const maxJsonLdSize = parseInt(pick(‘maxJsonldSize’) || pick(‘max-jsonld-size’) || 200000, 10);
// sanitize strings lightly
const sanitize = s => (typeof s === ‘string’ ? s.replace(/[u0000-u001F]/g,”).trim() : s);
// fetch with timeout and JSON parse
const fetchJson = (url, opts={}, timeout=5000) => {
return new Promise((resolve,reject)=>{
const timer = setTimeout(()=> reject(new Error(‘timeout’)), timeout);
fetch(url, opts).then(r=>{ clearTimeout(timer); if(!r.ok) return reject(new Error(‘http ‘+r.status)); return r.json(); }).then(resolve).catch(reject);
});
};
// local cache helper
const cacheGet = (k) => { try{ const s = localStorage.getItem(k); if(!s) return null; const p = JSON.parse(s); if(p.exp && Date.now()>p.exp){ localStorage.removeItem(k); return null; } return p.v; }catch(e){ return null; } };
const cacheSet = (k,v,ttl=300000) => { try{ localStorage.setItem(k, JSON.stringify({v:v, exp: Date.now()+ttl})); }catch(e){} };
// telemetry send (non-blocking)
const sendTelemetry = (evt, payload) => {
if(disableTelemetry) return;
try{
const body = {event: evt, payload: payload, ts: new Date().toISOString(), page: pageUrl, sku: sku};
// push to dataLayer if exists
if(window.dataLayer && Array.isArray(window.dataLayer)) window.dataLayer.push(Object.assign({event: ‘sd_ultimate_’+evt}, payload || {}));
// fire custom event
window.dispatchEvent(new CustomEvent(‘sd_ultimate_event’, {detail: body}));
// try to POST to telemetry endpoint (fire-and-forget)
if(telemetryEndpoint){
navigator.sendBeacon ? navigator.sendBeacon(telemetryEndpoint, JSON.stringify(body)) : fetch(telemetryEndpoint, {method:’POST’,headers:{‘Content-Type’:’application/json’},body:JSON.stringify(body)}).catch(()=>{});
}
}catch(e){}
};
// resource hints: preconnect, dns-prefetch, preload image
(function resourceHints(){
try{
const hosts = new Set([new URL(domain).host]);
images.forEach(u=>{ try{ hosts.add(new URL(u).host); }catch(e){} });
if(video && video.url) try{ hosts.add(new URL(video.url).host); }catch(e){}
hosts.forEach(h=>{
if(!document.head.querySelector(‘link[rel=”preconnect”][href*=”‘+h+'”]’)){
const l = document.createElement(‘link’); l.rel=’preconnect’; l.href = location.protocol + ‘//’ + h; l.crossOrigin = ”; document.head.appendChild(l);
}
if(!document.head.querySelector(‘link[rel=”dns-prefetch”][href*=”‘+h+'”]’)){
const l2 = document.createElement(‘link’); l2.rel=’dns-prefetch’; l2.href = location.protocol + ‘//’ + h; document.head.appendChild(l2);
}
});
if(images[0] && !document.head.querySelector(‘link[rel=”preload”][href=”‘+images[0]+'”]’)){
const pl = document.createElement(‘link’); pl.rel=’preload’; pl.as=’image’; pl.href = images[0]; document.head.appendChild(pl);
}
}catch(e){}
})();
// canonical
if(!document.querySelector(‘link[rel=”canonical”]’)){
const l = document.createElement(‘link’); l.rel=’canonical’; l.href = pageUrl; document.head.appendChild(l);
}
// hreflang
(function addHreflang(){
if(hreflangMap && typeof hreflangMap === ‘object’){
Object.keys(hreflangMap).forEach(lang=>{
const href = hreflangMap[lang];
if(href && !document.head.querySelector(‘link[rel=”alternate”][hreflang=”‘+lang+'”]’)){
const a = document.createElement(‘link’); a.rel=’alternate’; a.hreflang = lang; a.href = href; document.head.appendChild(a);
}
});
}
})();
// OG/Twitter
(function addSocialMeta(){
const add = (sel, tag, attrs) => { if(!document.head.querySelector(sel)){ const e = document.createElement(tag); Object.keys(attrs).forEach(k=> e.setAttribute(k, attrs[k])); document.head.appendChild(e); } };
add(‘meta[property=”og:type”]’,’meta’,{property:’og:type’,content:’product’});
add(‘meta[property=”og:title”]’,’meta’,{property:’og:title’,content:sanitize(name)});
add(‘meta[property=”og:description”]’,’meta’,{property:’og:description’,content:sanitize(desc)});
add(‘meta[property=”og:image”]’,’meta’,{property:’og:image’,content:images[0]});
add(‘meta[name=”twitter:card”]’,’meta’,{name:’twitter:card’,content:’summary_large_image’});
add(‘meta[name=”twitter:title”]’,’meta’,{name:’twitter:title’,content:sanitize(name)});
add(‘meta[name=”twitter:description”]’,’meta’,{name:’twitter:description’,content:sanitize(desc)});
add(‘meta[name=”twitter:image”]’,’meta’,{name:’twitter:image’,content:images[0]});
})();
// ———- Build base JSON-LD graph (client fallback) ———-
const graph = [];
graph.push({
“@type”:”Organization”,
“@id”: domain + “/#org”,
“name”: sanitize(brand) || “Rointan”,
“url”: domain,
“logo”: domain + “/logo.png”
});
graph.push({
“@type”:”WebSite”,
“@id”: domain + “/#website”,
“url”: domain,
“name”: sanitize(brand) || sanitize(name),
“potentialAction”: {“@type”:”SearchAction”,”target”: domain + “/search?q={search_term_string}”,”query-input”:”required name=search_term_string”}
});
// Service/Product entity
const product = {
“@type”:”Product”,
“@id”: pageUrl + “#product”,
“name”: sanitize(name),
“description”: sanitize(desc),
“image”: images.map(u=>({“@type”:”ImageObject”,”url”:u,”width”:imgW,”height”:imgH})),
“sku”: sanitize(sku),
“brand”: {“@type”:”Brand”,”name”: sanitize(brand)},
“category”: sanitize(category),
“offers”: [],
“mainEntityOfPage”: {“@type”:”WebPage”,”@id”: pageUrl}
};
if(gtin) product.gtin13 = sanitize(gtin);
// primary static offer
if(priceStatic){
product.offers.push({
“@type”:”Offer”,
“url”: pageUrl,
“priceCurrency”: currency,
“price”: priceStatic,
“priceValidUntil”: priceValidUntil || undefined,
“availability”: “https://schema.org/” + (availabilityStatic || “Online”),
“itemCondition”: “https://schema.org/NewCondition”,
“seller”: {“@type”:”Organization”,”name”: sanitize(brand)}
});
}
// tools as SoftwareApplication
if(Array.isArray(tools) && tools.length){
tools.forEach(t=>{
graph.push({
“@type”:”SoftwareApplication”,
“@id”: (t.url || pageUrl) + “#tool”,
“name”: sanitize(t.name || t.type || “Tool”),
“description”: sanitize(t.description || “”),
“applicationCategory”: “HealthApplication”,
“url”: t.url || pageUrl
});
});
}
// VideoObject
if(video && video.url){
const v = {
“@type”:”VideoObject”,
“name”: sanitize(name) + ” – معرفی”,
“description”: sanitize(desc),
“thumbnailUrl”: video.thumbnail || images[0],
“uploadDate”: video.uploadDate || undefined,
“duration”: video.duration || undefined,
“contentUrl”: video.url
};
// اگر transcript یک URL است، آن را به صورت لینک قرار بده؛ اگر متن است، درج کن
if(video.transcript){
v.transcript = video.transcript;
}
graph.push(v);
}
// FAQ and Q&A
if(Array.isArray(faq) && faq.length){
const faqEntity = {“@type”:”FAQPage”,”mainEntity”:[]};
faq.forEach(item=>{ if(item.q && item.a) faqEntity.mainEntity.push({“@type”:”Question”,”name”:sanitize(item.q),”acceptedAnswer”:{“@type”:”Answer”,”text”:sanitize(item.a)}}); });
if(faqEntity.mainEntity.length) graph.push(faqEntity);
}
if(Array.isArray(qa) && qa.length){
const qlist = qa.map(q=>{ const obj = {“@type”:”Question”,”name”:sanitize(q.q),”acceptedAnswer”:{“@type”:”Answer”,”text”:sanitize(q.a)}}; if(q.author) obj.author = {“@type”:”Person”,”name”:sanitize(q.author)}; return obj; });
if(qlist.length) graph.push({“@type”:”FAQPage”,”mainEntity”: qlist});
}
// Reviews -> Product node with aggregateRating
if(Array.isArray(reviews) && reviews.length){
const revs = reviews.map(r=>({ “@type”:”Review”, “author”:{“@type”:”Person”,”name”:sanitize(r.author||’کاربر’)}, “datePublished”: r.date || new Date().toISOString().split(‘T’)[0], “reviewBody”: sanitize(r.body||”), “reviewRating”: {“@type”:”Rating”,”ratingValue”: String(r.rating || 5)} }));
product.review = revs;
const sum = revs.reduce((s,r)=> s + (Number(r.reviewRating.ratingValue)||0), 0);
product.aggregateRating = {“@type”:”AggregateRating”,”ratingValue”: (sum/revs.length).toFixed(1),”reviewCount”: revs.length};
}
// Breadcrumb
graph.push({
“@type”:”BreadcrumbList”,
“itemListElement”:[
{“@type”:”ListItem”,”position”:1,”name”:”خانه”,”item”:domain},
{“@type”:”ListItem”,”position”:2,”name”:category,”item”: domain + ‘/category/’ + encodeURIComponent(category || ”)},
{“@type”:”ListItem”,”position”:3,”name”:sanitize(name),”item”: pageUrl}
]
});
// Speakable
graph.push({
“@type”:”WebPage”,
“@id”: pageUrl + “#webpage”,
“url”: pageUrl,
“name”: sanitize(name),
“speakable”: {“@type”:”SpeakableSpecification”,”xpath”:[“/html/head/title”,”/html/body//h1″]}
});
// push product last (so it can include reviews)
graph.push(product);
// ———- Utility: import PEM public key to CryptoKey ———-
async function importPublicKey(pem){
try{
if(!pem) return null;
// strip header/footer
const b64 = pem.replace(/—–BEGIN PUBLIC KEY—–/,”).replace(/—–END PUBLIC KEY—–/,”).replace(/s+/g,”);
const raw = Uint8Array.from(atob(b64), c=>c.charCodeAt(0));
return await crypto.subtle.importKey(‘spki’, raw.buffer, {name:’RSASSA-PKCS1-v1_5′, hash:’SHA-256′}, false, [‘verify’]);
}catch(e){ return null; }
}
// verify signature (server should return base64 signature of JSON-LD)
async function verifySignature(publicKeyPem, messageStr, signatureB64){
try{
if(!publicKeyPem || !signatureB64) return false;
const key = await importPublicKey(publicKeyPem);
if(!key) return false;
const enc = new TextEncoder().encode(messageStr);
const sig = Uint8Array.from(atob(signatureB64), c=>c.charCodeAt(0));
return await crypto.subtle.verify({name:’RSASSA-PKCS1-v1_5′}, key, sig.buffer, enc);
}catch(e){ return false; }
}
// ———- Option A: try to fetch signed JSON-LD from server (preferred for SEO) ———-
async function fetchSignedJsonLd(){
if(!signedJsonLdApi) return null;
try{
const cacheKey = ‘sd_signed_jsonld_’ + (sku || btoa(pageUrl).slice(0,12));
const cached = cacheGet(cacheKey);
if(cached) return cached;
const resp = await fetch(signedJsonLdApi, {method:’GET’, credentials:’same-origin’});
if(!resp.ok) throw new Error(‘http ‘+resp.status);
// server should return JSON body { jsonld: {…}, signature: “base64″ } or raw JSON-LD with header X-SD-Signature
const contentType = resp.headers.get(‘content-type’) || ”;
let payload = null;
if(contentType.includes(‘application/json’)){
payload = await resp.json();
if(payload && payload.jsonld){
const jsonStr = JSON.stringify(payload.jsonld);
const signature = payload.signature || resp.headers.get(‘x-sd-signature’) || null;
if(!disableSignedCheck && publicKeyPem && signature){
const ok = await verifySignature(publicKeyPem, jsonStr, signature);
if(!ok) { sendTelemetry(‘signed_check_failed’, {url: pageUrl}); return null; }
}
cacheSet(cacheKey, payload.jsonld, 600000);
return payload.jsonld;
} else {
// maybe server returned raw JSON-LD
cacheSet(cacheKey, payload, 600000);
return payload;
}
} else {
// fallback: try to parse text
const text = await resp.text();
try{ const parsed = JSON.parse(text); cacheSet(cacheKey, parsed, 600000); return parsed; }catch(e){ return null; }
}
}catch(e){
sendTelemetry(‘signed_fetch_error’, {error: String(e), url: signedJsonLdApi});
return null;
}
}
// ———- Dynamic price/inventory via server proxy (recommended) ———-
async function fetchDynamicData(){
const result = { price: priceStatic, availability: availabilityStatic, inventory: null };
try{
if(priceApi){
const cacheKey = ‘sd_price_’+(sku || pageUrl);
const cached = cacheGet(cacheKey);
if(cached) result.price = cached.price;
else {
const res = await fetchJson(priceApi, {}, 4000).catch(()=>null);
if(res && (res.price || res.price === 0)){ result.price = String(res.price); cacheSet(cacheKey, {price: result.price}, 300000); sendTelemetry(‘price_ok’,{price: result.price}); }
}
}
}catch(e){ sendTelemetry(‘price_error’,{error:String(e)}); }
try{
if(inventoryApi){
const cacheKey = ‘sd_inv_’+(sku || pageUrl);
const cached = cacheGet(cacheKey);
if(cached){ result.inventory = cached.inventory; result.availability = cached.availability || result.availability; }
else {
const res = await fetchJson(inventoryApi, {}, 4000).catch(()=>null);
if(res && (res.inventory !== undefined)){ result.inventory = res.inventory; result.availability = res.inventory>0 ? ‘InStock’ : ‘OutOfStock’; cacheSet(cacheKey, {inventory: res.inventory, availability: result.availability}, 300000); sendTelemetry(‘inventory_ok’,{inventory: res.inventory}); }
}
}
}catch(e){ sendTelemetry(‘inventory_error’,{error:String(e)}); }
return result;
}
// ———- Embeddings hook: send payload to server for vectorization ———-
async function sendEmbeddings(payload){
if(disableEmbeddings || !embeddingsEndpoint) return;
try{
// non-blocking, with navigator.sendBeacon fallback
const body = {id: payload.id, title: payload.title, description: payload.description, faq: payload.faq, reviews: payload.reviews, transcript: payload.transcript, url: pageUrl, ts: new Date().toISOString()};
if(navigator.sendBeacon){
navigator.sendBeacon(embeddingsEndpoint, JSON.stringify(body));
} else {
fetch(embeddingsEndpoint, {method:’POST’,headers:{‘Content-Type’:’application/json’},body:JSON.stringify(body)}).catch(()=>{});
}
sendTelemetry(’embeddings_sent’,{id: payload.id});
}catch(e){ sendTelemetry(’embeddings_error’,{error:String(e)}); }
}
// ———- Final assembly: prefer server-signed JSON-LD, else client-built ———-
(async function assembleAndInject(){
sendTelemetry(‘start’,{sku: sku});
// try signed JSON-LD from server
let finalJsonLd = null;
if(!disableSignedCheck && signedJsonLdApi){
const signed = await fetchSignedJsonLd();
if(signed) finalJsonLd = signed;
}
// if no signed JSON-LD, build client JSON-LD and enrich with dynamic data
if(!finalJsonLd){
const dyn = await fetchDynamicData();
// update offers with dynamic price/availability
if(dyn.price){
product.offers = product.offers.map(o => Object.assign({}, o, {“price”: dyn.price, “priceCurrency”: currency}));
}
if(dyn.availability){
product.offers = product.offers.map(o => Object.assign({}, o, {“availability”: “https://schema.org/” + dyn.availability}));
}
if(dyn.inventory !== null) product.inventoryLevel = {“@type”:”QuantitativeValue”,”value”: Number(dyn.inventory)};
// push product at end (already pushed earlier) – ensure graph contains product
// create final object
finalJsonLd = {“@context”:”https://schema.org”,”@graph”: graph};
}
// size guard
const jsonStr = JSON.stringify(finalJsonLd);
if(jsonStr.length > maxJsonLdSize){
sendTelemetry(‘jsonld_too_large’,{size: jsonStr.length, limit: maxJsonLdSize});
// if too large, try to strip heavy fields (transcript, reviews)
try{
if(finalJsonLd[‘@graph’]){
finalJsonLd[‘@graph’].forEach(n=>{
if(n[‘@type’] === ‘VideoObject’ && n.transcript && typeof n.transcript === ‘string’ && n.transcript.length > 2000) n.transcript = n.transcript.slice(0,2000) + ‘…’;
if(n[‘@type’] === ‘Product’ && n.review && n.review.length > 10) n.review = n.review.slice(0,10);
});
}
}catch(e){}
}
// inject JSON-LD into DOM (if not already present)
try{
const existing = document.querySelector(‘script[type=”application/ld+json”][data-sd=”ultimate-pro”]’);
if(existing) existing.remove();
const s = document.createElement(‘script’); s.type = ‘application/ld+json’; s.setAttribute(‘data-sd’,’ultimate-pro’); s.text = JSON.stringify(finalJsonLd, null, 2);
document.body.appendChild(s);
// expose for server-side capture
window.__sd_ultimate_jsonld = JSON.stringify(finalJsonLd);
sendTelemetry(‘injected’,{sku: sku, size: window.__sd_ultimate_jsonld.length});
}catch(e){ sendTelemetry(‘inject_error’,{error:String(e)}); }
// prepare embeddings payload and send to server
try{
const embedPayload = { id: sku || pageUrl, title: sanitize(name), description: sanitize(desc), faq: faq, reviews: reviews, transcript: (video && video.transcript) ? video.transcript : ” };
await sendEmbeddings(embedPayload);
}catch(e){ sendTelemetry(’embeddings_prepare_error’,{error:String(e)}); }
})();
// expose a small API for debugging and server capture
window.SD_ULTIMATE_PRO = {
getJsonLd: () => window.__sd_ultimate_jsonld || null,
refreshDynamic: async () => {
const dyn = await fetchDynamicData();
sendTelemetry(‘manual_refresh’,{dyn});
return dyn;
},
sendTelemetryEvent: (evt, payload) => sendTelemetry(evt, payload)
};
// final console info
if(window.console && console.info) console.info(‘SD Ultimate Pro initialized for’, name, pageUrl);
}catch(err){
try{ if(window.console) console.error(‘SD Ultimate Pro error’, err); }catch(e){}
}
})();

0دیدگاه