Skip to content

Instantly share code, notes, and snippets.

@kolyuchiy
Created September 9, 2016 16:09
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 kolyuchiy/3a3536a6973712cae724bc34bc56bc25 to your computer and use it in GitHub Desktop.
Save kolyuchiy/3a3536a6973712cae724bc34bc56bc25 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name Почта mail.ru
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author You
// @match https://e.mail.ru/*
// @grant none
// @require http://code.jquery.com/jquery-latest.js
// ==/UserScript==
(function() {
'use strict';
// http://www.appelsiini.net/projects/viewport
(function($){$.belowthefold=function(element,settings){var fold=$(window).height()+$(window).scrollTop();return fold<=$(element).offset().top-settings.threshold;};$.abovethetop=function(element,settings){var top=$(window).scrollTop();return top>=$(element).offset().top+$(element).height()-settings.threshold;};$.rightofscreen=function(element,settings){var fold=$(window).width()+$(window).scrollLeft();return fold<=$(element).offset().left-settings.threshold;};$.leftofscreen=function(element,settings){var left=$(window).scrollLeft();return left>=$(element).offset().left+$(element).width()-settings.threshold;};$.inviewport=function(element,settings){return!$.rightofscreen(element,settings)&&!$.leftofscreen(element,settings)&&!$.belowthefold(element,settings)&&!$.abovethetop(element,settings);};$.extend($.expr[':'],{"below-the-fold":function(a,i,m){return $.belowthefold(a,{threshold:0});},"above-the-top":function(a,i,m){return $.abovethetop(a,{threshold:0});},"left-of-screen":function(a,i,m){return $.leftofscreen(a,{threshold:0});},"right-of-screen":function(a,i,m){return $.rightofscreen(a,{threshold:0});},"in-viewport":function(a,i,m){return $.inviewport(a,{threshold:0});}});})(jQuery);
$.noConflict();
jQuery(document).ready(function($) {
$(document).keydown(function (e) {
//alert(e.which);
if (e.which == 68) { // d
if ($('#b-thread:visible').length > 0) {
var more = $('[data-mnemo="letter"].b-letter_expanded [data-group="more"]:in-viewport:first');
more.find('.js-preload-click').click();
more.find('[data-name="remove"]').click();
}
else if ($('#b-letters:visible').length > 0) {
$('.b-toolbar .b-checkbox').click();
$('.b-toolbar [data-name=remove]').click();
}
}
});
});
// Your code here...
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment