משתמש:Gridge/monobook.js

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

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

  • פיירפוקס / ספארי: להחזיק את המקש Shift בעת לחיצה על טעינה מחדש (Reload) או ללחוץ על צירוף המקשים Ctrl-F5 או Ctrl-R (במחשב מק: ⌘-R).
  • גוגל כרום: ללחוץ על צירוף המקשים Ctrl-Shift-R (במחשב מק: ⌘-Shift-R).
  • אינטרנט אקספלורר / אדג': להחזיק את המקש Ctrl בעת לחיצה על רענן (Refresh) או ללחוץ על צירוף המקשים Ctrl-F5.
  • אופרה: ללחוץ על Ctrl-F5.
// From [[en:User:Lupin/autoedit.js]], translated by [[user:ערן]], edited by [[User:Yonidebest]]

// String constants
ns_text = "חסר מקור";
ns_tooltip = "סמן תמונה זו כחסרה מקור";
nl_text = "חסר רישיון";
nl_tooltip = "סמן תמונה זו כחסרה פרטי רישיון";
nsl_text = "חסר מקור ורישיון";
nsl_tooltip = "סמן תמונה זו כחסרה מקור ופרטי רישיון";
c_text = "ויקישיתוף";
c_tooltip = "הודע למשתמש על ויקישיתוף";
p_text = "שימוש אישי";
p_tooltip = "סמן תמונה זו כשימוש אישי";
v_text = "אומת";
v_tooltip = "סמן תמונה זו כמאומתת";
fu_text = "ספק שימוש הוגן";
fu_tooltip = "סמן תמונה זו כבעייתית מבחינת שימוש הוגן";

// Site info
scriptPath = "/w/index.php";
prettyPath = "/wiki/";
wikiHostname = "he.wikipedia.org";

function openWindow(url) {
  var res = window.open(url, '_blank');
  if (!res) alert("openWindow: window.open() returned null");
}

function getUploader() {
  // Get uploader from first point in the list under "File history"
  // Uploader is stored in second A tag in UL tag under "File history"
  // Returns title of user page (without name space) in URL form
  var el = document.getElementById('filehistory')
  if (!el) {
    alert("תקלה: לא נמצאה הכותרת של היסטורית ההעלאה ... משימה נכשלה");
    return null;
  }
  while (!el.className || el.className != 'filehistory') {
    el = el.nextSibling;
  }
  if (!el) {
    alert("תקלה: לא נמצאה היסטורית העלאה ... משימה נכשלה");
    return null;
  }
  el = el.getElementsByTagName('tr')[1];
  if (!el) {
    alert("לא הצלחתי למצוא את השורה הדרושה לי בטבלה ... הפסקתי את המשימה");
    return null;
  }
  var as = el.getElementsByTagName('td');
  if (as[2].getElementsByTagName('a')[0].href.indexOf('http://upload.wikimedia.org') == 0) {
    el = as[3];
  } else {
    el = as[2];
  }
  if (!el) {
    alert("לא הצלחתי למצוא את התא הדרוש לי בטבלה ... הפסקתי את המשימה");
    return null;
  }
  el = el.getElementsByTagName('a')[0];
  if (!el) {
    alert("לא הצלחתי למצוא את הקישור הדרוש לי בטבלה ... הפסקתי את המשימה");
    return null;
  }
  return el.innerHTML;
}

// Function that help idenfity what action must be taken
function mnx_mark(imagepage_fakeaction, usertalk_fakeaction) {

  if (imagepage_fakeaction != 'v_temp' && imagepage_fakeaction != 'p_temp') {
    var pagename = encodeURIComponent(mw.config.get('wgPageName'));
    var uploader = getUploader();
 
    if (!uploader) return;
    // Open new window for the user page
    openWindow(scriptPath + '?title=User_talk:' + uploader + '&action=edit&fakeaction=' + usertalk_fakeaction + '&target=' + pagename + '&template_type=' + imagepage_fakeaction);
  }
  var editlk = document.getElementById('ca-edit').getElementsByTagName('a')[0].href;
  document.location = editlk + '&fakeaction=' + imagepage_fakeaction;
}

