משתמש:אלירן/monobook.js

מתוך ויקיפדיה, האנציקלופדיה החופשית

הערה: לאחר הפרסום, ייתכן שיהיה צורך לנקות את זיכרון המטמון (cache) של הדפדפן כדי להבחין בשינויים.

  • פיירפוקס / ספארי: להחזיק את המקש Shift בעת לחיצה על טעינה מחדש (Reload) או ללחוץ על צירוף המקשים Ctrl-F5 או Ctrl-R (במחשב מק: ⌘-R).
  • גוגל כרום: ללחוץ על צירוף המקשים Ctrl-Shift-R (במחשב מק: ⌘-Shift-R).
  • אינטרנט אקספלורר / אדג': להחזיק את המקש Ctrl בעת לחיצה על רענן (Refresh) או ללחוץ על צירוף המקשים Ctrl-F5.
  • אופרה: ללחוץ על Ctrl-F5.
/* Add links to diff pages */
/* Created by [[User:Yonidebest]]; Works in IE only; */

// String constants
wrn_text = "אזהרה";
wrn_tooltip = "הוסף תבנית אזהרה";
try_text = "ניסויים";
try_tooltip = "הוסף תבנית ניסויים";
cpy_text = "פרסומת";
cpy_tooltip = "הוסף תבנית פרסומת";
del_text = "בוטל";
del_tooltip = "הוסף תבנית בוטל";
tnx_text = "תודה";
tnx_tooltip = "הוסף תבנית תודה";

function openNewWindow(userName, previousTitle, template_name) {
  var url = 'http://he.wikipedia.org/w/index.php?title=' + encodeURIComponent('שיחת_משתמש:') + userName + '&action=edit&template_name=' + template_name + '&title_name=' + previousTitle;
  // var win = window.open(url, '_blank'); // חלון חדש
  document.location = url; // באותו חלון
}
  
// Add template to talk page
function addTemplate(template, title) {
  var txt = '\n==[[:' + decodeURIComponent(title).replace(/_/g, ' ') + ']]==\n';
  var comment = '';
  if (template == 'wrn') { // אזהרה
    template = 'אזהרה';
    comment = 'אזהרה';
  }
  if (template == 'try') { // ניסויים
    template = 'ניסויים';
    comment = 'ניסויים';
  }
  if (template == 'tnx') { // תודה
    template = 'תודה';
    comment = 'תודה';
  }
  if (template == 'cpy') { // פרסומת
    template = 'פרסומת';
    comment = 'פרסומת';
  }
  if (template == 'del') { // בוטל
    template = 'בוטל';
    comment = 'בוטל';
  }
  txt += '{{' + template + '}} ';
  document.editform.wpTextbox1.value += txt + '~~' + '~~\n';
  document.editform.wpSummary.value = comment;
  document.editform.wpSave.click();
}

