MediaWiki:WLHEditLinks/code.js

/*** WLH edit links ********************************************************* * Adds links for each linked page on Special:WhatLinksHere ****************************************************************************/ function addEditLinksToWLH { $.each($('#mw-whatlinkshere-list li a:not([title="Special:WhatLinksHere"])'), function {   var elem = $(this),      pageName = elem.attr('href').replace('?redirect=no','') + '?action=edit',      element = $(' ', { class: 'mw-whatlinkshere-edit' })     .before(' ')      .append('(') .append(       $('', { href: pageName, text: 'edit' })     )      .append(')')      .insertAfter(elem);  }); } $(function { if ($('body').hasClass('mw-special-Whatlinkshere')) {    addEditLinksToWLH  } }); /*** File usage edit links ************************************************** * Adds links for each linked page in File usage on file pages ****************************************************************************/ function addEditLinksToFilePages { $.each($('#mw-imagepage-section-linkstoimage .grid-3 a'), function {   var elem = $(this),      pageName = elem.attr('href') + '?action=edit',      element = $(' ', { class: 'mw-imagepage-section-linkstoimage-edit' })     .before(' ')      .append('(') .append(       $('', { href: pageName, text: 'edit' })     )      .append(')')      .insertAfter(elem);  }); } $(function { if ($('body').hasClass('ns-6')) {    addEditLinksToFilePages    var pagelistcontent = document.querySelector('.page-list-content');    var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) {       var rn = m.removedNodes;        rn.forEach(function(n) { if ($(n).hasClass('wikiaThrobber')) { addEditLinksToFilePages; }       });      });    });    if(pagelistcontent) observer.observe(pagelistcontent, { childList: true }); } });