xonecas.io
2495
Xg

xonecas.github.com / files

xonecas.github.com / _posts / 2012-06-25-a-little-chrome-app.markdown

1.8 KB
1---
2layout: post
3title: An example Chrome app
4---
5
6I've been using [Backbone.js](http://documentcloud.github.com/backbone/backbone.js) and after a few hours of reading the source in the browser my eyes demanded some syntax highlight. I assumed someone would've done this by now, but I could only find apps that provide much more than a nicer **reading** environment (I'm not looking to edit code on the browser).  *Great!*, I tough to myself, *I get to roll my own*!  Because I read mostly javascript source code, I focused on that, maybe if the need arises I'll beef it up with html and css highlight.
7
8So to get started I looked around for highlighting libraries, and found a couple of heavyweights and then I saw [hijs.js by cloudhead](https://github.com/cloudhead/hijs) and I grabbed it!
9
10After having a good grasp on what happens inside Hijs I was happy to see that it fits the bill perfectly because it will invoque itself when loaded. At that point all I needed was to actually create the app.
11
12I googled for some tutorials and ended up in the [official docs](http://code.google.com/chrome/extensions/overview.html) where I found everything I needed. It wasn't much, all I was missing was a manifest file.
13
14And... here it is:
15
16{% highlight javascript %}
17    {
18       "name": "Hijs",
19       "version": "0.0.1",
20       "description": "Raw javascript file highlighter.",
21       "permissions" : [
22          "http://*/*.js",
23          "https://*/*.js"
24       ],
25       "content_scripts": [
26          {
27             "matches": ["http://*/*.js", "https://*/*.js"],
28             "js": ["hijs.js"],
29             "css": ["highlight.css"]
30          }
31       ]
32    }
33{% endhighlight %}
34
35It is very simple, but i'm sure it can get much more complicated. Just read the docs!
36
37So if you'd like to try it out before I have it done, head on to the [github repo](https://github.com/xonecas/chrome-hijs)