Last active
December 1, 2015 22:41
-
-
Save oxchronxo/c8865a58dc297980fcf7 to your computer and use it in GitHub Desktop.
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 YMAC = (Y)ahoo (M)ail (A)d (C)leaner | |
// @description Remove ads in Yahoo Mail | |
// @version 1.26 | |
// @date 30.11.2015 | |
// @author Eric Fehrenbacher | |
// @grant metadata | |
// @updateUrl https://gist.github.com/oxchronxo/c8865a58dc297980fcf7/raw/ymac.user.js | |
// @downloadUrl https://gist.github.com/oxchronxo/c8865a58dc297980fcf7/raw/ymac.user.js | |
// @include http://*.mail.yahoo-inc.com/* | |
// @include https://*.mail.yahoo-inc.com/* | |
// @include http://*.mail.yahoo.com/* | |
// @include https://*.mail.yahoo.com/* | |
// @require http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js | |
// ==/UserScript== | |
var YMAC = (typeof(YMAC) !== "undefined") ? YMAC : { | |
data: { | |
ids: [ | |
"#UH", | |
"#uhWrapper", | |
"#masterNav", | |
"#yucs-network_link", | |
"#nav", | |
"#shellcontent", | |
"#main", | |
"#theMNWAd", | |
"#theAd", | |
"#slot_REC", | |
"#slot_LREC", | |
"#slot_FSRVY", | |
"#slot_MIP", | |
"#slot_MNW", | |
"#searchAd", | |
"#slot_mbrec", | |
"#slot_MB", | |
"#slot_BL1", | |
"#slot_TL1", | |
"#spritzAd", | |
"#yucs-disclaimer", | |
".list-view-items-page .ml-bg .mb-list-ad", | |
".yui3-feedback", | |
".typeahead-content-box ul.typeahead-list", | |
".bg-container", | |
"#web-search-btn", | |
".yucs td", | |
".search-box-inner", | |
"#mail-search-btn", | |
"#web-search-btn" | |
] | |
}, | |
state: { | |
initialized: false, | |
collecting: false, | |
processing: false | |
}, | |
init: function () { | |
console.log("init"); | |
var initialized = this.state.initialized; | |
if (!initialized) { | |
initialized = true; | |
var processElements = $.proxy(this.processElements, this); | |
processElements(); | |
$("#storm-listnav li a").on("click", function () { | |
setTimeout(function () { | |
console.log("trigger: click"); | |
processElements(); | |
}, 500); | |
setTimeout(function () { | |
console.log("post trigger: click"); | |
processElements(); | |
}, 2000); | |
}); | |
$(window).on("focus", function () { | |
setTimeout(function () { | |
console.log("trigger: focus"); | |
processElements(); | |
}, 500); | |
}); | |
} else { | |
console.log("rejecting request: already initialized"); | |
} | |
}, | |
collectElements: function (ids) { | |
console.log("collectElements"); | |
var elements = []; | |
var collecting = this.state.collecting; | |
if (!collecting) { | |
collecting = true; | |
$.each((ids ? ids : this.data.ids), function (index, value) { | |
$(value).each(function(index) { | |
elements.push({id: value, node: this}); | |
}); | |
}); | |
collecting = false; | |
} else { | |
console.log("rejecting request: already processing"); | |
} | |
return elements; | |
}, | |
processElements: function (elements) { | |
console.log("processElements"); | |
var processing = this.state.processing; | |
if (!processing) { | |
processing = true; | |
$.each((elements = elements ? elements : this.collectElements()), function (key, value) { | |
if (this.node !== null) { | |
var css = []; | |
console.log("proccessing: " + this.id); | |
switch (this.id) { | |
case "#UH": | |
css.push("height: 36px;"); | |
break; | |
case "#mail-search-btn": | |
css.push("margin-top: 1px; background-color: #EFEFEF; box-shadow: 0 1px 0 0 #DDDDDD; margin-left: 1px; color: #000000;"); | |
break; | |
case "#web-search-btn": | |
css.push("visibility: hidden;"); | |
break; | |
case ".typeahead-content-box ul.typeahead-list": | |
css.push("position: absolute; width: 480px;"); | |
break; | |
case "#uhWrapper": | |
css.push("top: 2px;"); | |
break; | |
case "#main": | |
css.push("marginRight: 0px; maxWidth: 100%; top: 38px;"); | |
break; | |
case ".search-box-inner": | |
css.push("border: 1px solid #DDDDDD;"); | |
break; | |
case "#shellcontent": | |
css.push("right: 0px;"); | |
break; | |
case ".list-view-items-page .ml-bg .mb-list-ad": | |
this.node.parentNode.style.cssText += "; display: none !important;"; | |
break; | |
case ".bg-container": | |
css.push("background-color: #CCCCCC;"); | |
break; | |
case ".yucs td": | |
css.push("padding: 0px;"); | |
break; | |
default: | |
css.push("display: none !important;"); | |
break; | |
} | |
if (css.length > 0) { | |
this.node.style.cssText += "; " + css.join(); | |
} | |
} | |
}); | |
processing = false; | |
} else { | |
console.log("rejecting request: already processing"); | |
} | |
} | |
}; | |
$(document).ready(function () { | |
setTimeout(function(){ | |
console.log("calling init"); | |
YMAC.init(); | |
}, 500) | |
setTimeout(function(){ | |
console.log("calling processElements, followup after init"); | |
YMAC.processElements(); | |
}, 5000) | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment