Hello There, Guest!
View New Posts  |  View Today's Posts
[JavaScript][Bookmarklet] Text To Rainbow

  • 0 Vote(s) - 0 Average


05-04-2012, 05:39 PM #1
Louis
Master of the IRCs!
**
Posts: 153 Threads:23 Joined: May 2012 Reputation: 11

[JavaScript][Bookmarklet] Text To Rainbow
I was bored and I seem to do very random things when I get bored... I created this for no reason at all.
What it does, is take HTML elements and converts all the text in them to rainbow colors. Current the elements are 'span', 'div', 'p', and 'pre'. Because of the way it loops and appends content after the DOM is loaded, it can be laggy if you use it on a page with too much content. Try using the example here: http://fb.ltdev.im/examples/rainbow.html -- You can also get the uncompressed version.

Bookmarklet:
Code:
javascript:(function(){function%20Rainbow(c){this.o={n:0,p:false,c:["FF0000","FF7F00","FFFF00","00FF00","0000FF","6600FF","8B00FF"]};this.byTag=function(a){var%20b=document.getElementsByTagName(a),o=this.o;for(var%20i=0;i<b.length;i++){b[i].innerHTML=b[i].innerHTML.replace(/./g,function(x){if(x=="<"){o.p=true}if(o.p==false&&x!=="%20"){if(o.n>5){o.n=0}else{o.n+=1}return'<font%20color="'+o.c[o.n]+'">'+x+'</font>'}else{if(x==">"){o.p=false}return%20x}})}};this.byTags=function(a){for(var%20i%20in%20a){this.byTag(a[i])}};(c?byTags(c):byTags(['span','div','p','pre']))}Rainbow();})();
This post was last modified: 01-24-2013, 10:14 PM by Louis.

05-04-2012, 06:24 PM #2
AceInfinity
Developer
*******
Administrators
Posts: 9,731 Threads:1,024 Joined: Jun 2011 Reputation: 76

RE: [JavaScript][Bookmarklet] Text To Rainbow
That's awesome, maybe not entirely useful but I create lots of just "fun" stuff like this too. Bookmarklets are awesome, unfortunately if I can remember correctly IE doesn't allow you to use them, which is why I use Chrome or Firefox instead at least lol


Microsoft MVP .NET Programming - (2012 - Present)
®Crestron DMC-T Certified Automation Programmer

Development Site: aceinfinity.net

 ▲
 ▲ ▲

05-04-2012, 06:54 PM #3
Louis
Master of the IRCs!
**
Posts: 153 Threads:23 Joined: May 2012 Reputation: 11

RE: [JavaScript][Bookmarklet] Text To Rainbow
I haven't used IE in years, so I have no idea what it supports and does not.. Good to know, anyway.




Forum Jump:


Possibly Related Threads...
Thread Author Replies Views Last Post
  Javascript-based Web Game - Untrusted AceInfinity 1 720 09-10-2015, 08:33 AM
Last Post: Mazzn
  Disabling JavaScript event selectively in Browsers Holmes.Sherlock 4 1,956 11-01-2014, 02:14 AM
Last Post: Louis
  Javascript Click iframe src on page load ѕα3єкα 1 1,158 06-17-2014, 06:09 PM
Last Post: AceInfinity
  Javascript problem william7 4 3,177 03-01-2014, 07:21 PM
Last Post: AceInfinity
  Javascript Issue QBcrusher 1 1,097 01-05-2014, 02:37 PM
Last Post: KoBE


Users browsing this thread: 1 Guest(s)