Skip to content

Instantly share code, notes, and snippets.

@dszakallas
Last active April 13, 2016 21:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dszakallas/400eaf155021136b6649 to your computer and use it in GitHub Desktop.
Save dszakallas/400eaf155021136b6649 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name RemoveMessengerMobileAdBanner
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Removes the annoying ad banner form the top of Messenger.
// @author Midiparse
// @match https://www.messenger.com/*
// @grant none
// ==/UserScript==
/* jshint -W097 */
'use strict';
/*!
* contentloaded.js
*
* Author: Diego Perini (diego.perini at gmail.com)
* Summary: cross-browser wrapper for DOMContentLoaded
* Updated: 20101020
* License: MIT
* Version: 1.2
*
* URL:
* http://javascript.nwbox.com/ContentLoaded/
* http://javascript.nwbox.com/ContentLoaded/MIT-LICENSE
*
*/
// @win window reference
// @fn function reference
function contentLoaded(win, fn) {
var done = false, top = true,
doc = win.document,
root = doc.documentElement,
modern = doc.addEventListener,
add = modern ? 'addEventListener' : 'attachEvent',
rem = modern ? 'removeEventListener' : 'detachEvent',
pre = modern ? '' : 'on',
init = function(e) {
if (e.type == 'readystatechange' && doc.readyState != 'complete') return;
(e.type == 'load' ? win : doc)[rem](pre + e.type, init, false);
if (!done && (done = true)) fn.call(win, e.type || e);
},
poll = function() {
try { root.doScroll('left'); } catch(e) { setTimeout(poll, 50); return; }
init('poll');
};
if (doc.readyState == 'complete') fn.call(win, 'lazy');
else {
if (!modern && root.doScroll) {
try { top = !win.frameElement; } catch(e) { }
if (top) poll();
}
doc[add](pre + 'DOMContentLoaded', init, false);
doc[add](pre + 'readystatechange', init, false);
win[add](pre + 'load', init, false);
}
}
contentLoaded(window, function(event) {
var banner = document.getElementsByClassName('_s15');
if(banner && banner.length && banner[0]) {
banner[0].parentNode.removeChild(banner[0]);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment