MediaWiki:Common.js: Perbedaan antara revisi
Tidak ada ringkasan suntingan Tanda: Suntingan perangkat seluler Suntingan peramban seluler |
Tidak ada ringkasan suntingan Tanda: Dikembalikan Suntingan perangkat seluler Suntingan peramban seluler |
||
| Baris 1.165: | Baris 1.165: | ||
/* ========================================================== | /* ========================================================== | ||
🛡️ MIPPEDIA CORE SYSTEM - NEURAL ENGINE | 🛡️ MIPPEDIA CORE SYSTEM - NEURAL ENGINE V8 (FIXED) | ||
Logika: Fix Anonim, Fix Proteksi Pembuka, Fix Auto-Tag | |||
========================================================== */ | ========================================================== */ | ||
mw.hook('postEdit').add(function() { | mw.hook('postEdit').add(function() { | ||
var | // FIX: Ambil username dengan aman tanpa bikin script error jika null (anonim) | ||
var rawUser = mw.config.get('wgUserName'); | |||
var userName = | var userName = rawUser ? rawUser.replace(/_/g, ' ') : 'Anonim'; | ||
var isPatroli = (userName === 'Mippedia Patroli'); | var isPatroli = (userName === 'Mippedia Patroli'); | ||
| Baris 1.196: | Baris 1.196: | ||
}).done(function(resData) { | }).done(function(resData) { | ||
var page = resData.query.pages[Object.keys(resData.query.pages)[0]]; | var page = resData.query.pages[Object.keys(resData.query.pages)[0]]; | ||
if (!page || !page.revisions) return; | |||
var rawContent = page.revisions[0]['*']; | var rawContent = page.revisions[0]['*']; | ||
var content = rawContent; | var content = rawContent; | ||
var summaryParts = []; | var summaryParts = []; | ||
// --- 1. GLOBAL ENGINE: AUTO-MAINTENANCE (SEMUA | // --- 1. GLOBAL ENGINE: AUTO-MAINTENANCE (SEMUA TERMASUK ANONIM) --- | ||
// A. Cek Referensi | // A. Cek Referensi | ||
if (!/<ref[\s>]/i | if (!content.match(/<ref[\s>]/i) && !content.match(/\{\{Butuh Referensi/i)) { | ||
content = '{{Butuh Referensi|date=April 2026}}\n' + content; | content = '{{Butuh Referensi|date=April 2026}}\n' + content; | ||
summaryParts.push('+Ref'); | summaryParts.push('+Ref'); | ||
} | } | ||
// B. Cek Kategori | // B. Cek Kategori | ||
var hasCat = (page.categories && page.categories.length > 0) || content.match(/\[\[Kategori:/i); | |||
if (!hasCat && !content.match(/\{\{Butuh Kategori/i)) { | |||
content = '{{Butuh Kategori|date=April 2026}}\n' + content; | content = '{{Butuh Kategori|date=April 2026}}\n' + content; | ||
summaryParts.push('+Cat'); | summaryParts.push('+Cat'); | ||
| Baris 1.214: | Baris 1.217: | ||
// C. Cek Artikel Rintisan (< 200 kata) | // C. Cek Artikel Rintisan (< 200 kata) | ||
var words = rawContent.trim().split(/\s+/).length; | var words = rawContent.trim().split(/\s+/).length; | ||
if (words < 200 && !/\{\{Artikel Rintisan/i | if (words < 200 && !content.match(/\{\{Artikel Rintisan/i)) { | ||
content = '{{Artikel Rintisan}}\n' + content; | content = '{{Artikel Rintisan}}\n' + content; | ||
summaryParts.push('+Stub'); | summaryParts.push('+Stub'); | ||
} | } | ||
// D. Cek Promosi | // D. Cek Promosi | ||
var promoList = ['memang hebat', 'terpercaya sekali', 'terbaik di dunia', 'hubungi nomor kami', 'harga murah', 'kualitas terjamin | var promoList = ['memang hebat', 'terpercaya sekali', 'terbaik di dunia', 'hubungi nomor kami', 'harga murah', 'kualitas terjamin']; | ||
if (promoList.some(p => rawContent.toLowerCase(). | if (promoList.some(p => rawContent.toLowerCase().indexOf(p) !== -1) && !content.match(/\{\{Hapus/i)) { | ||
content = '{{Hapus| | content = '{{Hapus|Promosi otomatis}}\n' + content; | ||
summaryParts.push('+Promo'); | summaryParts.push('+Promo'); | ||
} | } | ||
// --- 2. GLOBAL ENGINE: SMART RELATED ( | // --- 2. GLOBAL ENGINE: SMART RELATED (SEMUA TERMASUK ANONIM) --- | ||
if (content.indexOf('{{#related:') === -1) { | if (content.indexOf('{{#related:') === -1) { | ||
var currentKeywords = pageTitle.split(' '); | var currentKeywords = pageTitle.split(' '); | ||
| Baris 1.244: | Baris 1.247: | ||
if (isPatroli) { | if (isPatroli) { | ||
var placeholders = []; | var placeholders = []; | ||
// TAHAP A: Lindungi Template, Header, Kategori, DAN Paragraf awal (sebelum " adalah ") | // TAHAP A: Lindungi Template, Header, Kategori, DAN Paragraf awal (sebelum kata "adalah") | ||
content = content.replace(/(\{\{[\s\S]*?\}\}|==+.*?==+|\[\[Kategori:.*?\]\]|^ | // Menggunakan Regex multiline yang lebih kuat untuk menangkap teks awal | ||
content = content.replace(/(\{\{[\s\S]*?\}\}|==+.*?==+|\[\[Kategori:.*?\]\]|^[\s\S]*?adalah)/i, function(match) { | |||
placeholders.push(match); | placeholders.push(match); | ||
return '___MIP_SKIP_' + (placeholders.length - 1) + '___'; | return '___MIP_SKIP_' + (placeholders.length - 1) + '___'; | ||
}); | }); | ||
// TAHAP B: | // TAHAP B: Link Otomatis | ||
var tokens = content.split(/(\s+|\[\[|\]\])/); | var tokens = content.split(/(\s+|\[\[|\]\])/); | ||
var inLink = false; | var inLink = false; | ||
| Baris 1.259: | Baris 1.263: | ||
var wordsInToken = tokens[i].match(/\b\w+\b/g); | var wordsInToken = tokens[i].match(/\b\w+\b/g); | ||
if ( | if (wordsInToken) { | ||
wordsInToken.forEach(function(word) { | |||
var lowerWord = word.toLowerCase(); | |||
if (lowerWord === pageTitle.toLowerCase()) return; | |||
var idx = lowerTitles.indexOf(lowerWord); | |||
if (idx !== -1) { | |||
var regex = new RegExp('\\b' + word + '\\b', 'g'); | |||
tokens[i] = tokens[i].replace(regex, '[[' + allTitles[idx] + '|' + word + ']]'); | |||
} | |||
} | }); | ||
} | } | ||
} | } | ||
content = tokens.join(''); | content = tokens.join(''); | ||
content = content.replace(/___MIP_SKIP_(\d+)___/g, function(m, id) { return placeholders[id]; }); | |||
content = content.replace(/___MIP_SKIP_(\d+)___/g, function( | // Clean Red Links | ||
content = content.replace(/\[\[([^|\]:]+)\]\]/g, function(m, p1) { | |||
return lowerTitles.includes(p1.toLowerCase()) ? m : p1; | |||
// | |||
content = content.replace(/\[\[([^|\]:]+)\]\]/g, function( | |||
return lowerTitles.includes(p1.toLowerCase()) ? | |||
}); | }); | ||
} | } | ||
| Baris 1.290: | Baris 1.290: | ||
title: pageTitle, | title: pageTitle, | ||
text: content, | text: content, | ||
summary: 'Mippedia | summary: 'Mippedia Neural Engine: ' + summaryParts.join(', '), | ||
bot: true, markasbot: true | bot: true, markasbot: true | ||
}).done(function() { | }).done(function() { | ||
location.reload(); | location.reload(); | ||
}); | }); | ||