|
Tags: Blanking Manual revert |
| (18 intermediate revisions by the same user not shown) |
| Line 1: |
Line 1: |
| /* Any JavaScript here will be loaded for all users on every page load. */
| |
| mw.config.set('wgRawHtml', true);
| |
| mw.loader.using('mediawiki.util', function () {
| |
|
| |
|
| // Run only on content pages
| |
| if (mw.config.get('wgNamespaceNumber') !== 0) return;
| |
|
| |
| // Detect company pages by infobox
| |
| const infobox = document.querySelector('.infobox.company');
| |
| if (!infobox) return;
| |
|
| |
| // Extract values safely
| |
| const name =
| |
| infobox.querySelector('.fn')?.innerText ||
| |
| mw.config.get('wgTitle');
| |
|
| |
| const logoImg = infobox.querySelector('img');
| |
| const logo = logoImg ? logoImg.src : null;
| |
|
| |
| const description =
| |
| document.querySelector('meta[name="description"]')?.content || '';
| |
|
| |
| const schema = {
| |
| "@context": "https://schema.org",
| |
| "@type": "ProfilePage",
| |
| "mainEntity": {
| |
| "@type": "Organization",
| |
| "name": name,
| |
| "url": location.href,
| |
| "description": description,
| |
| "address": {
| |
| "@type": "PostalAddress",
| |
| "addressCountry": "IN"
| |
| }
| |
| }
| |
| };
| |
|
| |
| if (logo) {
| |
| schema.mainEntity.logo = logo;
| |
| }
| |
|
| |
| // Inject schema
| |
| const script = document.createElement('script');
| |
| script.type = 'application/ld+json';
| |
| script.text = JSON.stringify(schema);
| |
| document.head.appendChild(script);
| |
|
| |
| });
| |