User:Bot doubleredirects/Gadget-DoubleRedirectFixer.js: Difference between revisions
No edit summary |
No edit summary |
||
| (3 intermediate revisions by the same user not shown) | |||
| Line 1: | Line 1: | ||
(() => { | |||
const BOT_USERS = [508]; | |||
const api = new mw.Api(); | const api = new mw.Api(); | ||
| Line 38: | Line 39: | ||
if (query?.pages) { | if (query?.pages) { | ||
const page = Object.values(query.pages)[0]; | const page = Object.values(query.pages)[0]; | ||
if (page.ns) { | if (page.ns !== undefined) { | ||
const namespacePrefixes = { | const namespacePrefixes = { | ||
4: " | 4: 'חב"דפדיה:', | ||
6: " | 6: "קובץ:", | ||
10: " | 10: "תבנית:", | ||
12: " | 12: "עזרה:", | ||
14: "קטגוריה:", | |||
}; | }; | ||
return namespacePrefixes[page.ns] ?? ""; | return namespacePrefixes[page.ns] ?? ""; | ||
| Line 56: | Line 58: | ||
action: "edit", | action: "edit", | ||
format: "json", | format: "json", | ||
bot: true, | bot: true, | ||
title: title, | title: title, | ||
text: `# | text: `#הפניה [[${target}]]`, | ||
summary: "תיקון הפניה כפולה", | |||
}); | }); | ||
mw.notify(`\nstatus:${title} | mw.notify(`\nstatus:${title} success`); | ||
} catch (error) { | } catch (error) { | ||
console.error(error); | console.error(error); | ||
| Line 98: | Line 100: | ||
if (!userGroups.includes("bot") && !BOT_USERS.includes(userId)) return; | if (!userGroups.includes("bot") && !BOT_USERS.includes(userId)) return; | ||
if (pageName !== " | if (pageName !== "מיוחד:הפניות_כפולות") return; | ||
const num = prompt("? כמה הפניות כפולות להציג", 0); | const num = prompt("? כמה הפניות כפולות להציג", 0); | ||