Product Description
(function () {
"use strict";
// VEDIK GRAINS - CHEESE MAKHANA SEO
// This code runs ONLY on the specified product page.
const PRODUCT_PATH =
"/catalogue/O8ZDn8Nb/VHScyGtH";
const PRODUCT_URL =
"https://vedikgrains.com/Vedik-Grains-Roasted-Cheese-Makhana-Cheese-Flavoured-Fox-Nuts-Roasted/catalogue/O8ZDn8Nb/VHScyGtH";
if (!window.location.pathname.includes(PRODUCT_PATH)) {
return;
}
function initVedikSEO() {
// 1. DISPLAY COMPACT CUSTOMER HELP
const helpBox =
document.getElementById("vg-cheese-help");
if (helpBox) {
helpBox.hidden = false;
}
// 2. PRODUCT-SPECIFIC WHATSAPP ENQUIRY
const whatsapp =
document.getElementById("vg-cheese-whatsapp");
if (whatsapp) {
const message =
"Hello Vedik Grains! I have a question about " +
"Roasted Cheese Makhana 60g. " +
window.location.href;
whatsapp.href =
"https://wa.me/918053732337?text=" +
encodeURIComponent(message);
}
// 3. BROWSER-RENDERED SEO TITLE
document.title =
"Buy Roasted Cheese Makhana 60g Online | Vedik Grains";
// 4. BROWSER-RENDERED META DESCRIPTION
const description =
"Shop Vedik Grains Roasted Cheese Makhana 60g. " +
"Enjoy crunchy, savoury cheese-flavoured fox nuts. " +
"Ready to eat. Buy online for Rs. 299.";
let metaDescription =
document.querySelector('meta[name="description"]');
if (!metaDescription) {
metaDescription = document.createElement("meta");
metaDescription.name = "description";
document.head.appendChild(metaDescription);
}
metaDescription.content = description;
// 5. CHECK EXISTING PRODUCT STRUCTURED DATA
function containsProduct(data) {
if (!data || typeof data !== "object") {
return false;
}
if (Array.isArray(data)) {
return data.some(containsProduct);
}
const type = data["@type"];
if (
type === "Product" ||
(Array.isArray(type) && type.includes("Product"))
) {
return true;
}
return Object.values(data).some(containsProduct);
}
function existingProductSchema() {
if (
document.querySelector(
'[itemscope][itemtype*="schema.org/Product"],' +
'[typeof~="Product"]'
)
) {
return true;
}
const scripts = document.querySelectorAll(
'script[type="application/ld+json"]'
);
for (const script of scripts) {
try {
const json = JSON.parse(script.textContent);
if (containsProduct(json)) {
return true;
}
} catch (error) {
// Ignore unrelated invalid JSON-LD.
}
}
return false;
}
// Do not add a second Product schema.
if (existingProductSchema()) {
console.info(
"Vedik Grains: Existing Product schema detected."
);
return;
}
// 6. VERIFY CURRENT VISIBLE SELLING PRICE
// This avoids publishing an old price if it changes.
const pageText = document.body.innerText || "";
const titlePosition =
pageText.indexOf("Roasted Cheese Makhana");
if (titlePosition < 0) {
return;
}
const priceArea = pageText.slice(
titlePosition,
titlePosition + 350
);
const priceMatch =
priceArea.match(/₹\s*([\d,]+)(?:\.\d{1,2})?/);
if (!priceMatch) {
console.info(
"Vedik Grains: Selling price not verified."
);
return;
}
const displayedPrice = Number(
priceMatch[1].replace(/,/g, "")
);
if (displayedPrice !== 299) {
console.warn(
"Vedik Grains: Price mismatch. Schema skipped."
);
return;
}
// 7. PRODUCT + OFFER STRUCTURED DATA
const productSchema = {
"@context": "https://schema.org",
"@type": "Product",
"name":
"Vedik Grains Roasted Cheese Makhana 60g",
"description":
"Ready-to-eat roasted fox nuts with savoury " +
"cheese flavour and a light, crispy texture.",
"sku": "VG-MAK-CH-060",
"category": "Roasted Makhana",
"image": [
"https://d1311wbk6unapo.cloudfront.net/NushopCatalogue/tr%3Af-webp%2Cw-600%2Cfo-auto/6adca810713073e1edb0fdb0/cat_img/SNSHRV96MZ42VQQ9_1793016273055_wbyi9srejj7px0v.jpg"
],
"brand": {
"@type": "Brand",
"name": "Vedik Grains"
},
"weight": {
"@type": "QuantitativeValue",
"value": 60,
"unitCode": "GRM"
},
"offers": {
"@type": "Offer",
"url": PRODUCT_URL,
"priceCurrency": "INR",
"price": displayedPrice,
"itemCondition":
"https://schema.org/NewCondition",
"seller": {
"@type": "Organization",
"name": "Vedik Grains"
}
}
};
// 8. PREVENT DUPLICATE INJECTION
if (
document.getElementById("vg-cheese-product-schema")
) {
return;
}
const schemaScript =
document.createElement("script");
schemaScript.id = "vg-cheese-product-schema";
schemaScript.type = "application/ld+json";
schemaScript.textContent =
JSON.stringify(productSchema);
document.head.appendChild(schemaScript);
console.info(
"Vedik Grains: Product schema inserted."
);
}
if (document.readyState === "loading") {
document.addEventListener(
"DOMContentLoaded",
initVedikSEO,
{ once: true }
);
} else {
initVedikSEO();
}
})();