مدیاویکی:Group-sysop.js

از ویکی‌پدیا، دانشنامهٔ آزاد

نکته: برای دیدن تغییرات، ممکن است نیاز باشد که حافظهٔ نهانی مرورگر خود را پس از انتشار پاک‌سازی کنید. گوگل کروم، فایرفاکس، مایکروسافت اج و سافاری: کلید Shift را نگه دارید و روی دکمهٔ Reload در نوار ابزار مرورگر کلیک کنید. برای آگاهی از جزئیات و نحوهٔ پاک‌سازی حافظهٔ نهانی سایر مرورگرها، صفحهٔ ویکی‌پدیا:میانگیر مرورگرتان را خالی کنید را ببینید.

/** Automatic deletion dropdown
 *******************************************************
 *
 *  Description: Looks for CSD/XFD/PROD templates on a page; if 
 *               one is present,picks up the deletion reason  that's  
 *               hidden on the template and tweaks the 'delete' tab 
 *               link to preload that deletion summary.
 *  Maintainers: Happy-melon
 */
$(function() {
    if (document.getElementById('ca-delete') && document.getElementById('delete-criterion')) {
        var link = document.getElementById('ca-delete').getElementsByTagName('A')[0];
        var reason = document.getElementById('delete-reason').innerHTML;
        link.setAttribute('href', link.getAttribute('href') + '&wpReason=' + reason);
    }


    /** Sensitive IP checker
     *******************************************************
     *
     *  Description: Blocking certain ranges is politically...
     *               sensitive, and must be reported to the 
     *               Foundation Communications Committee.
     *  Maintainers: east718
     */
    if (mw.config.get('wgCanonicalNamespace') == "Special" && mw.config.get('wgCanonicalSpecialPageName') == "Blockip") {
        ips = [
            [/\b63\.162\.143\.21\b/, '[[وزارت امنیت داخلی ایالات متحده آمریکا]]'],
            [/\b82\.148\.9(6\.68|7\.69)\b/, '[[قطر]]'],
            [/\b128\.183\.103\.97\b/, '[[ناسا]]'],
            [/\b(((2|5)?6|7|[12]1|2(2|8|9)|3(0|3)|55)\.([01]?\d\d?|2(5[0-5]|[0-4]\d))|130\.22)(\.([01]?\d\d?|2(5[0-5]|[0-4]\d))){2}\b/, '[[وزارت دفاع ایالات متحده آمریکا]]'],
            [/\b138\.16[23](\.([01]?\d\d?|2(5[0-5]|[0-4]\d))){2}\b/, '[[نیروی دریایی ایالات متحده آمریکا]]'],
            [/\b143\.2(2[89]|3[01])(\.([01]?\d\d?|2(5[0-5]|[0-4]\d))){2}\b/, '[[مجلس نمایندگان ایالات متحده آمریکا]]'],
            [/\b149\.101(\.([01]?\d\d?|2(5[0-5]|[0-4]\d))){2}\b/, '[[وزارت دادگستری ایالات متحده آمریکا]]'],
            [/\b156\.33(\.([01]?\d\d?|2(5[0-5]|[0-4]\d))){2}\b/, '[[مجلس سنای ایالات متحده آمریکا]]'],
            [/\b(162\.4[56]\.([01]?\d\d?|2(5[0-5]|[0-4]\d))|198\.81\.(128|129|1[3-8]\d|191))\.([01]?\d\d?|2(5[0-5]|[0-4]\d))\b/, '[[سیا]]'],
            [/\b192\.197\.(7[7-9]|8[0-6])\.([01]?\d\d?|2(5[0-5]|[0-4]\d))\b/, '[[دولت کانادا]]'],
            [/\b(194.60.\d[0-5]?)\.([01]?\d\d?|2(5[0-5]|[0-4]\d))\b/, '[[پارلمان بریتانیا]]'],
            [/\b66\.230\.(19[2-9]|2[0-3]\d)\.([01]?\d\d?|2(5[0-5]|[0-4]\d))\b/, '[[بنیاد ویکی‌مدیا]]']
        ];
        ip = document.getElementById('mw-bi-target').value;
        if (/\b(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\b/.test(ip)) {
            for (i = 0; i < ips.length; i++) {
                if (ip.match(ips[i][0])) {
                    jsMsg('<table><tr><td valign="center"><img src="//upload.wikimedia.org/wikipedia/commons/thumb/f/f7/Nuvola_apps_important.svg/48px-Nuvola_apps_important.svg.png" /></td><td valign="center">شما در حال بستن آی‌پی مهمی(' + ips[i][1].replace('[[', '<a href="//en.wikipedia.org/wiki/').replace('|', '">').replace(']]', '</a>') + ') هستید. لطفاً مطمئن شوید که از <a href="//meta.wikimedia.org/wiki/Communications_committee/Notifications" class="extiw" title="meta:Communications_committee/Notifications">خطرات</a> این کار برای <a href="//meta.wikimedia.org/wiki/Communications_committee" class="extiw" title="meta:Communications_committee">بنیاد ویکی‌مدیا</a> آگاهی دارید.</td></tr></table>');
                }
            }
        }
    }

    if (mw.config.get('wgCanonicalSpecialPageName') === 'Recentchanges') {
        // کاربر پالایهٔ خرابکاری در تغییرات اخیر برای مدیران پررنگ شود
        $('a.mw-userlink[title="کاربر:پالایهٔ خرابکاری"]').parent().css({
            'background-color': 'LemonChiffon',
            'font-weight': 'bold'
        });
        // واگردانی‌های محتمل برای کاربران مدیر (و واگردان) پررنگ شود
        $('a[title="ویکی‌پدیا:رمبو"]').parents('li').css({
            'font-weight': 'bold'
        });
    }

    if (mw.config.get('wgPageName') === 'الگو:از_میان_خبرها/پیش‌نویس' && mw.config.get('wgAction') === 'view') {
    	$('#firstHeading').append($('<div style="float: left; font-size: 50%"><span class="plainlinks noprint"><a target="_blank" class="external text" href="//fa.wikipedia.org/w/index.php?title=الگو:از_میان_خبرها/پیش‌نویس&withJS=MediaWiki:الگو:از_میان_خبرها/پیش‌نویس.js"><span class="mw-ui-button mw-ui-progressive">به‌روزرسانی صفحهٔ اصلی</span></a></span></div>'))
    }

    if (mw.config.get('wgNamespaceNumber') === 6 &&
        mw.config.get('wgAction') === 'view' &&
        $('#file').length !== 0) {
        	
        importScript('مدیاویکی:FairUseResize.js');

	    mw.util.addPortletLink(
	        'p-cactions',
	        'http://tineye.com/search?url=' + encodeURIComponent($('#file a')[0].href),
	        'Tineye',
	        'ca-tineye'
	    );
	    mw.util.addPortletLink(
	        'p-cactions',
	        'http://images.google.com/searchbyimage?image_url=' + encodeURIComponent($('#file a')[0].href),
	        'Google Images',
	        'ca-googleimage'
	    );
	
	    //ربات جایگزین‌کننده پیوند۱ به پیوند۲ در صورتی که در زمان انتقال دکمهٔ برجا گذاشتن تغییرمسیر خاموش باشد
	    if ($.inArray(mw.config.get('wgAction'), ['view', 'submit']) !== -1) {
	        $('#movepage button[type=submit]').click(function() { //اگر در حالت انتقال باشد
	            if ($("input[name='wpLeaveRedirect']:checkbox").is(":checked") !== true) { //اگر دکمهٔ برجا گذاشتن تغییرمسیر انتخاب شده‌بود
	                var OriginTitle = mw.config.get('wgTitle')
	                OriginTitle = OriginTitle.substring(12, OriginTitle.length) //صفحهٔ اصلی
	                var PNamespace = document.getElementsByClassName("oo-ui-dropdownWidget-handle")[0].getElementsByClassName("oo-ui-labelElement-label")[0].innerText
	                if (PNamespace !== '(مقاله)') {
	                    PNamespace = PNamespace + ':'
	                } else {
	                    PNamespace = ''
	                }
	                var TargetTitle = PNamespace + document.getElementsByClassName("oo-ui-inputWidget-input")[1].value
	                    //صفحهٔ هدف
	                var botpath = '//tools.wmflabs.org/rezabot/replacelink.php?title=' + OriginTitle + '---' + TargetTitle + '---انتقال بدون تغییرمسیر&user=کاربر:' + mw.config.get('wgUserName')
	                alert(botpath)
	                console.log(botpath);
	                $.get(botpath)
	            };
	        });
	    }
    }
});