fouad / Jira Hide filtered Epics in Scrum Board

// ==UserScript==
// @name         Jira Hide filtered Epics in Scrum Board
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  Hides epics that are filtered in jira board, filtering usually is because an epic tasks are complete, or because epics are not in this version
// @author       Fouad
// @match        https://*.atlassian.net/secure/RapidBoard*
// @require      http://code.jquery.com/jquery-latest.js
// @grant        none
// ==/UserScript==

// requires jQuery, but use noConflict version in order not to conflict with Jira code
(function ($, undefined) {
  $(function () {
    'use strict';
    
    var hideEpics = false;
    
     $(document).ready(function () {
         var headbar = document.getElementById('ghx-board-name'); //  ghx-controls-plan  ghx-controls// ghx-view-selector ghx-board-name
         
         // Embed a link button right next to the board name, and bind it to our action
         var actButton = document.createElement('span');
         actButton.innerHTML = '<span> - </span><a id="btnHideEpics" role="button" href="#" class="js-quickfilter-button" title="" >Hide Epics</a>';
         //actButton.innerHTML = '<a  id="btnHideEpics" href="#hide-epics">Hide Epics</div></a>';
         headbar.appendChild(actButton);
          $('#btnHideEpics').click(function(){
             console.log("registered click!!!");
            updateEpics();
        });

     });

    function updateEpics(){
       console.log('User Script - Hiding epics!');
        // Select the epic divs that are filtered out.
       var selector = "div.ghx-classification-scrollview > div.ghx-classification-cards.ui-sortable > div.js-sortable.ghx-classification-item.ghx-closed.ui-droppable.ghx-filtered";
       hideEpics = !hideEpics;
       if (hideEpics)
       {
           $(selector).hide(); //('display', 'none');
           $('#btnHideEpics').html('Show Epics');
       }
        else
        {
            $(selector).show();
            $('#btnHideEpics').html('Hide Epics');
        }
    }
 });
})(window.jQuery.noConflict(true));