Created
June 30, 2011 16:13
-
-
Save antimatter15/1056568 to your computer and use it in GitHub Desktop.
Google+ Mute Keyboard Shortcut Userscript
This file contains hidden or 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 Google+ Mute Keyboard Shortcut | |
// @namespace http://antimatter15.com/ | |
// @description Mute conversations in your stream by hitting "m" | |
// @include https://plus.google.com/* | |
// @include http://plus.google.com/* | |
// @version 1.2 | |
// ==/UserScript== | |
document.addEventListener('keydown', function(e){ | |
function mouse(name){ | |
var evt = document.createEvent("MouseEvents"); | |
evt.initMouseEvent(name ? ('mouse'+name) : 'click', true, true, window, 0, 0, 0, 1, 1, false, false, false, false, 0, null); | |
return evt; | |
} | |
if(e.keyCode == 77 && !(document.activeElement.isContentEditable || /input|textarea/i.test(document.activeElement.tagName))){ | |
var selected = [].slice.call(document.querySelectorAll('#contentPane div[id^=update]'),0).filter(function(i){ | |
return getComputedStyle(i).getPropertyValue('border-left-color') == 'rgb(77, 144, 240)' | |
})[0]; | |
if(!selected) return; | |
var undo_mute = selected.querySelector("span[title=Undo]"); | |
if(!undo_mute || window.getComputedStyle(undo_mute.parentNode.parentNode.parentNode).display == 'none'){ | |
selected.querySelector('span[title="Options menu"]').dispatchEvent(mouse('down')); | |
var mute = [].slice.call(selected.querySelectorAll('div[role=menuitem]'),0).filter(function(e){ | |
return ~e.innerHTML.indexOf('Mute') | |
})[0]; | |
mute.dispatchEvent(mouse('down')); | |
mute.dispatchEvent(mouse('up')); | |
}else{ | |
undo_mute.dispatchEvent(mouse()); | |
} | |
} | |
}, true) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
forked, and fixed: https://gist.github.com/1609306