הערה: לאחר הפרסום, ייתכן שיהיה צורך לנקות את זיכרון המטמון (cache) של הדפדפן כדי להבחין בשינויים.

  • פיירפוקס / ספארי: להחזיק את המקש Shift בעת לחיצה על טעינה מחדש (Reload) או ללחוץ על צירוף המקשים Ctrl-F5 או Ctrl-R (במחשב מק: ⌘-R).
  • גוגל כרום: ללחוץ על צירוף המקשים Ctrl-Shift-R (במחשב מק: ⌘-Shift-R).
  • אדג': להחזיק את המקש Ctrl בעת לחיצה על רענן (Refresh) או ללחוץ על צירוף המקשים Ctrl-F5.
(async function () {
    if (mw.config.get('wgNamespaceNumber') !== -1) return;
    const PAGES_TO_CHECK = 100;
    const REPORT_PAGE = 'משתמש:מ. רובין/צ\'קטי';
    const pages = await fetch(
        mw.util.wikiScript('api') +
        '?action=query&list=allpages&aplimit=' + PAGES_TO_CHECK + '&format=json'
    ).then(r => r.json());
    const problematic = [];
    for (const page of pages.query.allpages) {
        const title = page.title;
        const wikitext = await fetch(
            mw.util.wikiScript('api') +
            '?action=query&prop=revisions&rvprop=content&titles=' + encodeURIComponent(title) + '&format=json'
        ).then(r => r.json())
         .then(d => Object.values(d.query.pages)[0].revisions?.[0]['*'] || '');
        if (window.checktypo) {
            const result = window.checktypo.checkText(wikitext);
            const autoFixes = result.fixes.filter(f => f.automatic);
            const manualFixes = result.fixes.filter(f => !f.automatic);
            if (autoFixes.length > 0) {
                let newText = wikitext;
                for (const fix of autoFixes) {
                    newText = newText.replace(fix.regex, fix.replacement);
                }
                await fetch(mw.util.wikiScript('api'), {
                    method: 'POST',
                    headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
                    body: new URLSearchParams({
                        action: 'edit',
                        title,
                        text: newText,
                        summary: 'תיקוני צ\'קטי אוטומטיים',
                        token: mw.user.tokens.get('csrfToken'),
                        format: 'json'
                    })
                });
            }
            if (manualFixes.length > 0) {
                problematic.push('* [[' + title + ']] (' + manualFixes.length + ' בעיות)');
            }
        }
    }
    if (problematic.length > 0) {
        const reportText =
            '== דו"ח צ\'קטי אוטומטי ==\n' +
            'נוצר בתאריך 12:04, 26 באוקטובר 2025 (IST)\n\n' +
            problematic.join('\n');
        await fetch(mw.util.wikiScript('api'), {
            method: 'POST',
            headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
            body: new URLSearchParams({
                action: 'edit',
                title: REPORT_PAGE,
                text: reportText,
                summary: 'דו"ח צ\'קטי אוטומטי',
                token: mw.user.tokens.get('csrfToken'),
                format: 'json'
            })
        });
    }
})();