מדיה ויקי:Gadget-Censorbutton.js: הבדלים בין גרסאות בדף
תוכן שנמחק תוכן שנוסף
אין תקציר עריכה תגית: שוחזרה |
ניסיון תגית: שוחזרה |
||
שורה 19: | שורה 19: | ||
let split_str = word.split(""); |
let split_str = word.split(""); |
||
const nikud = "[֑-ׇׇ]*" |
const nikud = "[֑-ׇׇ]*" |
||
⚫ | |||
const reg_list = split_str.reduce((list, elem, i) => { |
const reg_list = split_str.reduce((list, elem, i) => { |
||
list.push(elem, nikud); |
list.push(elem, nikud); |
||
שורה 27: | שורה 27: | ||
reg_list.splice(3, 0, ')', '('); |
reg_list.splice(3, 0, ')', '('); |
||
reg_list.push(')'); |
reg_list.push(')'); |
||
if (word === "אדני") reg_list[reg_list.length-4] = "ָ?" |
|||
if (word === "אדני" && reg_list[reg_list.length - 4] !== "ָ?") { |
|||
return; |
|||
⚫ | |||
} |
|||
⚫ | |||
const regex = new RegExp(reg_list.join(""), "g"); |
|||
⚫ | |||
} |
} |
||
גרסה מ־22:50, 8 ביולי 2023
if (
mw.config.get('wgNamespaceNumber') === 0 ||
mw.config.get('wgNamespaceNumber') === 106 ||
mw.config.get('wgNamespaceNumber') === 14
) {
var buttonSpan = document.createElement("span");
buttonSpan.className = "plainlinks mw-ui-button";
buttonSpan.innerText = "צנזור שם ה'";
var buttonDiv = document.createElement("div");
buttonDiv.className = "mw-parser-output";
buttonDiv.appendChild(buttonSpan);
var heading = document.getElementById('firstHeading');
heading.appendChild(buttonDiv);
buttonSpan.addEventListener("click", function() {
function censore(element, word) {
let split_str = word.split("");
const nikud = "[֑-ׇׇ]*"
const reg_list = split_str.reduce((list, elem, i) => {
list.push(elem, nikud);
return list;
}, []);
reg_list.splice(0, 0, '(');
reg_list.splice(3, 0, ')', '(');
reg_list.push(')');
if (word === "אדני" && reg_list[reg_list.length - 4] !== "ָ?") {
return;
}
const regex = new RegExp(reg_list.join(""), "g");
element.innerHTML = element.innerHTML.replace(regex, "$1-$2");
}
var elements = document.getElementsByTagName("*");
for (var i = 0; i < elements.length; i++) {
censore(elements[i], "יהוה");
censore(elements[i], "אדני");
censore(elements[i], "אלוה");
censore(elements[i], "אלהי");
censore(elements[i], "אלהים");
censore(elements[i], "צבאות");
censore(elements[i], "שדי");
}
});
}