function templateSC_onload() {
  if (document.location.href.indexOf('diff') != -1) {
    var as = document.getElementById('bodyContent').getElementsByTagName('a');
    var titleName = wgPageName;
    var userName;
    var rx = new RegExp('[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}');
    for (var i=0; i < as.length; i++) {
      /* עבור משמשים אנונימיים */
       var m = rx.test(as[i].title);
       if (as[i].title.indexOf("מיוחד:Contributions") == 0 && m) {
         userName = encodeURIComponent(as[i].title.substring(as[i].title.lastIndexOf("Contributions") + 14, as[i].title.length));
        /* tnx */
         var txt1 = document.createTextNode(')');
         var txt2 = document.createTextNode(' | ');
         var a_tnx = document.createElement('a');
         a_tnx.href = 'javascript:openNewWindow(\'' + userName + '\', \'' + titleName + '\', \'' + 'tnx' + '\')';
         a_tnx.appendChild(document.createTextNode(tnx_text));
         a_tnx.title = tnx_tooltip;
         as[i].parentNode.insertBefore(txt1, as[i].nextSibling);
         as[i].parentNode.insertBefore(a_tnx, as[i].nextSibling);
         as[i].parentNode.insertBefore(txt2, as[i].nextSibling);
        /* cpy */
         var txt3 = document.createTextNode(' | ');
         var a_cpy = document.createElement('a');
         a_cpy.href = 'javascript:openNewWindow(\'' + userName + '\', \'' + titleName + '\', \'' + 'cpy' + '\')';
         a_cpy.appendChild(document.createTextNode(cpy_text));
         a_cpy.title = cpy_tooltip;
         as[i].parentNode.insertBefore(a_cpy, as[i].nextSibling);
         as[i].parentNode.insertBefore(txt3, as[i].nextSibling);
        /* del */
         var txt4 = document.createTextNode(' | ');
         var a_del = document.createElement('a');
         a_del.href = 'javascript:openNewWindow(\'' + userName + '\', \'' + titleName + '\', \'' + 'del' + '\')';
         a_del.appendChild(document.createTextNode(del_text));
         a_del.title = del_tooltip;
         as[i].parentNode.insertBefore(a_del, as[i].nextSibling);
         as[i].parentNode.insertBefore(txt4, as[i].nextSibling);
        /* try */
         var txt5 = document.createTextNode(' | ');
         var a_try = document.createElement('a');
         a_try.href = 'javascript:openNewWindow(\'' + userName + '\', \'' + titleName + '\', \'' + 'try' + '\')';
         a_try.appendChild(document.createTextNode(try_text));
         a_try.title = try_tooltip;
         as[i].parentNode.insertBefore(a_try, as[i].nextSibling);
         as[i].parentNode.insertBefore(txt5, as[i].nextSibling);
        /* wrn */
         var txt6 = document.createTextNode(' (');
         var a_wrn = document.createElement('a');
         a_wrn.href = 'javascript:openNewWindow(\'' + userName + '\', \'' + titleName + '\', \'' + 'wrn' + '\')';
         a_wrn.appendChild(document.createTextNode(wrn_text));
         a_wrn.title = wrn_tooltip;
         as[i].parentNode.insertBefore(a_wrn, as[i].nextSibling);
         as[i].parentNode.insertBefore(txt6, as[i].nextSibling);
       }  
    }
  }

  var template_name = getParamValue('template_name');   // Fetch what template to add
  var title_name = getParamValue('title_name');

  if (template_name == 'wrn'){
    addTemplate('wrn', title_name);
  }
  if (template_name == 'try'){
    addTemplate('try', title_name);
  }
  if (template_name == 'tnx'){
    addTemplate('tnx', title_name);
  }
  if (template_name == 'cpy'){
    addTemplate('cpy', title_name);
  }
  if (template_name == 'del'){
    addTemplate('del', title_name);
  }
}

$(templateSC_onload);

importUserScript(16);

importUserScript(13);

importUserScript(20);

importUserScript(14);

importUserScript(27);

importUserScript(12);

importUserScript(15);

importUserScript(22);

importUserScript(25);

// Revert tools by Lorian
//From Nir909's monobook
function getElementsByClass(searchClass,node,tag) {
  // Function from http://www.dustindiaz.com/getelementsbyclass/
  var classElements = new Array();
  if ( node == null )
    node = document;
  if ( tag == null )
    tag = '*';
  var els = node.getElementsByTagName(tag);
  var elsLen = els.length;
  var pattern = new RegExp("(^|\\s)"+searchClass+"(\\s|$)");
  for (i = 0, j = 0; i < elsLen; i++) {
    if ( pattern.test(els[i].className) ) {
      classElements[j] = els[i];
      j++;
    }
  }
  return classElements;
}

// _GET code from NoGray JS Library http://www.nogray.com/new_site/
var _GET = new Array();
var _uri = location.href;

var _temp_get_arr = _uri.substring(_uri.indexOf('?')+1, _uri.length).split("&");

var _temp_get_arr_1 = new Array();

