Skip to content

Instantly share code, notes, and snippets.

@monokrome
Forked from anonymous/mocospaceplus.user.js
Created December 15, 2012 21:00
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 monokrome/4299146 to your computer and use it in GitHub Desktop.
Save monokrome/4299146 to your computer and use it in GitHub Desktop.
// ==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";
}),
"removePadding": (function(element) {
element.style.padding = 0;
}),
"fullHeight": (function(element) {
var tagNameIndex, tagNames = ['body', 'html'];
for (tagNameIndex in tagNames) {
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",
"removePadding"
],
"#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