Show/Hide issue comments for GitHub Issues

Add floating button to show/hide issue comments of GitHub Issues, to see discussion events / references easier.

Stan na 02-02-2018. Zobacz najnowsza wersja.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

You will need to install an extension such as Tampermonkey to install this script.

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==UserScript==
// @name         Show/Hide issue comments for GitHub Issues
// @namespace    http://kyanny.me/
// @version      1.0.0
// @description  Add floating button to show/hide issue comments of GitHub Issues, to see discussion events / references easier.
// @author       Kensuke Nagae
// @match        https://github.com/*/*/issues/*
// @grant        none
// ==/UserScript==

(function() {
  'use strict';

  var button = document.createElement('button');
  button.setAttribute('style', 'position: fixed; top: 10px; right: 5px;');
  button.setAttribute('data-display', "block");
  var text = document.createTextNode('Show/Hide comments');
  button.appendChild(text);

  button.onclick = function() {
    var display = button.getAttribute('data-display');

    var comments = Array.prototype.slice.call(document.querySelectorAll('.js-comment-container'));

    if (display === "hidden") {
      // Show
      Array.forEach(comments, function(comment) {
        comment.style = 'display: block';
      });
      button.setAttribute('data-display', "block");
    } else {
      // Hide
      Array.forEach(comments, function(comment) {
        comment.style = 'display: none';
      });
      button.setAttribute('data-display', "hidden");
    }
  };

  document.body.appendChild(button);
})();