for(_get_arr_i=0; _get_arr_i<_temp_get_arr.length; _get_arr_i++){
  _temp_get_arr_1 = _temp_get_arr[_get_arr_i].split("=");
  _GET[decodeURI(_temp_get_arr_1[0])] = decodeURI(_temp_get_arr_1[1]);
}

delete _uri; delete _temp_get_arr; delete _temp_get_arr_1;

function getMessage (where, user1, user2) {
  var message = prompt ('איזו הודעה ברצונך להשאיר?', '');
  window.location = 'http://he.wikipedia.org/w/index.php?title=' + _GET['title'] + '&action=edit&oldid=' + _GET['oldid'] + '&'+where+'=2&user1='+user1+'&user2='+user2+'&message='+message;
}

$(function (){
  if (location.href.match(/diff=/)) {
    // Get username of submitter
    var user1 = getElementsByClass('diff-otitle',null,'td'); user1 = user1[0].getElementsByTagName('a')[2].innerHTML;
    var user2 = getElementsByClass('diff-ntitle',null,'td'); user2 = user2[0].getElementsByTagName('a')[3].innerHTML;
    document.getElementById('contentSub').innerHTML = '(<a href="http://he.wikipedia.org/w/index.php?title=' + wgPageName + '&action=edit&oldid=' + _GET['oldid'] + '&revert=1&user1='+user1+'&user2='+user2+'">שחזר</a> / <a href="javascript:var message = getMessage(\'revert\', \''+user1+'\', \''+user2+'\');">הודעה</a>) (<a href="http://he.wikipedia.org/w/index.php?title=' + wgPageName + '&action=edit&oldid=' + _GET['oldid'] + '&vandalism=1&user1='+user1+'&user2='+user2+'">ונדליזם</a> / <a href="javascript:var message = getMessage(\'vandalism\', \''+user1+'\', \''+user2+'\');">הודעה</a>) (אזהרה: <a href="http://he.wikipedia.org/w/index.php?title=User_talk:'+user2+'&action=edit&section=new&warn=1">אזהרה</a> / <a href="http://he.wikipedia.org/w/index.php?title=User_talk:'+user2+'&action=edit&section=new&warn=2">ניסויים</a> / <a href="http://he.wikipedia.org/w/index.php?title=User_talk:'+user2+'&action=edit&section=new&warn=3">תודה</a>)';
  } else if (location.href.match(/revert=1/)) {
    document.getElementById('wpSummary').value = 'שוחזר מעריכה של [[Special:Contributions/'+_GET['user2']+'|'+_GET['user2']+']] לגרסה ' + _GET['oldid']+' של [[Special:Contributions/'+_GET['user1']+'|'+_GET['user1']+']]';
    document.getElementById('editform').submit();
  } else if (location.href.match(/revert=2/)) {
    document.getElementById('wpSummary').value = 'שוחזר מעריכה של [[Special:Contributions/'+_GET['user2']+'|'+_GET['user2']+']] לגרסה ' + _GET['oldid']+' של [[Special:Contributions/'+_GET['user1']+'|'+_GET['user1']+']] ('+_GET['message']+')';
    document.getElementById('editform').submit();
  } else if (location.href.match(/vandalism=1/)) {
    document.getElementById('wpSummary').value = 'שחזור השחתה של[[Special:Contributions/'+_GET['user2']+'|'+_GET['user2']+']] לגרסה ' + _GET['oldid']+' של [[Special:Contributions/'+_GET['user1']+'|'+_GET['user1']+']]';
    document.getElementById('editform').submit();
  } else if (location.href.match(/vandalism=2/)) {
    document.getElementById('wpSummary').value = 'שחזור השחתה של [[Special:Contributions/'+_GET['user2']+'|'+_GET['user2']+']] לגרסה ' + _GET['oldid']+' של [[Special:Contributions/'+_GET['user1']+'|'+_GET['user1']+']] ('+_GET['message']+')';
    document.getElementById('editform').submit();
  } else if (location.href.match(/warn=1/)) {
    document.getElementById('wpSummary').value = 'אזהרת השחתה';
    document.getElementById('wpTextbox1').value = '{{אזהרה}} ~~'+'~~';
    document.getElementById('editform').submit();
  } else if (location.href.match(/warn=2/)) {
    document.getElementById('wpSummary').value = 'ניסויי עריכה';
    document.getElementById('wpTextbox1').value = '{{ניסויים}} ~~'+'~~';
    document.getElementById('editform').submit();
  } else if (location.href.match(/warn=3/)) {
    document.getElementById('wpSummary').value = 'תודה על תרומתך לוויקיפדיתנו!';
    document.getElementById('wpTextbox1').value = '{{תודה}} ~~'+'~~';
    document.getElementById('editform').submit();
  }
});
//Made by Eran
function addDeleteOption() {
  ta['del'] = ['', 'מחק דף זה'];
  if (!document.getElementById) return;
  var reqDel=wgPageName;
  x = document.getElementById('ca-move');
  if(!x) return;
  y = document.createElement('li');
  y.id = 'ca-move';
  z = document.createElement('a');
    z.href = 'http://he.wikipedia.org/w/index.php?title=ויקיפדיה:בקשות_ממפעילים&action=edit&section=1&pleasedelete=yes&pagefordel='+reqDel;
  if (x.children) {
    z.appendChild(document.createTextNode('מחיקה'));
    y.appendChild(z);
    document.getElementById('p-cactions').children[1].insertBefore(y,x.nextSibling);
  } else {
    z.appendChild(document.createTextNode('מחיקה'));
    y.appendChild(z);
    document.getElementById('p-cactions').childNodes[3].insertBefore(y,null);
  }
}

