Skip to content

Instantly share code, notes, and snippets.

@kazmiekr
Created February 10, 2015 22:11
Show Gist options
  • Select an option

  • Save kazmiekr/92140e674e01850e34af to your computer and use it in GitHub Desktop.

Select an option

Save kazmiekr/92140e674e01850e34af to your computer and use it in GitHub Desktop.
Script to remove any giphy reference in slack
// ==UserScript==
// @name Gif off my lawn
// @description banish the scourge of giphys
// @include https://universalmind.slack.com/*
// ==/UserScript==
(function() {
var classList = [ 'inline_attachment', 'msg_inline_img_holder' ];
var blackList = [ 'giphy' ];
var classString = classList.reduce( function ( memo, item, index ) {
var selector = blackList.map( function ( keyword ) {
return "." + item + "[data-real-src*='" + keyword + "']";
} );
if ( index === 0 ) {
return selector;
} else {
return memo + ", " + selector;
}
}, "" );
var css = classString + "{\n display: none !important;\n }";
if (typeof GM_addStyle != "undefined") {
GM_addStyle(css);
} else if (typeof PRO_addStyle != "undefined") {
PRO_addStyle(css);
} else if (typeof addStyle != "undefined") {
addStyle(css);
} else {
var node = document.createElement("style");
node.type = "text/css";
node.appendChild(document.createTextNode(css));
var heads = document.getElementsByTagName("head");
if (heads.length > 0) {
heads[0].appendChild(node);
} else {
// no head yet, stick it whereever
document.documentElement.appendChild(node);
}
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment