MediaWiki:Common.js: Perbedaan antara revisi

Tidak ada ringkasan suntingan
Tanda: Suntingan perangkat seluler Suntingan peramban seluler
Tidak ada ringkasan suntingan
Tanda: Suntingan perangkat seluler Suntingan peramban seluler
Baris 353: Baris 353:


/* ==========================================================
/* ==========================================================
   🛡️ MIPPEDIA SHIELD: PROTEKSI HALAMAN SENSITIF (FULL CODE)
   🛡️ MIPPEDIA SHIELD v3.0 (Smart Bot Bypass)
   Hanya untuk Pengurus, Birokrat, dan Pengawas.
   Proteksi halaman untuk user, tapi tetap Open untuk Googlebot
   ========================================================== */
   ========================================================== */
$(document).ready(function() {
$(document).ready(function() {
      
      
     // 1. DAFTAR HALAMAN YANG MAU DIKUNCI
     // 1. DAFTAR HALAMAN YANG DIKUNCI
    // Tambah atau hapus di dalam kurung siku ini. Gunakan koma sebagai pemisah.
     var protectedPages = [
     var protectedPages = [
         "MediaWiki:",
         "MediaWiki:",  
         "Istimewa:Versi"
         "Mippedia:Privasi",
        "Mippedia:Kebijakan",
        "Spesial:Versi",
        "Mippedia:Ketentuan_penggunaan"
     ];
     ];


     // 2. CEK STATUS USER & HALAMAN
     // 2. DETEKSI BOT PENCARI (Google, Bing, Yahoo, dll)
    var userAgent = navigator.userAgent.toLowerCase();
    var isSearchBot = /googlebot|bingbot|yandexbot|duckduckbot|slurp|baiduspider|facebookexternalhit|twitterbot|rogerbot|linkedinbot|embedly|quora\ link\ preview|showyoubot|outbrain|pinterest\/0\.|bingpreview|slackbot|vkShare|W3C_Validator/.test(userAgent);
 
    // 3. CEK STATUS USER & HALAMAN
     var userGroups = mw.config.get('wgUserGroups') || [];
     var userGroups = mw.config.get('wgUserGroups') || [];
    // Daftar grup yang KEBAL proteksi (bisa akses halaman)
     var isStaff = userGroups.some(r => ["sysop", "bureaucrat", "steward", "interface-admin"].includes(r));
     var isStaff = userGroups.some(r => ["sysop", "bureaucrat", "steward", "interface-admin"].includes(r));
   
     var currentPage = mw.config.get('wgPageName');
     var currentPage = mw.config.get('wgPageName');
    // Cek apakah halaman saat ini masuk dalam daftar proteksi
     var shouldProtect = protectedPages.some(prefix => currentPage.startsWith(prefix.replace(/ /g, '_')));
     var shouldProtect = protectedPages.some(prefix => currentPage.startsWith(prefix.replace(/ /g, '_')));


     // 3. EKSEKUSI PROTEKSI (Hanya jika user BUKAN staff)
     // 4. EKSEKUSI PROTEKSI
     if (shouldProtect && !isStaff) {
    // Syarat kunci: Halaman sensitif AND Bukan Staff AND BUKAN Search Bot
     if (shouldProtect && !isStaff && !isSearchBot) {
          
          
        // Hapus total konten asli agar tidak bisa diintip/disunting
         $('body').addClass('mippedia-locked').html('');
         $('body').addClass('mippedia-locked').html('');


        // Inject CSS khusus untuk tampilan Mobile-Friendly & Auto-Center
         $('<style>').prop('type', 'text/css').html(`
         $('<style>').prop('type', 'text/css').html(`
             html, body {  
             html, body { margin: 0!important; padding: 0!important; height: 100%!important; width: 100%!important; overflow: hidden!important; background: #f8f9fa!important; }
                margin: 0 !important;  
             #protection-wrapper { display: flex; align-items: center; justify-content: center; min-height: 100vh; width: 100vw; padding: 20px; box-sizing: border-box; font-family: sans-serif; }
                padding: 0 !important;  
             .protection-card { width: 100%; max-width: 400px; background: #fff; padding: 40px 25px; border-radius: 30px; box-shadow: 0 15px 50px rgba(54,102,204,0.15); text-align: center; border: 1px solid #eef0f2; }
                height: 100% !important;  
                width: 100% !important;  
                overflow: hidden !important;  
                background: #f8f9fa !important;
            }
             #protection-wrapper {
                display: flex;
                align-items: center;
                justify-content: center;
                min-height: 100vh;
                width: 100vw;
                padding: 20px;
                box-sizing: border-box;
                font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
            }
             .protection-card {
                width: 100%;
                max-width: 400px;
                background: #ffffff;
                padding: 40px 25px;
                border-radius: 30px;
                box-shadow: 0 15px 50px rgba(54, 102, 204, 0.15);
                border: 1px solid #eef0f2;
                text-align: center;
            }
             .shield-icon { font-size: 70px; display: block; margin-bottom: 20px; }
             .shield-icon { font-size: 70px; display: block; margin-bottom: 20px; }
             .lock-title { color: #1a1a1a; font-size: 24px; font-weight: 800; margin: 0 0 15px 0; }
             .lock-title { color: #1a1a1a; font-size: 24px; font-weight: 800; margin-bottom: 15px; }
             .lock-desc { color: #5f6368; font-size: 15px; line-height: 1.6; margin-bottom: 25px; }
             .lock-desc { color: #5f6368; font-size: 14px; line-height: 1.6; margin-bottom: 25px; }
             .admin-notice {  
             .admin-notice { background: #fff5f5; color: #d93025; padding: 12px; border-radius: 12px; font-size: 12px; font-weight: 700; margin-bottom: 30px; border: 1px solid #fadbd8; }
                background: #fff5f5;  
             .btn-back { background: #36c; color: #fff; border: none; padding: 16px; border-radius: 18px; font-weight: 700; width: 100%; cursor: pointer; }
                color: #d93025;  
                padding: 12px;  
                border-radius: 12px;  
                font-size: 13px;  
                font-weight: 700;  
                margin-bottom: 30px;  
                border: 1px solid #fadbd8;
            }
             .btn-back {  
                background: #36c;  
                color: #fff;  
                border: none;  
                padding: 16px;  
                border-radius: 18px;  
                font-weight: 700;  
                font-size: 16px;
                width: 100%;  
                cursor: pointer;
                box-shadow: 0 4px 12px rgba(51, 102, 204, 0.3);
            }
            .link-home { display: block; margin-top: 20px; color: #70757a; font-size: 14px; text-decoration: none; }
            .footer-ver { margin-top: 40px; font-size: 10px; color: #bdc1c6; font-weight: bold; letter-spacing: 2px; }
         `).appendTo('head');
         `).appendTo('head');


        // Tampilkan layar kunci
         var shieldHTML = `
         var shieldHTML = `
             <div id="protection-wrapper">
             <div id="protection-wrapper">
                 <div class="protection-card">
                 <div class="protection-card">
                     <span class="shield-icon">🛡️</span>
                     <span class="shield-icon">🛡️</span>
                     <h2 class="lock-title">Akses Dibatasi</h2>
                     <h2 class="lock-title">Akses Terbatas</h2>
                     <p class="lock-desc">
                     <p class="lock-desc">Halaman ini adalah bagian sistem yang dilindungi untuk menjaga stabilitas Mippedia.</p>
                        Halaman ini telah dilindungi oleh <b>Mippedia Community</b> untuk mencegah vandalisme dan menjaga stabilitas sistem.
                     <div class="admin-notice">Hanya Administrator yang dapat melihat konten ini.</div>
                    </p>
                     <button class="btn-back" onclick="window.history.back()">Kembali</button>
                     <div class="admin-notice">
                     <br><a href="/" style="display:block; margin-top:20px; color:#70757a; font-size:13px; text-decoration:none;">Ke Beranda</a>
                        Hanya Administrator & Birokrat yang dapat mengakses halaman ini.
                    </div>
                     <button class="btn-back" onclick="window.history.back()">
                        Kembali ke Halaman Sebelumnya
                    </button>
                     <a href="/" class="link-home">Kembali ke Beranda</a>
                    <div class="footer-ver">MIPPEDIA COMMUNITY SECURITY v2.0</div>
                 </div>
                 </div>
             </div>
             </div>
         `;
         `;
         $('body').append(shieldHTML);
         $('body').append(shieldHTML);
       
         document.title = "Akses Dilindungi - Mippedia";
        // Ubah judul tab browser
         document.title = "Akses Dilindungi - Mippedia bahasa Indonesia, ensiklopedia umum";
     }
     }
});
});