ผู้ใช้:Patsagorn Y./Tools/mobsmtcom.js

จากวิกิพีเดีย สารานุกรมเสรี

หมายเหตุ: หลังเผยแพร่ คุณอาจต้องล้างแคชเว็บเบราว์เซอร์ของคุณเพื่อดูการเปลี่ยนแปลง

  • ไฟร์ฟอกซ์ / ซาฟารี: กด Shift ค้างขณะคลิก Reload หรือกด Ctrl-F5 หรือ Ctrl-R (⌘-R บนแมค)
  • กูเกิล โครม: กด Ctrl-Shift-R (⌘-Shift-R บนแมค)
  • อินเทอร์เน็ตเอกซ์พลอเรอร์ และ Edge: กด Ctrl ค้างขณะคลิก Refresh หรือกด Ctrl-F5
  • โอเปร่า: กด Ctrl-F5
// คัดลอกแนวคิดจากคอมมอนส์ 
// <nowiki>
$.when(mw.loader.using(['oojs-ui-core', 'oojs-ui.styles.icons-interactions'])).then(function() {
    if (mw.config.get('wgNamespaceNumber') == 6 && mw.config.get('wgAction') === "view" && document.getElementById('file') && mw.config.get('skin') === 'minerva') {
        var title = mw.config.get('wgPageName'), // ชื่อไฟล์
            articlebaseurl = window.location.protocol + '\/\/' + window.location.hostname + '/wiki/';
        license = document.getElementsByClassName('licensetpl_short')[0].innerHTML.toLowerCase().slice(0, 8), // สัญญาอนุญาตที่เครื่องอ่านได้
            acceptedLicense = ['cc0', 'cc-by', 'cc-by-sa']; //รายการสัญญาอนุญาตที่คอมมอนส์รับได้
        if (acceptedLicense.indexOf(license) === -1 || license !== 'Public domain' ) return; // ดูเหมือนว่าไฟล์จะรับไม่ได้
        var userGroups = mw.config.get('wgUserGroups');
        if (mw.config.get('wgUserGroups').indexOf('autoconfirmed') === -1) return; //เผื่อไม่ใช่ยืนยันอัตโนมัติ
        var pageURL = articlebaseurl + title,
            randomURL = 'https://randomincategory.toolforge.org/%E0%B8%AA%E0%B8%B7%E0%B9%88%E0%B8%AD%E0%B9%80%E0%B8%AA%E0%B8%A3%E0%B8%B5%E0%B8%97%E0%B8%B1%E0%B9%89%E0%B8%87%E0%B8%AB%E0%B8%A1%E0%B8%94?server=//th.wikipedia.org&type=file', // [[หมวดหมู่:สื่อเสรีทั้งหมด]]
            target = 'https:\/\/commons.wikimedia.org/wiki/Special:ImportFile?clientUrl=' + encodeURIComponent(pageURL) + '&importSource=FileExporter',
            moveimage = new OO.ui.ButtonWidget({
                label: 'ย้ายไฟล์ไปคอมมอนส์',
                href: target,
                icon: 'logoWikimediaCommons',
                target: '_blank',
                title: 'ไฟล์นี้ดูเหมือนว่าจะมีสัญญาอนุญาตที่เข้ากับคอมมอนส์ กดที่นี่เพื่อย้าย',
                flags: [
		'primary',
                'progressive'
                ]
            }),
            morerandom = new OO.ui.ButtonWidget({
                label: 'สุ่มต่อ',
                href: randomURL,
                target: '_blank',
                title: 'สุ่มดูในหมวดหมู่ไฟล์เสรีทั้งหมดต่อ',
                flags: [
                'progressive'
                ]
            });
        $("#siteNotice").append(moveimage.$element, morerandom.$element); //แทรก
    }
});
// </nowiki>