משתמש:Neriah/common.js: הבדלים בין גרסאות בדף
קפיצה לניווט
קפיצה לחיפוש
תגיות: החלפה ביטול |
אין תקציר עריכה |
||
(29 גרסאות ביניים של 2 משתמשים אינן מוצגות) | |||
שורה 10: | שורה 10: | ||
if (mw.config.get('wgCanonicalNamespace')+':'+mw.config.get('wgTitle') === 'Project:AutoWikiBrowser/Script' && mw.config.get('wgAction') == 'view') | if (mw.config.get('wgCanonicalNamespace')+':'+mw.config.get('wgTitle') === 'Project:AutoWikiBrowser/Script' && mw.config.get('wgAction') == 'view') | ||
mw.loader.load('//en.wikipedia.org/w/index.php?title=User:Joeytje50/JWB.js&action=raw&ctype=text/javascript'); | mw.loader.load('//en.wikipedia.org/w/index.php?title=User:Joeytje50/JWB.js&action=raw&ctype=text/javascript'); | ||
/* | |||
// סקריפט לצנזור שם ה' - נכתב ע"י [[user:Neriah]] | |||
//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.id = "censorButton"; | |||
buttonSpan.innerText = "צנזור שם ה'"; | |||
var buttonDiv = document.createElement("div"); | |||
buttonDiv.className = "mw-parser-output"; | |||
buttonDiv.id = "censorButton-div"; | |||
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] = "[-֯/ָּ]*" | |||
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], "צבאות"); | |||
censore(elements[i], "שדי"); | |||
} | |||
}); | |||
} | |||
*/ | |||
var buttonSpan = document.createElement("span"); | |||
buttonSpan.className = "plainlinks mw-ui-button"; | |||
buttonSpan.innerText = "הסר ניקוד"; | |||
var buttonDiv = document.createElement("div"); | |||
buttonDiv.className = "mw-parser-output"; | |||
buttonDiv.style.display = "inline-block"; | |||
buttonDiv.style.verticalAlign = "left"; | |||
buttonDiv.appendChild(buttonSpan); | |||
var heading = document.getElementById('firstHeading'); | |||
heading.appendChild(buttonDiv); | |||
buttonSpan.addEventListener("click", function() { | |||
var elements = document.body.getElementsByTagName("*"); | |||
for (var i = 0; i < elements.length; i++) { | |||
elements[i].innerHTML = elements[i].innerHTML.replace(/[֑-ֽֿׁ-ׇׇ]*/g, ""); | |||
} | |||
}); |
גרסה אחרונה מ־15:49, 12 בינואר 2024
/** This script contains the code required for loading [[User:Joeytje50/JWB.js]].
* All other code is located at that page.
*/
//Idea by [[User:Epicgenius]]
$.when(mw.loader.using(['mediawiki.util'], $.ready)).done( function() {
mw.util.addPortletLink("p-tb", mw.config.get('wgArticlePath').replace('$1', "Project:AutoWikiBrowser/Script"), "AWB אונליין", "tb-awbscript", "Run Javascript Wiki Browser");
});
if (mw.config.get('wgCanonicalNamespace')+':'+mw.config.get('wgTitle') === 'Project:AutoWikiBrowser/Script' && mw.config.get('wgAction') == 'view')
mw.loader.load('//en.wikipedia.org/w/index.php?title=User:Joeytje50/JWB.js&action=raw&ctype=text/javascript');
/*
// סקריפט לצנזור שם ה' - נכתב ע"י [[user:Neriah]]
//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.id = "censorButton";
buttonSpan.innerText = "צנזור שם ה'";
var buttonDiv = document.createElement("div");
buttonDiv.className = "mw-parser-output";
buttonDiv.id = "censorButton-div";
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] = "[-֯/ָּ]*"
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], "צבאות");
censore(elements[i], "שדי");
}
});
}
*/
var buttonSpan = document.createElement("span");
buttonSpan.className = "plainlinks mw-ui-button";
buttonSpan.innerText = "הסר ניקוד";
var buttonDiv = document.createElement("div");
buttonDiv.className = "mw-parser-output";
buttonDiv.style.display = "inline-block";
buttonDiv.style.verticalAlign = "left";
buttonDiv.appendChild(buttonSpan);
var heading = document.getElementById('firstHeading');
heading.appendChild(buttonDiv);
buttonSpan.addEventListener("click", function() {
var elements = document.body.getElementsByTagName("*");
for (var i = 0; i < elements.length; i++) {
elements[i].innerHTML = elements[i].innerHTML.replace(/[֑-ֽֿׁ-ׇׇ]*/g, "");
}
});