$(function (){
if(location.href.match(/pleasedelete=yes/)) {
    txtLoc=location.href;
    reqDel=decodeURI(txtLoc.substring(txtLoc.indexOf('pagefordel=')+11,txtLoc.length));
    document.getElementById('wpSummary').value = '[[' + reqDel + ']]';
    document.getElementById('wpTextbox1').value = document.getElementById('wpTextbox1').value + '\n*[['+reqDel+']] ~~'+'~~';
    document.getElementById('editform').submit();
}
});

addLoadEvent(FACarch);

//Made by Eran
/* הוספת כפתור שמבצע החלפות שונות ומתריע על בעיות סגנון שונות סקריפט שנלקח מ[[משתמש:ערן|ערן]] ונערך קצת על ידי ניר */
function CheckTy()
{
 txt = document.editform.wpTextbox1.value;
 txt = txt.replace(/\ גיאומטריה/g, " גאומטריה");
 txt = txt.replace(/\ דארווין /g, " דרווין ");
 txt = txt.replace(/\ יעוץ/g, " ייעוץ");
 txt = txt.replace(/\ סינטטי/g, " סינתטי");
txt = txt.replace(/\ פלשתינאים/g, " פלסטינים");
txt = txt.replace(/\ תיאולוגיה/g, " תאולוגיה");
 txt = txt.replace(/\ היתה/g, " הייתה");
 txt = txt.replace(/\REDIRECT/g, "הפניה");
 txt = txt.replace(/\איזור/g, "אזור");
 txt = txt.replace(/\אירגון/g, "ארגון");
 txt = txt.replace(/\גיאוגרפיה/g, "גאוגרפיה");
 txt = txt.replace(/\גיאולוגיה/g, "גאולוגיה");
 txt = txt.replace(/\דוגמא /g, "דוגמה ");
 txt = txt.replace(/\ ישוב /g, " יישוב ");
 txt = txt.replace(/\כנסיה/g, "כנסייה");
 txt = txt.replace(/\מוסיקה/g, "מוזיקה");
 txt = txt.replace(/\פיסיולוגיה/g, "פיזיולוגיה");
 txt = txt.replace(/\פיסיקה/g, "פיזיקה");
 txt = txt.replace(/\צלסיוס/g, "צלזיוס");
 txt = txt.replace(/\ שניה /g, " שנייה ");
 txt = txt.replace(/\תיאוריה/g, "תאוריה");
 txt = txt.replace(/\[Category:/gi, "[קטגוריה:");
 txt = txt.replace(/\[Image:/gi, "[תמונה:");
 txt = txt.replace(/\|thumb\|/gi, "|ממוזער|");
 txt = txt.replace(/\|right\|/gi, "|ימין|");
 txt = txt.replace(/\|left\|/gi, "|שמאל|");
txt = txt.replace(/\Image:/gi, "תמונה:");
 txt = txt.replace(/ראה גם/g, "ראו גם");
 txt = txt.replace(/\במידה ו/g, "במידה ש");
txt = txt.replace(/עויין/g, "עוין");
txt = txt.replace(/מצויין/g, "מצוין");
txt = txt.replace(/(ב-|ב )([1-9])?([1-9])( ל)(ינואר|פברואר|מרץ|אפריל|מאי|יוני|יולי|אוגוסט|ספטמבר|אוקטובר|נובמבר|דצמבר)/g, "ב-$2$3 ב$5");
txt = txt.replace(/\t/g, " ");
txt = txt.replace(/(\n\n)\n+/g, "$1");
txt = txt.replace(/== ? ?\n\n==/g, "==\n==");
txt = txt.replace(/^ ? ? \n/gm, "\n");
txt = txt.replace(/[ \t][ \t]+/g, " ");
 txt = txt.replace(/\  /g, " ");
 document.editform.wpTextbox1.value = txt;
comstr="";
 if(txt.indexOf("בגלל ש",0)!=-1) comstr=comstr+"\nיתכן שבערך מופיע הצירוף בגלל ש. אם מופיע מומלץ להחליפו בכיוון ש, משום ש, מאחר ש או מפני ש (מידע נוסף ב ויקיפדיה:לשון)";
 if(txt.indexOf("שוב פעם",0)!=-1) comstr=comstr+"\nיתכן שבערך מופיע הצירוף שוב פעם. אם מופיע מומלץ להחליפו עוד פעם או שוב (מידע נוסף ב ויקיפדיה:לשון)";
 if(txt.indexOf("עובדה מעניינת",0)!=-1 || txt.indexOf("ראוי לציין",0)!=-1 || txt.indexOf("יש לציין",0)!=-1 || txt.indexOf("צריך להדגיש",0)!=-1){
   comstr=comstr+"\nאל תעיד אל עיסתך! מומלץ להימנע מהביטוים עובדה מעניינת היא או צריך להדגיש או יש לציין. יש לתת לקורא להחליט אם העובדה ראויה לציון. (מידע נוסף ב ויקיפדיה:לשון)";
 }
 if(txt.indexOf("למרות ש",0)!=-1) comstr=comstr+"\nיתכן שבערך מופיע הצירוף למרות ש. אם מופיע מומלץ להחליפו באף על פי ש או אף ש או על אף ש או לעיתים הגם ש(מידע נוסף ב ויקיפדיה:לשון)";
if(txt.indexOf("כמובן ש",0)!=-1) comstr=comstr+"\nיתכן שבערך מופיע הצירוף כמובן ש. אם מופיע מומלץ להחליפו במובן ש או בכמובן(מידע נוסף ב ויקיפדיה:לשון)";
 if(txt.indexOf("כנראה ש",0)!=-1) comstr += "\nבערך מופיע הצירוף כנראה ש. רצוי להחליפו בנראה ש או בכנראה";
 if(txt.indexOf("להיכן",0)!=-1 || txt.indexOf("לאיפה",0)!=-1 || txt.indexOf("מהיכן",0)!=-1 || txt.indexOf("מאיפה",0)!=-1) comstr += "\nבערך מופיע בכל\"ם בצמוד לאיפה או להיכן. רצוי להחליף במקרים אלו מומלץ להחליף למילית שאלה אין - לאן או מאין";
 if(txt.indexOf("הכי טוב",0)!=-1){
   comstr=comstr+"\nבערך זה מופיע הצירוף הכי טוב, יתכן שכדאי להחליפו לטוב ביותר (מידע נוסף ב ויקיפדיה:שגיאות תרגום נפוצות)";
 }
 if(txt.indexOf("נפלא",0)!=-1) comstr=comstr+"\nיתכן שהערך כולל סופרלטיבים מיותרים; נפלא (וצורת הרבים והנקבה שלו)";
 if(txt.indexOf("מחריד",0)!=-1) comstr=comstr+"\nיתכן שהערך כולל סופרלטיבים מיותרים; מחריד (וצורות הרבים והנקבה שלו)";
 if(txt.indexOf("מקסים",0)!=-1 || txt.indexOf("מקסימה",0)!=-1 || txt.indexOf("מקסימים",0)!=-1 || txt.indexOf("מקסימות",0)!=-1) comstr=comstr+"\nיתכן שהערך כולל סופרלטיבים מיותרים; מקסים (וצורת הרבים והנקבה שלו)";
 if(txt.indexOf("מדהים",0)!=-1 || txt.indexOf("מדהימה",0)!=-1 || txt.indexOf("מדהימים",0)!=-1 || txt.indexOf("מדהימות",0)!=-1) comstr=comstr+"\nיתכן שהערך כולל סופרלטיבים מיותרים; מדהים (וצורת הרבים והנקבה שלו)";
 if(txt.indexOf("מהמם",0)!=-1 || txt.indexOf("מהממים",0)!=-1 ||txt.indexOf("מהממת",0)!=-1 || txt.indexOf("מהממות",0)!=-1) comstr=comstr+"\nיתכן שהערך כולל סופרלטיבים מיותרים; מהמם (וצורת הרבים והנקבה שלו)";
 if(txt.indexOf("נהדר",0)!=-1) comstr=comstr+"\nיתכן שהערך כולל סופרלטיבים מיותרים; נהדר (וצורת הרבים והנקבה שלו)";
 if(txt.indexOf("חתיך",0)!=-1 || txt.indexOf("חתיכים",0)!=-1 || txt.indexOf("חתיכות",0)!=-1 || txt.indexOf("חתיכה",0)!=-1) comstr=comstr+"\nיתכן שהערך כולל סופרלטיבים מיותרים; חתיך (וצורת הרבים והנקבה שלו)";
 if(txt.indexOf("למרבה הצער",0)!=-1) comstr=comstr+"\nיתכן שהערך כולל סופרלטיבים מיותרים; למרבה הצער";
 if(txt.indexOf("למרבה השמחה",0)!=-1) comstr=comstr+"\nיתכן שהערך כולל סופרלטיבים מיותרים; למרבה השמחה";
 if(txt.indexOf("למרבה העצב",0)!=-1) comstr=comstr+"\nיתכן שהערך כולל סופרלטיבים מיותרים; למרבה העצב";


 if(txt.indexOf(" יכל",0)!=-1) comstr=comstr+"\nבערך מופיע יכל רצוי להחליפו להיה יכול";
 if(txt.indexOf(" ז\"ל",0)!=-1) comstr=comstr+"\nאין להצמיד לאדם את התואר ז\"ל (מידע נוסף ב ויקיפדיה:עקרונות מיוחדים לשפה העברית)";
if(txt.indexOf(" ע\"י",0)!=-1) comstr=comstr+"\nיש ע\"י מומלץ לפתוח את ראשי התיבות ולהחליף ב'על ידי'";
if(txt.indexOf(" בד\"כ",0)!=-1) comstr=comstr+"\nיש בד\"כ מומלץ לפתוח את ראשי התיבות ולהחליף ב'בדרך כלל'";
 if(comstr!=""){
  alert(comstr);
 }
}