משתמש:מ. רובין/הודעה למשתמש.js
הערה: לאחר הפרסום, ייתכן שיהיה צורך לנקות את זיכרון המטמון (cache) של הדפדפן כדי להבחין בשינויים.
- פיירפוקס / ספארי: להחזיק את המקש Shift בעת לחיצה על טעינה מחדש (Reload) או ללחוץ על צירוף המקשים Ctrl-F5 או Ctrl-R (במחשב מק: ⌘-R).
- גוגל כרום: ללחוץ על צירוף המקשים Ctrl-Shift-R (במחשב מק: ⌘-Shift-R).
- אדג': להחזיק את המקש Ctrl בעת לחיצה על רענן (Refresh) או ללחוץ על צירוף המקשים Ctrl-F5.
// ==UserScript== // @name Disambig & Link Checker for Hamichlol // @description מציג אזהרות לקישורים לדפי פירושונים, הפניות ודפים אדומים בעריכת קוד מקור // @version 1.0 // @match https://chabadpedia.co.il/* // @grant none // ==/UserScript==
(function () { if (mw.config.get('wgAction') !== 'edit' && mw.config.get('wgAction') !== 'submit') return; if (!document.querySelector('#wpTextbox1')) return;
const textbox = document.querySelector('#wpTextbox1');
const warningBox = document.createElement('div');
warningBox.style.border = '1px solid #ccc';
warningBox.style.padding = '10px';
warningBox.style.marginTop = '10px';
warningBox.style.background = '#f9f9f9';
warningBox.innerHTML = '<strong>בדיקת קישורים:</strong>';
textbox.parentNode.insertBefore(warningBox, textbox.nextSibling);
const linkRegex = /(.*?)(\||)/g;
const text = textbox.value;
const checkedLinks = new Set();
let match;
while ((match = linkRegex.exec(text)) !== null) {
const fullLink = match[1].trim();
const linkTarget = fullLink.split('#')[0].split('/')[0];
if (checkedLinks.has(linkTarget)) continue;
checkedLinks.add(linkTarget);
checkLink(linkTarget);
}
function checkLink(title) {
const url = `/w/api.php?action=query&format=json&titles=${encodeURIComponent(title)}&redirects=1&origin=*`;
fetch(url)
.then(res => res.json())
.then(data => {
const pages = data.query.pages;
const pageId = Object.keys(pages)[0];
const page =