GitterArchiveLinks

Gitter archive pages: show only messages containing 'http' links

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

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

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        GitterArchiveLinks
// @namespace   https://gitter.im/
// @description Gitter archive pages: show only messages containing 'http' links
// @include     https://gitter.im/*/live/archives/*/*/*
// @version     2
// @grant       none
// ==/UserScript==

// Based on LongMsgBuster
// https://greasyfork.org/en/scripts/26053-longmsgbuster

document.addEventListener('keydown', function(e) {
  // Key Binding | Defaults:
  // CTRL~CMD + ALT + F -> Filter blocks
  var filter = e.keyCode === 70; // F
  var middle = e.altKey;
  var first = e.metaKey || e.ctrlKey;

  if (first && middle && filter) {
    applyToDomElements(
      document.querySelectorAll('.chat-item'),
      hideChatBlock);
  }
});

function applyToDomElements(elements, action) {
  which_things = [];
  for (var i = 0, l = elements.length; i < l; i++) {
    chat_text = elements[i].getElementsByClassName('chat-item__text js-chat-item-text')[0].innerText;
    if(!chat_text.includes('http')) {
      which_things.push(i);
    }
  }

  for(i=0; i<which_things.length; i++) {
    hideChatBlock(elements[which_things[i]]);
  }
}

function hideChatBlock(block) {
  // Straight up delete the node from the tree
  block.parentNode.removeChild(block);
}