MediaWiki:Common.js: Perbedaan antara revisi
Tidak ada ringkasan suntingan Tanda: Dikembalikan Suntingan perangkat seluler Suntingan peramban seluler |
Tidak ada ringkasan suntingan Tanda: Pengembalian manual Suntingan perangkat seluler Suntingan peramban seluler |
||
| Baris 1.165: | Baris 1.165: | ||
/* ========================================================== | /* ========================================================== | ||
🛡️ MIPPEDIA CORE SYSTEM - NEURAL ENGINE | 🛡️ MIPPEDIA CORE SYSTEM - NEURAL ENGINE V7 | ||
Fitur: Anti-Link Pembuka, Auto-Tagging, Promo Check, Related | |||
========================================================== */ | ========================================================== */ | ||
mw.hook('postEdit').add(function() { | mw.hook('postEdit').add(function() { | ||
var currentUser = mw.config.get('wgUserName'); | |||
var | // Jika anonim, currentUser null, kita set jadi string 'Anonim' | ||
var userName = | var userName = currentUser ? currentUser.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]]; | ||
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 USER/ANONIM) --- | ||
// A. Cek Referensi | // A. Cek Referensi | ||
if (! | if (!/<ref[\s>]/i.test(content) && !/\{\{Butuh Referensi/i.test(content)) { | ||
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 | ||
if ((!page.categories || page.categories.length === 0) && !/\{\{Butuh Kategori/i.test(content) && !/\[\[Kategori:/i.test(content)) { | |||
content = '{{Butuh Kategori|date=April 2026}}\n' + content; | content = '{{Butuh Kategori|date=April 2026}}\n' + content; | ||
summaryParts.push('+Cat'); | summaryParts.push('+Cat'); | ||
| Baris 1.217: | Baris 1.214: | ||
// 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 && ! | if (words < 200 && !/\{\{Artikel Rintisan/i.test(content)) { | ||
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', 'solusi terbaik']; | ||
if (promoList.some(p => rawContent.toLowerCase(). | if (promoList.some(p => rawContent.toLowerCase().includes(p)) && !/\{\{Hapus/i.test(content)) { | ||
content = '{{Hapus| | content = '{{Hapus|Alasan: Deteksi kalimat promosi otomatis}}\n' + content; | ||
summaryParts.push('+Promo'); | summaryParts.push('+Promo'); | ||
} | } | ||
// --- 2. GLOBAL ENGINE: SMART RELATED ( | // --- 2. GLOBAL ENGINE: SMART RELATED (MAX 3, NO [[ ]]) --- | ||
if (content.indexOf('{{#related:') === -1) { | if (content.indexOf('{{#related:') === -1) { | ||
var currentKeywords = pageTitle.split(' '); | var currentKeywords = pageTitle.split(' '); | ||
| Baris 1.247: | Baris 1.244: | ||
if (isPatroli) { | if (isPatroli) { | ||
var placeholders = []; | var placeholders = []; | ||
// TAHAP A: Lindungi Template, Header, Kategori, DAN Paragraf awal (sebelum | // TAHAP A: Lindungi Template, Header, Kategori, DAN Paragraf awal (sebelum " adalah ") | ||
content = content.replace(/(\{\{[\s\S]*?\}\}|==+.*?==+|\[\[Kategori:.*?\]\]|^.*?adalah)/gi, function(match) { | |||
content = content.replace(/(\{\{[\s\S]*?\}\}|==+.*?==+|\[\[Kategori:.*?\]\]|^ | |||
placeholders.push(match); | placeholders.push(match); | ||
return '___MIP_SKIP_' + (placeholders.length - 1) + '___'; | return '___MIP_SKIP_' + (placeholders.length - 1) + '___'; | ||
}); | }); | ||
// TAHAP B: Link Otomatis | // TAHAP B: Olah Teks (Link Otomatis) | ||
var tokens = content.split(/(\s+|\[\[|\]\])/); | var tokens = content.split(/(\s+|\[\[|\]\])/); | ||
var inLink = false; | var inLink = false; | ||
| Baris 1.263: | Baris 1.259: | ||
var wordsInToken = tokens[i].match(/\b\w+\b/g); | var wordsInToken = tokens[i].match(/\b\w+\b/g); | ||
if (wordsInToken) | if (!wordsInToken) continue; | ||
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( | |||
// TAHAP C: Kembalikan Unsur yang Dilindungi | |||
// | content = content.replace(/___MIP_SKIP_(\d+)___/g, function(match, id) { | ||
content = content.replace(/\[\[([^|\]:]+)\]\]/g, function( | return placeholders[id]; | ||
return lowerTitles.includes(p1.toLowerCase()) ? | }); | ||
// TAHAP D: Bersihkan Link Merah | |||
content = content.replace(/\[\[([^|\]:]+)\]\]/g, function(match, p1) { | |||
return lowerTitles.includes(p1.toLowerCase()) ? match : p1; | |||
}); | }); | ||
} | } | ||
| Baris 1.290: | Baris 1.290: | ||
title: pageTitle, | title: pageTitle, | ||
text: content, | text: content, | ||
summary: 'Mippedia | summary: 'Mippedia System Intelligence: ' + summaryParts.join(', '), | ||
bot: true, markasbot: true | bot: true, markasbot: true | ||
}).done(function() { | }).done(function() { | ||
// Refresh otomatis agar hasil maintenance terlihat | |||
location.reload(); | location.reload(); | ||
}); | }); | ||