ميدياويكي:Common.js

من قصص عارف

ملاحظة: بعد النشر، أنت قد تحتاج إلى إفراغ الكاش الخاص بمتصفحك لرؤية التغييرات.

  • فايرفوكس / سافاري: أمسك Shift أثناء ضغط Reload، أو اضغط على إما Ctrl-F5 أو Ctrl-R (⌘-R على ماك)
  • جوجل كروم: اضغط Ctrl-Shift-R (⌘-Shift-R على ماك)
  • إنترنت إكسبلورر/إيدج: أمسك Ctrl أثناء ضغط Refresh، أو اضغط Ctrl-F5
  • أوبرا: اضغط Ctrl-F5.
mw.loader.using('mediawiki.util').then(function() {
    var pageTitle = mw.config.get('wgPageName').replace(/_/g, ' '); // Get page title and replace underscores with spaces

    var emailButton = $('<button>')
        .text('تواصل معنا')
        .css({
            position: 'fixed',
            bottom: '20px',
            right: '20px',
            'background-color': '#3366CC',
            color: '#FFFFFF',
            padding: '10px 20px',
            'border-radius': '5px',
            'font-size': '16px',
            border: 'none',
            cursor: 'pointer',
            'z-index': 1000
        })
        .click(function() {
            window.open('mailto:info@3arf.org?subject=' + encodeURIComponent(pageTitle), '_blank');
        });

    $('body').append(emailButton);
});

$(document).ready(function() {
    var pageTitle = mw.config.get('wgPageName').replace(/_/g, ' '); // Get page title and replace underscores with spaces
    
    $('body').append('<button class="email-button" onclick="window.location.href=\'mailto:info@3arf.org?subject=' + encodeURIComponent(pageTitle) + '\'">تواصل معنا</button>');
});




mw.hook('wikipage.content').add(function ($content) {
    // Target all anchor links <a> with href starting with "/stories/image-proxy.php?url=https://fngml.com"
    $content.find('a').each(function () {
        const link = $(this);
        const href = link.attr('href');
        
        if (href && href.startsWith('/stories/image-proxy.php?url=https://fngml.com')) {
            // Rewrite the link to use the proxy script
            const newHref = `/image-proxy.php?url=${encodeURIComponent(href)}`;
            link.attr('href', newHref);
        }
    });

    // Target all image sources <img> with src starting with "/stories/image-proxy.php?url=https://fngml.com"
    $content.find('img').each(function () {
        const img = $(this);
        const src = img.attr('src');

        if (src && src.startsWith('/stories/image-proxy.php?url=https://fngml.com')) {
            // Rewrite the src to use the proxy script
            const newSrc = `/image-proxy.php?url=${encodeURIComponent(src)}`;
            img.attr('src', newSrc);
        }
    });
});