2 May 2007

CSS Mutation with JavaScript

What do you get when you apply someone else’s style on your website … Someone smarter than me called it a CSS love child … which is an awesome experiment … but i wanted a something that i could use on any website no matter where i was … and hence born my CSS mutation …

So first the example … LET’S MUTATE ...

I love StopDesign design ... their skin fits well on me i think … hmm… not so bad … let’s try some others really beautiful people … i hope those people don’t hate me for linking to their css … but they really all have great sites you should check out…

ok not everyone makes me look good ... so i can’t in all good conscience call this a “love child” ... that’s why it’s a mutation …

bookmarklet: css mutate

drag this bookmarklet to your browser … and you too can make mutations … or grab source below and put on your website … it’s allot of FUN !

da code

//shortcus
var doc = document;
var sty = doc.styleSheets;
var els = doc.getElementsByTagName('*');
var hed = doc.getElementsByTagName('head')[0];
//take out all the styles
//http://dorward.me.uk/software/disablecss/
for (i=0;i<sty.length;i++)  
    void(sty.item(i).disabled=true); 	
for (i=0; i<els.length; i++) 
    void(els[i].style.cssText = '');	
//new style
if(who == undefined || who == '') 
{
	who="default cs";	
	who=prompt('css stylesheet',who);
}
//create new link tag
var lnk = doc.createElement("link");
lnk.rel="stylesheet";
lnk.media="all";	
lnk.type="text/css";
//set new style
lnk.href=who;
//insert into head
hed.appendChild(lnk);

download: css-mutate.js

some info

First thanks to David Dorward for the code to remove styles on a website …

so this is no where as sophisticated as man in blue, that actually parses the HTML to figure out the css files … but this requires no server side code … try the bookmarklet below by adding to yout browser bar … and try on any site …

try the bookmarklet for yourself on here and elsewhere

css mutate

conclusion

There really is none … this was for fun … but maybe there is a need for standards across how we code … that maybe a little too much to ask … everyone has there “style” ...


enjoy…


 

comment



note: you can only submit after you hit preview


nuff-respec is a weblog written by daniel bulli a senior web programmer in boston, ma.
more >

contact | resume | profile

recently :::

diversions :::

beSlimed - Mootools game
Cool little game done in my favorite javascript library...
First Magazine
A Jamaican Magazine on the web ... very clean ... now i need to explore the articles ...
The Afflicted Yard
Love to see when there is Jamaican stuff out there... nice thoughts and clean design ... just don't look on the source code ...
BugMeNot
What a wonderful service of passwords for sites that want pointless registrations...
you still want more »