Skip to content

Instantly share code, notes, and snippets.

@wernull
Last active December 11, 2019 04:03
Show Gist options
  • Save wernull/a5db9d75946ad54da5fd to your computer and use it in GitHub Desktop.
Save wernull/a5db9d75946ad54da5fd to your computer and use it in GitHub Desktop.
Slack image and video hide userscript
.sgh-flyout {
position: absolute;
top: 0;
left: 0;
z-index: 9999;
}
.sgh-icons {
position: relative;
float: left;
right: 0;
margin-left: -100%;
-webkit-transition: margin-left .25s;
padding: .5em 0;
background: #e5e5e5;
border: 1px solid #ddd;
border-radius: 0 0 4px 0;
}
.sgh-icons:hover {
margin-left: 0;
}
.sgh-hide {
float: left;
clear: both;
white-space: nowrap;
color: #999;
padding: 0 .75em 0 .5em;
margin-bottom: .5em;
}
.sgh-hide:hover {
color: #2d2d2d;
}
.sgh-icon {
padding-right: .5em;
}
.sgh-flyout a:hover .sgh-icon {
text-decoration: none;
}
.sgh-hit {
position: absolute;
top: 0;
right: -1.5em;
width: 1.5em;
height: 7em;
}
.sgh-tab {
position: absolute;
top: .75em;
left: 0;
width: .5em;
-webkit-transition: width .25s;
height: 2em;
background: #e5e5e5;
border: 1px solid #ddd;
border-radius: 0 4px 4px 0;
}
.sgh-icons:hover .sgh-tab {
width: 0;
border: none;
}
sgh = {};
sgh.InitSlackGifHide = function(){
// trigger message collapse when image is clicked
$("#messages_container").delegate('.msg_inline_img','click',function(e) {
e.preventDefault();
e.stopPropagation();
$(e.target).closest('.message').find('.msg_inline_img_collapser').trigger('click');
});
}
sgh.SetFlyoutEvents = function () {
// hide all items of category clicked in flyout
$(".sgh-hide").on('click',function(e) {
e.preventDefault();
var closeMessage = null;
switch($(e.target).data("hide")) {
case "images":
closeMessage = $('.msg_inline_img').closest('.message');
break;
case "video":
closeMessage = $('.msg_inline_video').closest('.message');
break;
case "all":
closeMessage = $('.message');
break;
}
closeMessage.find('.fa-caret-down').trigger('click');
});
}
$(function(){
$("body").append('<div class="sgh-flyout"><div class="sgh-icons"><div class="sgh-hit"><span class="sgh-tab"></span></div><a href="#hide" data-hide="images" class="sgh-hide"><i class="sgh-icon icon-collapse-alt"></i>Images</a><a href="#hide" data-hide="video" class="sgh-hide"><i class="sgh-icon icon-collapse-alt"></i>Videos</a><a href="#hide" data-hide="all" class="sgh-hide"><i class="sgh-icon icon-collapse-alt"></i>All</a></div></div>');
sgh.InitSlackGifHide();
sgh.SetFlyoutEvents();
});
@wernull
Copy link
Author

wernull commented Jun 24, 2014

Just like https://gist.github.com/wernull/7330137 but for Slack.com

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment