<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    
                        <title>milov.nl: bookmarklet: !usedcolors</title>
          <link>http://milov.nl/1938</link>
          <description>Weblog/photolog of Milo Vermeulen</description>
          <lastBuildDate>Tue, 19 Dec 2006 11:21:50 GMT</lastBuildDate>
                                <item>
              <title>GTonini</title>
              <link>http://milov.nl/1938#comment9726</link>
              <guid>http://milov.nl/1938#comment9726</guid>
              <pubDate>Tue, 19 Dec 2006 11:21:50 GMT</pubDate>
              <description>Oh yes. I see the !usedcolors bookmarklet extracts colors from text! Bad idea. My bookmarklet above doesn't do that. The results posted upon running it in this page are no longer valid, since the CSS was changed after the test.</description>
            </item>
                      <item>
              <title>Bob</title>
              <link>http://milov.nl/1938#comment6989</link>
              <guid>http://milov.nl/1938#comment6989</guid>
              <pubDate>Tue, 12 Jul 2005 07:08:45 GMT</pubDate>
              <description>It finds unexisting colours, for example it finds #FF6600 just because someone mentioned it in the previous comment. Search the tags not the text...</description>
            </item>
                      <item>
              <title>GTonini</title>
              <link>http://milov.nl/1938#comment3184</link>
              <guid>http://milov.nl/1938#comment3184</guid>
              <pubDate>Mon, 26 May 2003 17:03:32 GMT</pubDate>
              <description>I reworked the bookmarl - at least for IE/Mac. It nevigates thru each color element of the document, so it is very, very slow but accurate. Also built-in a name-to-hex color conversion (e.g. aqua=#00FFFF,...). It list also the position of the first occourrence of each color. All that withi 1kB code.

Here's the result on this page:
#000000 all[17] backgroundColor
#CCCCCC all[17] color
transparent all[18] backgroundColor
#888888 all[26] color
#AAAAAA all[27] color
#999999 all[42] color
#333333 all[532] backgroundColor
#FF6600 all[553] backgroundColor
#FFC8A4 all[553] borderBottomColor
#FFFFFF all[553] color
#666666 all[566] color

The code:javascript:
w='',j=0,C=new Array(),C['AQUA']='0FF',C['BLACK']='000',C['BLUE']='00F',C['FUCHSIA']='F0F',C['GRAY']='808080',C['GREEN']='008000',C['LIME']='0F0',C['MAROON']='800000',C['NAVY']='000080',C['OLIVE']='808000',C['PURPLE']='800080',C['RED']='F00',C['SILVER']='C0C0C0',C['TEAL']='008080',C['WHITE']='FFF',C['YELLOW']='FF0';
function g(n,m){
	for(var i in n){
		if(i.toLowerCase().indexOf('color')&gt;=0&amp;&amp;n[i]!=''&amp;&amp;typeof(n[i])!='undefined'&amp;&amp;n[i].indexOf(' ')&lt;0){
			var V=n[i].toUpperCase(),W=(V.charAt(0)!='#'?('#'+C[V]):V),X=W.charAt(1),Y=W.charAt(2),Z=W.charAt(3);
			W=(W=='#undefined'?n[i]:(W.length==4?'#'+X+X+Y+Y+Z+Z:W));
			if(!C[W]&amp;&amp;W!='invert'){
				w+=C[W]='&lt;div style=&quot;border-left:20px solid '+W+'&quot;&gt;&amp;nbsp;'+W+' all['+m.sourceIndex+'] '+i+'&lt;/div&gt;';
				j++
			}
		}
	}
}
function gC(m){
	g(m,m);
	g(m.currentStyle,m)
}
gC(document.body);
with(document.body){
	for(i=0;i&lt;all.length;i++){
		if(all[i].nodeType!=3){
			gC(all[i]);
		}
	}
}
if(j&gt;0){
	with(open('','iM','').document){
		write('&lt;body&gt;&lt;h3&gt;URL: '+this.location+'&lt;br&gt;Colors: '+j+'&lt;/h3&gt;&lt;tt&gt;'+w+'&lt;/tt&gt;&lt;/body&gt;');
		close()
	}
}</description>
            </item>
                      <item>
              <title>Owentje</title>
              <link>http://milov.nl/1938#comment2691</link>
              <guid>http://milov.nl/1938#comment2691</guid>
              <pubDate>Mon, 13 Jan 2003 21:50:04 GMT</pubDate>
              <description>nice work..2 comments:

- it doesn't work on frames, maybe try searching one level deep into frames?
- it is case-sensitive, which means #ffffff and #FFFFFF are two different colours where they are not.

:)</description>
            </item>
                      <item>
              <title>Ben</title>
              <link>http://milov.nl/1938#comment2684</link>
              <guid>http://milov.nl/1938#comment2684</guid>
              <pubDate>Fri, 10 Jan 2003 15:51:47 GMT</pubDate>
              <description>This chunk of code:
(this.style.behavior = 'url(#default#homepage)
makes the bookmarklet think #DEFA is a color variable.</description>
            </item>
                      <item>
              <title>Nate</title>
              <link>http://milov.nl/1938#comment2682</link>
              <guid>http://milov.nl/1938#comment2682</guid>
              <pubDate>Thu, 09 Jan 2003 22:22:10 GMT</pubDate>
              <description>There is probably a more direct workaround for Safari, but this one seems to work just fine:
Change: 
window.open().document.write(w))
To:
window.open('','colors','height=200,width=200,left=80,top=80').document.write(w))</description>
            </item>
                      <item>
              <title>Nate</title>
              <link>http://milov.nl/1938#comment2680</link>
              <guid>http://milov.nl/1938#comment2680</guid>
              <pubDate>Thu, 09 Jan 2003 22:04:59 GMT</pubDate>
              <description>Hey, it even works in Safari!... at least for a second.. then it tries to load a page called &quot;undefined&quot;, as if it were a page at the same site you used the bookmarklet on.  If I knew anything about javascript or regex maybe I could have provided better feedback.</description>
            </item>
                      <item>
              <title>kristoff</title>
              <link>http://milov.nl/1938#comment2679</link>
              <guid>http://milov.nl/1938#comment2679</guid>
              <pubDate>Thu, 09 Jan 2003 19:27:53 GMT</pubDate>
              <description>Not only nice, useful too!
Great work, Milo (yet again!)</description>
            </item>
                      <item>
              <title>Bob</title>
              <link>http://milov.nl/1938#comment2671</link>
              <guid>http://milov.nl/1938#comment2671</guid>
              <pubDate>Thu, 09 Jan 2003 09:36:41 GMT</pubDate>
              <description>Wow, very nice!</description>
            </item>
                      <item>
              <title>mados</title>
              <link>http://milov.nl/1938#comment2667</link>
              <guid>http://milov.nl/1938#comment2667</guid>
              <pubDate>Wed, 08 Jan 2003 22:25:42 GMT</pubDate>
              <description>Please replace the /href=&quot;.*&quot;/ regex with /href=&quot;[^&quot;]*&quot;/ - that's a common error. Look for greedy/ungreedy in some manual. :-)</description>
            </item>
                      <item>
              <title>poi</title>
              <link>http://milov.nl/1938#comment2650</link>
              <guid>http://milov.nl/1938#comment2650</guid>
              <pubDate>Wed, 08 Jan 2003 13:31:36 GMT</pubDate>
              <description>that's an interresting bookmarklet you did. If all the bugs you mentionned could be fixed, it could be really helpful. It could be great to put the number of occurence of each color code

You might need to use some REGEX

Do you know of any size limit for a bookmarlet ? Whatever if there's small limitation, an IFRAME or a WINDOW.OPEN might do the trick to load some additionnal code ( as you did for your LINEDRAW bookmarklet )</description>
            </item>
                        
      </channel>
</rss>