-
-
Save m-hume/97e8efc292f237c1e2a211138d5d3512 to your computer and use it in GitHub Desktop.
Outlook.com Ad-Blocker
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Office.com Ad-Blocker | |
// @namespace http://tampermonkey.net/ | |
// @version 1.2 | |
// @description try to take over the world! | |
// @author You | |
// @match https://outlook.live.com/owa/* | |
// @grant none | |
// @require http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
// Create a body observer instance | |
var body_observer = new MutationObserver(function( mutations ) { | |
mutations.forEach(function( mutation ) { | |
var newNodes = mutation.addedNodes; // DOM NodeList | |
if( newNodes !== null ) { // If there are new nodes added | |
var adToHide = $('._n_h'); | |
if(adToHide.length){ | |
var mainContent = adToHide.next().next(), | |
runManip = function(){ | |
mainContent.css('right', '0px'); | |
adToHide.hide(); | |
$('._n_15').hide(); //remove 'Upgrade to Premium' button | |
}; | |
runManip(); | |
var main_observer = new MutationObserver(function( mutations ) { | |
mutations.forEach(function( mutation ) { | |
if( mutation.type == 'attributes' && mutation.attributeName == 'style' ) { | |
if(mutation.target.style.right && mutation.target.style.right != '0px'){ // elements style 'right' has a value and its not 0px | |
//console.log('main_observer mutation', mutation); | |
runManip(); // this will cause the mutation to trigger again | |
} | |
} | |
}); | |
}); | |
main_observer.observe(mainContent[0], {attributes: true}); // listen for attribute changes on the message display i.e. when they set the right position again. | |
body_observer.disconnect(); // now '._n_h' exists stop monitoring | |
} | |
} | |
}); | |
}); | |
body_observer.observe($('body')[0], {childList: true}); // just listen for new nodes added directly to the body | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment