Skip to content

Instantly share code, notes, and snippets.

@balazs-endresz
Last active December 15, 2016 12:05
Show Gist options
  • Save balazs-endresz/2f7a68e2f7912e9369904020c361ff93 to your computer and use it in GitHub Desktop.
Save balazs-endresz/2f7a68e2f7912e9369904020c361ff93 to your computer and use it in GitHub Desktop.
Hide status bar on Slack
// ==UserScript==
// @name Hide status bar on Slack
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author You
// @match https://*.slack.com/*
// @grant none
// ==/UserScript==
(function() {
'use strict';
var observeDOM = (function(){
var MutationObserver = window.MutationObserver || window.WebKitMutationObserver,
eventListenerSupported = window.addEventListener;
return function(obj, callback){
if( MutationObserver ){
// define a new observer
var obs = new MutationObserver(function(mutations, observer){
if( mutations[0].addedNodes.length || mutations[0].removedNodes.length )
callback();
});
// have the observer observe foo for changes in children
obs.observe( obj, { childList:true, subtree:true });
}
else if( eventListenerSupported ){
obj.addEventListener('DOMNodeInserted', callback, false);
obj.addEventListener('DOMNodeRemoved', callback, false);
}
};
})();
function removeStatusBar(e){
$('.im_name, .channel_name').removeAttr('href');
}
var interval = setInterval(function(){
if($('.im_name, .channel_name').length){
removeStatusBar();
clearInterval(interval);
}
}, 500);
// Observe a specific DOM element:
observeDOM(document.getElementById('channels'), removeStatusBar);
observeDOM(document.getElementById('direct_messages'), removeStatusBar);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment