Jump to content

User:GhostInTheMachine/test.js

From Wikipedia, the free encyclopedia
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
// $("#mw-content-text a[href^='/wiki/'].nonimage").prepend(' <<').append('>> ');

// $('#firstHeading').append(' ###');

// $('#firstHeading').append(' <a id="make_link_list" href="#"> Make link list </a>');

$(function(){
  var menuTabs = $('#p-cactions > div > ul');

  menuTabs.append($('<li id="sd-link-maker"><a href="#" title="Build list of SDlinks">SDlinks</a></li>'))
  $('#sd-link-maker').click(makeSDlinks);
});

function makeSDlinks(){
  var links = $("#mw-content-text a[href^='/wiki/'].nonimage");
  var body = $("#mw-content-text");
  body.html("<ul>");
  links.each(function() {
    var page = $(this).text();
    if( page ) {
      body.append( $("<li>").html( ': {{SDlink|' + page + '}}' ));
    }
  });
}