Hide stuff button.

209 views
Skip to first unread message

DarkFoxDK

unread,
Nov 25, 2010, 5:02:36 PM11/25/10
to LimeChat
I made a small script that adds a 4x4 pixel button in the top-left
corner.

When clicked the first time, it hides joins, quits and parts.
Second time, it also hides kicks, mode changes and nick changes.
Third time, the lines are shown again.

Just save the code below to a .js file with the same name as the theme
you use, or add it into the end of the file, if it already exists.
______________________________________________
function addHideButton() {
if (document.getElementsByTagName("body")[0] != null) {
var styleElement = document.createElement("a");
styleElement.style.position = "fixed";
styleElement.style.zIndex = '10';
styleElement.style.left = "0";
styleElement.style.top = "0";
styleElement.style.margin = "0";
styleElement.style.padding = "0";
styleElement.style.height = "4px";
styleElement.style.width = "4px";
styleElement.style.overflow = 'hidden';
styleElement.style.textAlign = 'center';
styleElement.style.textDecoration = 'none';
styleElement.style.color = '#FFFFFF';
styleElement.style.fontSize = '6pt';
styleElement.style.backgroundColor = "#BBBBBB";
styleElement.style.opacity = "50";
styleElement.href = 'javascript:hideStuff();';
document.getElementsByTagName("body")
[0].appendChild(styleElement);
} else {
var t=setTimeout("addHideButton()",500);
}
}


//Function to hide joins/parts/etc/etc.
var hideNo = 0;
function hideStuff () {
if (hideNo == 0) {
changecss('body.normal .event[type=join],
body.normal .event[type=part], body.normal .event[type=quit]',
'display', 'none');
hideNo = 1;
} else if (hideNo == 1) {
changecss('body.normal .event[type=kick],
body.normal .event[type=mode], body.normal .event[type=nick]',
'display', 'none');
hideNo = 2;
} else if (hideNo == 2) {
changecss('body.normal .event[type=join],
body.normal .event[type=part], body.normal .event[type=quit]',
'display', 'block');
changecss('body.normal .event[type=kick],
body.normal .event[type=mode], body.normal .event[type=nick]',
'display', 'block');
hideNo = 0;
}
}

function changecss(theClass,element,value) {
//Last Updated on October 10, 1020
//documentation for this script at
//http://www.shawnolson.net/a/503/altering-css-class-attributes-with-
javascript.html
var cssRules;

var added = false;
for (var S = 0; S < document.styleSheets.length; S++){

if (document.styleSheets[S]['rules']) {
cssRules = 'rules';
} else if (document.styleSheets[S]['cssRules']) {
cssRules = 'cssRules';
} else {
//no rules found... browser unknown
}

for (var R = 0; R < document.styleSheets[S][cssRules].length; R++)
{
if (document.styleSheets[S][cssRules][R].selectorText ==
theClass) {
if(document.styleSheets[S][cssRules][R].style[element]){
document.styleSheets[S][cssRules][R].style[element] = value;
added=true;
break;
}
}
}
if(!added){
try{
document.styleSheets[S].insertRule(theClass+' { '+element+':
'+value+'; }',document.styleSheets[S][cssRules].length);
} catch(err){
try{document.styleSheets[S].addRule(theClass,element+': '+value
+';');}catch(err){}
}
if(document.styleSheets[S].insertRule){
document.styleSheets[S].insertRule(theClass+' { '+element+':
'+value+'; }',document.styleSheets[S][cssRules].length);
} else if (document.styleSheets[S].addRule) {
document.styleSheets[S].addRule(theClass,element+': '+value
+';');
}
}
}
}

(function() {
addHideButton();
})();

Daniel Ralph

unread,
Nov 5, 2015, 7:09:49 PM11/5/15
to LimeChat
This sounds like an awesome feature, but I can't seem to make it work.
Do you need to add anything to the .css or .yaml files to "trigger" the .js file?

Martin Eberhardt

unread,
Nov 6, 2015, 5:53:52 AM11/6/15
to LimeChat
Sadly it seems to have been broken some time ago, and I haven't had the time to fix it.
Reply all
Reply to author
Forward
0 new messages