Q:

Javascript parse a page for find hex color values

in my project i need a function for find all hex color values into a webpage (like #FFDD600, #999, etc).
In the past to do the same thing I used php class "PHP Simple HTML DOM Parser", but now I need that # research is carried out ​​in javascript or jquery.
For a study I need to catalog some websites registering the colors used.
Any idea?
Thanks in advance

A:

This will fetch an url and parse it as text for all hex values, and put them into current page body.
You can check it out here: JSFiddle
Though it will be somewhat limited due to cross-origin policy.
$.ajax({
    url: ENTER_URL_HERE,
    success: function (data) {
        var hexCodes = $("html").html().match(/#[a-fA-F0-9]{6}|#[a-fA-F0-9]{3}/g);
        $("body").html("");
        $.each(hexCodes, function () {
            $("body").append("<p>" + this + "</p>");
        });
    }
});

