mawiseman / Strikeout Unlicensed Users in Confluence

// ==UserScript==
// @name           Strikeout Unlicensed Users in Confluence
// @author         Mark Wiseman
// @namespace      https://openuserjs.org/users/mawiseman
// @description    Strikes out unlincsed users for better visibility in confluence
// @icon           https://wac-cdn-2.atlassian.com/image/upload/f_auto,q_auto/assets/img/favicons/atlassian/apple-touch-icon-57x57.png
// @copyright      2021, wiseman.net.au
// @version        1.0.8
// @license        MIT
// @grant          none
// @match          https://*.jira.com/wiki/*
// @match          https://*.atlassian.net/wiki/*
// ==/UserScript==

var $ = window.jQuery;

$(document).ajaxStop(function () {
  // It upsets me I am using timouts here
  // I haven't figured out what to use to handle the confluence "finish render" event

  setTimeout(ProcessUnlicensedLinks, 2000);
})

function ProcessUnlicensedLinks() {
  console.log('ProcessUnlicensedLinks');

  // Reset styles after ajax update

  $('a.unlicensed').each(function (index, value) {
    $(this).css('text-decoration', '');
    $(this).css('color', '');

    console.log('Removing Unlicensed: ' + $(this).text());
  });

  $('a').removeClass('unlicensed');

  // Apply styles

  $('a:contains("(Unlicensed)"), a:contains("(Deactivated)"), a:contains("(Deleted)")').each(function (index, value) {
    $(this).addClass('unlicensed');

    $(this).css('text-decoration', 'line-through');
    $(this).css('color', '#add8e6');

    console.log('Applying Unlicensed: ' + $(this).text());
  });
}