אונטערשייד צווישן ווערסיעס פון "באַניצער:גאון הירדן/ברוך הבא.js"
קפיצה לניווט
קפיצה לחיפוש
מוטי (שמועס | ביישטייערונגען) (ייבוא) |
(קיין אונטערשייד)
|
יעצטיגע רעוויזיע זינט 17:32, 15 פעברואר 2023
$(() => {
const userToolLinks = document.querySelectorAll(".mw-usertoollinks");
userToolLinks.forEach((element) => {
const noContributes = element.querySelector(
"a.mw-usertoollinks-contribs.new"
);
const noTalk = element.querySelector("a.mw-usertoollinks-talk.new");
if (noContributes != null || noTalk == null) return;
const talkPage = noTalk.title.replace("(בלאַט עקזיסטירט נאכנישט)", "");
const span = document.createElement("span");
const newElement = document.createElement("a");
newElement.href = "#";
newElement.textContent = "ברוך הבא";
newElement.classList.add("mw-usertoollinks-contribs");
newElement.addEventListener("click", () => {
const name = talkPage.replace("שיחת משתמש:", "");
const message = "{{בה|" + name + "}}";
let summary;
if (confirm("תרצה להוסיף כותרת אישית למשתמש " + name + "?")) {
summary = prompt("רשום כאן את הכותרת האישית:", "");
} else {
summary = "ברוך בואך";
}
const params = {
action: "query",
format: "json",
prop: "info",
titles: talkPage,
utf8: 1,
};
$.getJSON("/w/api.php", params, function (data) {
if (data.query.pages["-1"]) {
$.ajax({
url: mw.util.wikiScript("api"),
type: "post",
data: {
action: "flow",
submodule: "new-topic",
page: talkPage,
nttopic: summary,
token: mw.user.tokens.get("csrfToken"),
ntcontent: message,
format: "json",
},
success: function (data) {
mw.notify("ההודעה בדף " + talkPage + " נשמרה בהצלחה");
},
error: function (data) {
mw.notify("תקלה. התבנית לא נשמרה בדף השיחה של המשתמש");
},
});
} else {
mw.notify("ההודעה בדף " + talkPage + " כבר מופיעה");
}
});
element.removeChild(span);
});
span.appendChild(newElement)
element.appendChild(span);
});
});