Jump to content

User:GhostInTheMachine/UI.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.
//// my UI changes

// remove the Wikipedia logo to save space in the sidebar
// remove the ID so that the first portal menu heading is shown (see [[Phab:T268157]])
$('#p-logo').hide().removeAttr('id');

// remove the logout link to make things safer (and save space)
$('#pt-logout').hide();

// move the Mobile link to the end of the footer row
$('#footer-places-mobileview').appendTo('#footer-places')

// add some style so that the left panel headings stand out a bit -- black text over pale orange?
mw.util.addCSS('.vector-menu-portal .vector-menu-heading { background-color: cornsilk; color: black;}');

// use bull characters in hlists
mw.util.addCSS('.hlist li::after {content: " • " !important;} .hlist li:last-child::after {content: none !important;}');

// open a gap under the page title to allow for gadgets
mw.util.addCSS('.mw-body .firstHeading {margin-top: 1em;}');

// move main page link to the top of the tools menu
$('#p-tb > div > ul').prepend($('#n-mainpage-description'));

// create new "My pages" and "My gadgets" portlet menus at the top of the sidebar
"pages gadgets"
  .split(' ').forEach(function(p){
  $('#p-navigation').clone().attr('id', 'p-my-'+p).insertBefore('#p-navigation');
  $('#p-my-'+p+' .vector-menu-heading-label').text('My '+p);
  $('#p-my-'+p+'>div>ul').text('');
});

// add a set of my subpages to the "My pages" menu
mw.util.addPortletLink ('p-my-pages', '/wiki/User:GhostInTheMachine', 'HOME');

"All Drafts Help Misc Modules Other Layout Projects Scripts Test Tidying TidyingSD Timeline TODO WIP"
  .split(' ').forEach(function(p){
  mw.util.addPortletLink ('p-my-pages', '/wiki/User:GhostInTheMachine/' + p, '/ ' + p);
});

// add link to the "My gadgets" menu -- ⇑ go to top -- click -> scroll
$(mw.util.addPortletLink( 'p-my-gadgets', '#', String.fromCharCode(8657)+' go to top', 'p-my-gadgets-top', 'Go to the top'))
  .click(function(e){ e.preventDefault(); $('html, body').animate({scrollTop: 0}); });

// add link to the "My gadgets" menu -- / sub-pages -- real link
mw.util.addPortletLink('p-my-gadgets', mw.config.get('wgServer')+mw.config.get('wgArticlePath').replace("$1", "Special:PrefixIndex/"+mw.config.get('wgPageName')+"/"), '/ sub-pages');

// add link to the "My gadgets" menu -- ⇓ go to end -- click -> scroll
$(mw.util.addPortletLink( 'p-my-gadgets', '#', String.fromCharCode(8659)+' go to end', 'p-my-gadgets-end', 'Go to the end'))
  .click( function(e){ e.preventDefault(); $('html, body').animate({scrollTop: $(document).height()}); });

// add link to the "My gadgets" menu -- Process this page with Refill
mw.util.addPortletLink('p-my-gadgets', "https://refill.toolforge.org/ng/result.php?page="+mw.config.get('wgPageName')+"&wiki=en&method-wiki=Fix%20page&noaccessdate=on", 'Refill');

// hide some of the sidebar menus
"p-navigation p-interaction p-coll-print_export p-lang"
  .split(' ').forEach(function(p){
    $('#'+p).hide();
  });

// move assorted gadgets from their default menu into the "My gadgets" menu
// add a loader delay -- Twinkle seems very slow to load
mw.loader.using( 'ext.gadget.Twinkle', function () {
  "todo_add todo_view tw-lastdiff ca-make-sd-links us-majavah-align t-dumb-quotes ca-wping ca-AutoEd"
    .split(' ').forEach(function(p){
      ui_move_gadget(p, 20);
    });
});

// wait for the gadget "$1" to get loaded - retry $2 times with a delay of 100ms
function ui_move_gadget(id, safety) {
  console.log('ui_move_gadget '+id, safety);
  var $id = $('#' + id);
  if($id.length < 1 && safety > 0) {
    setTimeout(ui_move_gadget, 100, id, safety-1);
    return;
  }
  $id.appendTo('#p-my-gadgets > div > ul');
}

// VERY dirty quick fix following Thursday 6 June 2024 to stop the diff spots from U+26AB — see Phab T366845
// mw.hook( 'wikipage.diff' ).add( function() { $('.mw-diff-movedpara-left, .mw-diff-movedpara-right').text(''); } );

// quick fix following Thursday 20 June 2024 mess to diff display  — see Phab T361717
mw.util.addCSS('.diff-deletedline { border-color: #ffe49c; }');
mw.util.addCSS('.diff-addedline { border-color: #a3d3ff; }');
mw.util.addCSS('.diff-deletedline .diffchange, .mw-diff-inline-deleted del, .mw-diff-inline-changed del, .mw-diff-inline-moved del { background: #ffe49c; }');
mw.util.addCSS('.diff-addedline .diffchange, .mw-diff-inline-added ins, .mw-diff-inline-changed ins, .mw-diff-inline-moved ins { background: #a3d3ff; }');