"മീഡിയവിക്കി:Common.js" എന്ന താളിന്റെ പതിപ്പുകൾ തമ്മിലുള്ള വ്യത്യാസം

No edit summary
No edit summary
വരി 3: വരി 3:
   ============================================================ */
   ============================================================ */
mw.hook('wikipage.content').add(function () {
mw.hook('wikipage.content').add(function () {
     var images = document.querySelectorAll('img');
     function replaceOSMMarkers(root) {
    for (var i = 0; i < images.length; i++) {
        var images = root.querySelectorAll('img[src*="tile.openstreetmap.org/v4/marker/"]');
        var img = images[i];
 
        if (
         images.forEach(function (img) {
            img.src &&
            img.src.startsWith('https://tile.openstreetmap.org/v4/marker/')
         ) {
             img.src = img.src.replace(
             img.src = img.src.replace(
                 'https://tile.openstreetmap.org/v4/marker/',
                 'https://tile.openstreetmap.org/v4/marker/',
                 'https://maps.wikimedia.org/v4/marker/'
                 'https://maps.wikimedia.org/v4/marker/'
             );
             );
         }
         });
     }
     }
    // Initial pass
    replaceOSMMarkers(document);
    // Watch for dynamically added images
    var observer = new MutationObserver(function (mutations) {
        mutations.forEach(function (mutation) {
            mutation.addedNodes.forEach(function (node) {
                if (node.nodeType === 1) {
                    replaceOSMMarkers(node);
                }
            });
        });
    });
    observer.observe(document.body, {
        childList: true,
        subtree: true
    });
});
});


/* ============================================================
/* ============================================================
"https://schoolwiki.in/മീഡിയവിക്കി:Common.js" എന്ന താളിൽനിന്ന് ശേഖരിച്ചത്