// Add template to image description page
function mnx_addTemplate(template) {
  var comment = "תמונה חשודה";
  if (template == 'ns_temp') template = 'ס:תמונה חשודה|סיבה=חסר מקור'; //no source
  if (template == 'nl_temp') template = 'ס:תמונה חשודה|סיבה=חסר רישיון'; //no license
  if (template == 'fu_temp') template = 'ס:תמונה חשודה|ספק שימוש הוגן'; //no license
  if (template == 'nsl_temp') template = 'ס:תמונה חשודה|סיבה=חסר מקור ורישיון'; //no source and license
  if (template == 'c_temp') { //commons
    template = 'העברה לוויקישיתוף';
    comment = 'העברה לוויקישיתוף';
  }
  if (template == 'v_temp') { //verified
    template = 'אומת';
    comment = 'אומת';
  }
  if (template == 'p_temp') { //private
    template = 'תמונה לשימוש אישי}}{{אומת';
    comment = 'שימוש אישי';
  }
  var txt = '{{' + template + '}}';
  document.editform.wpTextbox1.value += '\n' + txt;
  document.editform.wpSummary.value = comment;
  document.editform.wpSave.click();
}

// Add warning template to uploader's talk page
function mnx_addUserWarningTemplate(imagetarget, template_type) {
  var imageName = imagetarget.substring(6,imagetarget.length);
  var txt = '==[[:תמונה:' + imageName + '|' + imageName + ']]==\n';
  var comment = '';
  if (template_type == 'ns_temp') { // source
     txt += 'שלום, במסגרת הטיפול בתמונות בעייתיות ב[[וק:מה|מיזם התמונות]] אותרה התמונה הנ"ל. ציון המקור של התמונה אינו תקין ואינו עומד בהנחיות החדשות המופיעות ב[[מיוחד:Upload|דף העלאת קובץ לשרת]] ובדפי העזרה בנושא תמונות. אנא פעל על פי ה\'\'\'[[משתמש:Gridge/מקור|הנחיות בדף זה]]\'\'\', אחרת התמונה עלולה להימחק בעשרת הימים הקרובים. בהמשך לפנייה זו אני לרשותך לשם מתן מידע ועזרה. לחלופין, ניתן ואף רצוי לפנות ל[[ויקיפדיה:דלפק ייעוץ|דלפק הייעוץ]] שכן שם יש סיכוי טוב יותר לקבל תשובה מהירה יותר. ';
     comment = 'חסר מקור';
  }
  if (template_type == 'nl_temp') { // license
     txt += 'שלום, במסגרת הטיפול בתמונות בעייתיות ב[[וק:מה|מיזם התמונות]] אותרה התמונה הנ"ל. רישיונה של התמונה אינו תקין ואינו עומד בהנחיות החדשות המופיעות ב[[מיוחד:Upload|דף העלאת קובץ לשרת]] ובדפי העזרה בנושא תמונות. אנא פעל על פי ה\'\'\'[[משתמש:Gridge/רישיון|הנחיות בדף זה]]\'\'\', אחרת התמונה עלולה להימחק בעשרת הימים הקרובים. בהמשך לפנייה זו אני לרשותך לשם מתן מידע ועזרה. לחלופין, ניתן ואף רצוי לפנות ל[[ויקיפדיה:דלפק ייעוץ|דלפק הייעוץ]] שכן שם יש סיכוי טוב יותר לקבל תשובה מהירה יותר. ';
     comment = 'חסר רישיון';
  }
  if (template_type == 'nsl_temp') { // source and license
     txt += 'שלום, במסגרת הטיפול בתמונות בעייתיות ב[[וק:מה|מיזם התמונות]] אותרה התמונה הנ"ל. רישיונה של התמונה אינו תקין ואינו עומד בהנחיות החדשות המופיעות ב[[מיוחד:Upload|דף העלאת קובץ לשרת]] ובדפי העזרה בנושא תמונות. כמו כן, לא מצוין מקור בצורה הדרושה. אנא פעל על פי ה\'\'\'[[משתמש:Gridge/מקור ורישיון|הנחיות בדף זה]]\'\'\', אחרת התמונה עלולה להימחק בעשרת הימים הקרובים. בהמשך לפנייה זו אני לרשותך לשם מתן מידע ועזרה. לחלופין, ניתן ואף רצוי לפנות ל[[ויקיפדיה:דלפק ייעוץ|דלפק הייעוץ]] שכן שם יש סיכוי טוב יותר לקבל תשובה מהירה יותר. ';
     comment = 'חסר מקור ורישיון';
  }
  if (template_type == 'c_temp') { // commons
     txt += 'במסגרת הטיפול בתמונות חופשיות ב[[וק:מה|מיזם התמונות]], ברצוני להזכיר לך כי תמונות חופשיות יש להעלות ל[[ויקישיתוף|וויקישיתוף]]. תודה, ';
     comment = 'ויקישיתוף';
  }
  if (template_type == 'fu_temp') {
  txt += 'שלום, נראה כי [[:תמונה:'+imageName+']] אשר העלית אינה בשימוש הוגן ולכן צפויה להימחק בקרוב. אנא עיין ב[[ויקיפדיה:רישוי/שימוש הוגן|וויקיפדיה:רישוי/שימוש הוגן]] וב[[ויקיפדיה:שאלות ותשובות/זכויות יוצרים|וויקיפדיה:שאלות ותשובות/זכויות יוצרים]]. אם יש לך השגות על המחיקה הצפויה, אנא פנה אליי בדף השיחה שלי. ';
     comment = 'בעיה בשימוש הוגן בתמונה'
  }
  document.editform.wpTextbox1.value += '\n' + txt + '~~' + '~~\n';
  document.editform.wpSummary.value = comment;
  document.editform.wpSave.click();
}

function mnx_onload() {
  if (wgNamespaceNumber == 6) { // image name space
    addLink('p-tb', 'javascript:mnx_mark(\'ns_temp\', \'warn\')', ns_text, 'mark-no-source', ns_tooltip, null, null);
    addLink('p-tb', 'javascript:mnx_mark(\'nl_temp\', \'warn\')', nl_text, 'mark-no-license', nl_tooltip, null, null);
    addLink('p-tb', 'javascript:mnx_mark(\'nsl_temp\', \'warn\')', nsl_text, 'mark-no-license-source', nsl_tooltip, null, null);
    addLink('p-tb', 'javascript:mnx_mark(\'c_temp\', \'warn\')', c_text, 'mark-commons', c_tooltip, null, null);
    addLink('p-tb', 'javascript:mnx_mark(\'fu_temp\', \'warn\')', fu_text, 'mark-no-fairuse', fu_tooltip, null, null);
    addLink('p-tb', 'javascript:mnx_mark(\'v_temp\', \'no_warn\')', v_text, 'mark-verified', v_tooltip, null, null);
    addLink('p-tb', 'javascript:mnx_mark(\'p_temp\', \'no_warn\')', p_text, 'mark-private', p_tooltip, null, null);
  }
  var fakeaction = getParamValue('fakeaction');
  var template_type = getParamValue('template_type');   // Fetch what template to add

  if (fakeaction == 'ns_temp'){ // מקור
    mnx_addTemplate('ns_temp');
  }
  if (fakeaction == 'nsl_temp'){ // מקור ורישיון
    mnx_addTemplate('nsl_temp');
  }
  if (fakeaction == 'nl_temp'){ // רישיון
    mnx_addTemplate('nl_temp');
  }
  if (fakeaction == 'v_temp'){ // אומת
    mnx_addTemplate('v_temp');
  }
  if (fakeaction == 'p_temp'){ // שימוש אישי
    mnx_addTemplate('p_temp');
  }
  if (fakeaction == 'c_temp'){ // ויקישיתוף
    mnx_addTemplate('c_temp');
  }
  if (fakeaction == 'fu_temp'){ // שימושהוגן
    mnx_addTemplate('fu_temp');
  }
  if (fakeaction == 'warn') {
   mnx_addUserWarningTemplate(decodeURIComponent(getParamValue('target')), template_type);
  }
}

$(mnx_onload);

/* Add links to diff pages */
/* Created by [[User:Yonidebest]]; */

importUserScript(64);

function welcomeRecentChanges() {
    if( wgCanonicalSpecialPageName != "Recentchanges" ) return; // not recent changes
    var links = document.getElementById("bodyContent").getElementsByTagName("a");
    var talkLink, user, welcomeLink;
    for( var i = 1; i < links.length; i++ ) {
        talkLink = links[i];
        if( talkLink.innerHTML != "שיחה" ) continue; // not a talk page link
        if( talkLink.parentNode.nodeName.toLowerCase() != "li" || talkLink.parentNode.parentNode.className != "special" ) continue; // not in the right place
        if( talkLink.className != "new" ) continue; // not a red link
        user = talkLink.previousSibling.previousSibling.innerHTML;
        if( /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test( user ) ) continue; // an anonymous change

        var span = document.createElement("span");
        span.appendChild( document.createTextNode( " (" ) );
        span.appendChild( createWarningLink( user, "ברוך בואך", "הוספת ברכת ברוך הבא למשתמש", "null" ) );
        span.appendChild( document.createTextNode( ")" ) );
        talkLink.parentNode.insertBefore( span, talkLink.nextSibling );
    }
}
$(welcomeRecentChanges);

//
// סקריפט 12: לקוח מ[[ויקיפדיה:סקריפטים/12]]
// הקוד מוסיף אפשרות לערוך את ההקדמה של הערך
//
function addEditSection0() {
  x = document.getElementById('ca-edit');
  if (!x) return;
  ta['ca-edit-0'] = ['', 'ערוך את ההקדמה'];
  y = document.createElement('LI');
  y.id = 'ca-edit-0';
  
  // if is edit page and is section 0, then mark "0" as seleted and mark "עריכה" as unseleted
  var isSelected = (x.className.indexOf('selected') != -1);
  var isTalk = (x.className.indexOf('istalk') != -1);
  var isSection0 = (/&action=edit&section=0$/.test(window.location.href));
  //alert(isSelected + " " + isTalk + " " + isSection0);
  if (isSelected) {
    if (isSection0) {
      y.className = x.className;
      x.className = (isTalk) ? 'istalk' : '';
    } else {
      if (isTalk) y.className = 'istalk';
    }
  }

  // add the "0" li element
  var z = document.createElement('A');
  z.href = x.childNodes[0].href + '&section=0';
  z.appendChild(document.createTextNode('0'));
  y.appendChild(z);
  x.parentNode.insertBefore(y,x.nextSibling);

  // add summary if editing section 0
  if ( isSection0 )
    document.getElementById("wpSummary").value = "/* עריכת ההקדמה */ ";
}
$(addEditSection0);
// עד כאן סקריפט 12

function picVerified() {
 if (wgNamespaceNumber != 6) return;
 var picVerifiedSpan = document.getElementById('picVerified');
 var filetocDiv = document.getElementById('filetoc');
 if (picVerifiedSpan != null) { // verified
   filetocDiv.style.background = '#eFFFFF';
 } else { // not verified
   filetocDiv.style.background = '#FFF0F5';
 }
}
 
$(picVerified);
// Revert tools by Lorian
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();
}
});
 
  addOnloadHook(addDeleteOption);
//עד כאן סקריפט השחזורים