משתמש:Davidnead/חפיץ הסבה.js
הערה: לאחר הפרסום, ייתכן שיהיה צורך לנקות את זיכרון המטמון (cache) של הדפדפן כדי להבחין בשינויים.
- פיירפוקס / ספארי: להחזיק את המקש Shift בעת לחיצה על טעינה מחדש (Reload) או ללחוץ על צירוף המקשים Ctrl-F5 או Ctrl-R (במחשב מק: ⌘-R).
- גוגל כרום: ללחוץ על צירוף המקשים Ctrl-Shift-R (במחשב מק: ⌘-Shift-R).
- אינטרנט אקספלורר / אדג': להחזיק את המקש Ctrl בעת לחיצה על רענן (Refresh) או ללחוץ על צירוף המקשים Ctrl-F5.
- אופרה: ללחוץ על Ctrl-F5.
if (mw.config.get("wgPageName") == "מיוחד:חיפוש") {
$(mw.util.addPortletLink('p-navigation', '#', ' בקשה לבוט ההסבה')).css("backgroundColor", " #ffcccc").click(function () {
var url = window.location.href
url = url.replace(/searchToken=.+?(?:$|\s|&)/, "").replace(/[&]limit=\d+?(?:$|\s|&)/, "").replace(/[&]offset=.+?(?:$|\s|&)/, "")
var newUrl = url + "&limit=5000&offset=0"
var summary = prompt("הזן תקציר עריכה").replace(/\|/, "{{!}}")
var regex = "<nowiki>" + prompt("הזן ביטוי רגולרי").replace(/\|/, "{{subst:!}}") + "</nowiki>"
var newText = "<code><nowiki>" + prompt("הזן טקסט חדש").replace(/\|/, "{{subst:!}}") + "</nowiki></code>"
var template = `{{ס:בוט ההסבה/שלד חפיץ\n|תקציר עריכה=` + summary + `\n|ערכים להסבה=@[` + newUrl + `]\n|ביטוי רגולרי להסבה=` + regex + `\n|מפרט הסבה=` + newText + `}}`
var api = new mw.Api();
api.postWithToken("edit", {
action: "edit",
title: "משתמש:" + mw.config.get("wgUserName") + "/הסבה",
text: template
}).done(function (result, jqXHR) {
mw.notify("success")
}).fail(function (code, result) {
if (code === "http") {
mw.notify("HTTP error: " + result.textStatus); // result.xhr contains the jqXHR object
} else if (code === "ok-but-empty") {
mw.notify("Got an empty response from the server");
} else {
mw.notify("API error: " + code);
}
});
})
}