Skip to content

Instantly share code, notes, and snippets.

@KristianP26
Last active August 13, 2025 09:22
Show Gist options
  • Select an option

  • Save KristianP26/46cf9a12a8db1dc2127b6db26b9f570a to your computer and use it in GitHub Desktop.

Select an option

Save KristianP26/46cf9a12a8db1dc2127b6db26b9f570a to your computer and use it in GitHub Desktop.
This is Violentmonkey script which will show you product MPN next to its name on Alza.
// ==UserScript==
// @name Alza.cz MPN
// @namespace https://gist.github.com/KristianP26/46cf9a12a8db1dc2127b6db26b9f570a
// @version 1.0
// @description Extract MPN and Add New H1
// @author Kristian Partl
// @match https://www.alza.cz/*
// @match https://www.alza.sk/*
// @grant none
// ==/UserScript==
(function() {
'use strict';
window.addEventListener('load', function() {
var scripts = document.querySelectorAll('script[type="application/ld+json"]');
scripts.forEach(function(script) {
try {
var jsonData = JSON.parse(script.textContent);
if (jsonData["@type"] === "Product") {
var mpn = jsonData.mpn;
var h1 = document.querySelector('h1');
if (h1 && mpn) {
var br = document.createElement('br');
var newH1 = document.createElement('h1');
newH1.textContent = `MPN: ${mpn}`;
h1.parentNode.insertBefore(br, h1.nextSibling);
h1.parentNode.insertBefore(newH1, br.nextSibling);
}
}
} catch (e) {
console.log('Error parsing JSON:', e);
}
});
});
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment