משתמש:Yonidebest/monobook.js/removeimagelinks.js

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

  • פיירפוקס / ספארי: להחזיק את המקש Shift בעת לחיצה על טעינה מחדש (Reload) או ללחוץ על צירוף המקשים Ctrl-F5 או Ctrl-R (במחשב מק: ⌘-R).
  • גוגל כרום: ללחוץ על צירוף המקשים Ctrl-Shift-R (במחשב מק: ⌘-Shift-R).
  • אדג': להחזיק את המקש Ctrl בעת לחיצה על רענן (Refresh) או ללחוץ על צירוף המקשים Ctrl-F5.
//
// Adds a "remove me" link in image pages under the "קישורי תמונות" section
// created by [[user:Yonidebest]]
//
function addRemoveImageLinks() {
 // add the link to image pages
 if (wgNamespaceNumber == 6 && wgAction == 'view') {
   var ul = document.getElementById('filelinks').nextSibling.nextSibling;

   if (!ul) return;

   var lis = ul.getElementsByTagName('LI');

   for (var i = 0; i < lis.length; i++) {
      link = document.createElement('A');
      link.href = '/w/index.php?title=' + lis[i].childNodes[0].title + '&action=edit&removeimage=yes&name=' + encodeURIComponent(wgTitle);
      link.appendChild(document.createTextNode('הסר'));
      lis[i].appendChild(document.createTextNode(' ('));
      lis[i].appendChild(link);
      lis[i].appendChild(document.createTextNode(')'));
   }
 }

 // remove image and save
 if (getParamValue('removeimage') == 'yes') {
   var imageName = decodeURIComponent(getParamValue('name'));
   if (imageName) {
     var rx = new RegExp('\\[\\[\\s?:?(תמונה|image)\\s?:\\s?(' + imageName + '|' + imageName.replace(' ', '_') + ')([^\\[]|\\[\\[[^\\]]*\\]\\])*\\]\\]', 'ig');
     document.editform.wpTextbox1.value = document.editform.wpTextbox1.value.replace(rx, '');
     document.editform.wpSummary.value = 'הסרת [[תמונה:' + imageName + ']]';
     document.editform.wpSave.click();
   }
 }
}

$(addRemoveImageLinks);