User:Lectrician1/SplitWatchlist.js

Note: After publishing, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Press Ctrl-F5.
// Splits your watchlist into 2 columns.
// Left column is entity changes. Right column is all other page changes
// Author: Lectrician1
// License: CC0

var styles = `
    .column-wrapper {
      display: flex;
    }

    .special {
      margin: 5px;
    }
  `;

// Create a style element and append it to the head
var styleElement = document.createElement('style');
styleElement.type = 'text/css';
styleElement.appendChild(document.createTextNode(styles));
document.head.appendChild(styleElement);

// Duplicate and place below
$('.special').each(function(index) {
  var duplicate = $(this).clone();
  $(this).after(duplicate);

  // Add classes to the left and right columns
  $(this).addClass('column-wrapper-left');
  duplicate.addClass('column-wrapper-right');
});

// Wrap original and duplicate in a column wrapper
var specialUls = $('.special + .special');

// Iterate over each pair and wrap them along with the header in a parent div
specialUls.each(function(index, element) {
  var currentPair = $(element).prevUntil(':not(.special)').addBack();
  currentPair.add(currentPair.prev('.header')).wrapAll('<div class="column-wrapper"></div>');
});

// Filter left and right columns based on criteria
$('.column-wrapper-left').each(function() {
  $(this).find('li').each(function() {
    if ($(this).find('span.wb-itemlink-id').length == 0) {
      $(this).remove();
    }
  });
});

$('.column-wrapper-right').each(function() {
  $(this).find('li').each(function() {
    if ($(this).find('span.wb-itemlink-id').length != 0) {
      $(this).remove();
    }
  });
});