Skip to content

Instantly share code, notes, and snippets.

@antimatter15
Created June 30, 2011 16:13
Show Gist options
  • Save antimatter15/1056568 to your computer and use it in GitHub Desktop.
Save antimatter15/1056568 to your computer and use it in GitHub Desktop.
Google+ Mute Keyboard Shortcut Userscript
// ==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)
@micktaiwan
Copy link

It does not work anymore. There is an error saying "unable to find mute link". Mickael.

@nyet
Copy link

nyet commented Jan 13, 2012

forked, and fixed: https://gist.github.com/1609306

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment