Created
December 15, 2012 20:49
-
-
Save anonymous/4299061 to your computer and use it in GitHub Desktop.
This makes chatrooms on MocoSpace actually usable.
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 MocoSpace Plus | |
// @namespace http://monokro.me/ | |
// @version 0.1 | |
// @description Makes mocospace not-so-lame. | |
// @match http://www.mocospace.com/html/chat/* | |
// @copyright 2012+, Brandon R. Stoner | |
// ==/UserScript== | |
(function(undefined) { | |
function boundWidths(min, max) { | |
return (function(element) { | |
element.style.minWidth = min; | |
element.style.maxWidth = max; | |
}); | |
} | |
var elementActions = { | |
"actions": { | |
"hideElement": (function(element) { | |
element.style.display = "none"; | |
}), | |
"fullHeight": (function(element) { | |
var tagNameIndex, tagNames = ['body', 'html']; | |
for (tagNameIndex in tagNames) { | |
console.log(tagNames[tagNameIndex]); | |
var elementIndex, | |
elements = document.getElementsByTagName(tagNames[tagNameIndex]); | |
for (elementIndex in elements) { | |
if (typeof elements[elementIndex] != 'undefined' && typeof elements[elementIndex].style != 'undefined') { | |
elements[elementIndex].style.height = '100%'; | |
} | |
} | |
} | |
element.style.height = '100%'; | |
}) | |
}, | |
"selectors": { | |
"#header": "hideElement", | |
".warningmsg": "hideElement", | |
"#footer": "hideElement", | |
"#wrapper": "fullHeight", | |
"#content": [ | |
boundWidths('100px', '100%'), | |
"fullHeight" | |
], | |
"#conversations": "fullHeight" | |
}, | |
"initialize": (function() { | |
var selector, | |
action, actionName, | |
elements, | |
elementIndex, element; | |
document.removeEventListener("load", elementActions.initialize); | |
for (selector in elementActions.selectors) { | |
actionName = elementActions.selectors[selector]; | |
elements = document.querySelectorAll(selector); | |
for (elementIndex = 0; elementIndex < elements.length; ++elementIndex) { | |
element = elements.item(elementIndex); | |
elementActions.parseAction(actionName, element); | |
} | |
} | |
}), | |
"parseAction": (function(action, element) { | |
if (typeof action == 'string') { | |
action = elementActions.actions[action]; | |
} else if (typeof action == 'object') { | |
var actionIndex; | |
for (actionIndex in action) { | |
elementActions.parseAction(action[actionIndex], element); | |
} | |
return; | |
} | |
action(element); | |
}) | |
}; | |
document.addEventListener("load", | |
elementActions.initialize, | |
false); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I made this, but - just like everything else that they've touched in the last year - GitHub has completely ruined the GIST portion of the site. When you go to gist, you don't get automatically logged in. Then you post something which is now owned by "anonymous", and there's a "sign in to comment button" which automatically logs me in. That's some horrible UX. Why did they get rid of the "Login to claim this gist" button? Oh well.
Now I have to fork it if changes ever occur. Fantastic.