GitterArchiveLinks

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

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

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

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

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

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

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.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

// ==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);
}