pirvu / Bitbucket Show/Hide behind only branches button

// ==UserScript==
// @name         Bitbucket Show/Hide behind only branches button
// @namespace    http://tampermonkey.net/
// @version      0.3
// @description  Adds a buton to hide branches that have 0 commits ahead
// @author       Valeriu Parvu valeriuparvu@gmail.com
// @match        http*://*/projects/*/repos/*/branches*
// @grant        none
// @require      http://code.jquery.com/jquery-3.3.1.min.js
// @copyright    2019, pirvu (https://openuserjs.org/users/pirvu)
// @updateURL    https://openuserjs.org/meta/pirvu/Bitbucket_ShowHide_behind_only_branches_button.meta.js
// @license      MIT
// ==/UserScript==

(function () {
  'use strict';
  let visibile = true;
  const applyVisibility = function () {
    const elements = $("#branch-list .count-graph.ahead-graph.empty-count, #branch-list .no-changes").parent().parent().parent();
    if (visibile) {
      elements.show()
    }
    else {
      elements.hide()
    }
  }
  const b = $(`<a href="#" id="custom_hide_non_ahead_branches" class="aui-button" tabindex="0">Toogle behind only</a>`).click(function () {
    visibile = !visibile;
    applyVisibility()
  });
  setInterval(applyVisibility, 250);
  $(`.aui-page-panel-inner`).css("min-height", "1000px");
  $(`.aui-toolbar2-secondary.commit-badge-container`).prepend("&nbsp;").prepend(b);
})();