// ==UserScript== // @name Liferay's Social Office forums revamp // @namespace in.liferay.com brandizzi // @include https://in.liferay.com/* // @include https://dev.liferay.com/* // @version 1 // @grant none // ==/UserScript== var fromCamelCaseToDashSeparated = function(str) { return str.replace(/([a-z][A-Z])/g, function (g) { return g[0] + '-' + g[1].toLowerCase(); }); } var GlobalStyleSheet = function() { this.title = Math.random().toString(36); this.element = document.createElement('style'); this.element.title = this.title; getChildByTag(document, 'head').appendChild(this.element); for (var i in document.styleSheets) { var styleSheet = document.styleSheets[i]; if (styleSheet.title == this.title) { this.styleSheet = styleSheet; this.styleSheet.disbled = false; } } } GlobalStyleSheet.prototype.addRule = function(selector, properties) { var rule = selector + ' {\n'; for (var k in properties) { var value = properties[k]; var property; if (k == 'cssFloat') { property = 'float'; } else { property = fromCamelCaseToDashSeparated(k); } rule += ' ' + property + ': ' + value + ';\n'; } rule += '}\n\n'; this.styleSheet.insertRule(rule, this.styleSheet.cssRules.length); } var convertToSpan = function(item) { var span = document.createElement('span'); while (item.childNodes.length > 0) { span.appendChild(item.childNodes[0]); } return span; } var getChildByClass = function(node, clazz, index) { if (typeof index == "undefined") { index = 0; } return node.getElementsByClassName(clazz)[index]; } var getChildByTag = function(node, tag, index) { if (typeof index == "undefined") { index = 0; } return node.getElementsByTagName(tag)[index]; } var setStyle = function(node, style) { for (var k in style) { node.style[k] = style[k]; } } var deleteNode = function(node) { node.parentNode.removeChild(node); } var moveControls = function(destination, controls, acc) { for (var j=0; j