|
Tags: Blanking Manual revert |
| (11 intermediate revisions by the same user not shown) |
| Line 1: |
Line 1: |
| mw.loader.using('mediawiki.util', function () {
| |
|
| |
|
| if (mw.config.get('wgNamespaceNumber') !== 0) return;
| |
|
| |
| const infobox = document.querySelector('.infobox');
| |
| if (!infobox) return;
| |
|
| |
| const metaDesc =
| |
| document.querySelector('meta[name="description"]')?.content || "";
| |
|
| |
| const pageUrl = location.href;
| |
| const pageTitle = mw.config.get('wgTitle');
| |
|
| |
| let schema = null;
| |
|
| |
| // COMPANY (Infobox company)
| |
| if (infobox.innerHTML.toLowerCase().includes('industry')
| |
| && infobox.innerHTML.toLowerCase().includes('founded')) {
| |
|
| |
| schema = {
| |
| "@context": "https://schema.org",
| |
| "@type": "Organization",
| |
| "name": pageTitle,
| |
| "url": pageUrl,
| |
| "description": metaDesc
| |
| };
| |
|
| |
| const logo = infobox.querySelector('img')?.src;
| |
| if (logo) schema.logo = logo;
| |
| }
| |
|
| |
| // PERSON (Infobox person)
| |
| else if (infobox.innerHTML.toLowerCase().includes('born')) {
| |
|
| |
| schema = {
| |
| "@context": "https://schema.org",
| |
| "@type": "Person",
| |
| "name": pageTitle,
| |
| "url": pageUrl,
| |
| "description": metaDesc
| |
| };
| |
|
| |
| const image = infobox.querySelector('img')?.src;
| |
| if (image) schema.image = image;
| |
| }
| |
|
| |
| if (!schema) return;
| |
|
| |
| const script = document.createElement('script');
| |
| script.type = 'application/ld+json';
| |
| script.text = JSON.stringify(schema);
| |
| document.head.appendChild(script);
| |
|
| |
| });
| |