GitterArchiveLinks

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

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

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.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==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://greatest.deepsurf.us/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);
}