Skip to content

Instantly share code, notes, and snippets.

@sheodox
Created February 13, 2015 14:32
Show Gist options
  • Save sheodox/e4def722691762c4c910 to your computer and use it in GitHub Desktop.
Save sheodox/e4def722691762c4c910 to your computer and use it in GitHub Desktop.
Better Hangouts
// ==UserScript==
// @name Better Hangouts
// @namespace Jake Harrington
// @description Makes Hangouts better
// @include https://plus.google.com/*/hangouts
// @version 1.0
// @run-at document-end
// @require https://code.jquery.com/jquery-1.11.2.min.js
// @require https://code.jquery.com/ui/1.11.3/jquery-ui.min.js
// @downloadURL https://gist.github.com/dbs727/e4def722691762c4c910/raw/2bf1936175459f6b6c0fefbe222f34d298234b82/betterhangouts.user.js
// @grant GM_addStyle
// ==/UserScript==
function filteredNewNodeCallback(root, selector, callback) {
var obs, i;
if (!root || !selector || !callback) {
return;
}
function filterAndCallback(node) {
var matches = [], childMatches;
if (node.matches(selector)){
matches.push(node);
}
childMatches = node.querySelectorAll(selector);
if (childMatches.length !== 0) {
matches = matches.concat([].slice.call(childMatches))
}
matches.map(callback);
}
obs = new MutationObserver(function(mutations){
mutations.forEach(function(mutation){
for(i = 0; i < mutation.addedNodes.length; i++) {
if (mutation.addedNodes[i].nodeType === 1) {
filterAndCallback(mutation.addedNodes[i]);
}
}
})
});
obs.observe(root, {childList: true, subtree: true});
}
function makeDraggable(el) {
var $chat = $(el);
$chat.draggable();
//remove the auto-position resetting handler
setTimeout(function() {
$chat.find('iframe').contents().find('body')[0].removeEventListener('click');
}, 3000);
}
//hide 'posts'
$('[role="main"]').hide();
GM_addStyle('.talk_chat_widget {border: 10px solid gray;}');
/*//make all existing chats draggable
$('.talk_chat_widget').each(function() {
makeDraggable(this);
});
filteredNewNodeCallback(document.body, '.talk_chat_widget', makeDraggable);
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment