I want to use clojurescript to write chrome extensions.
4 Answers
Chrome extensions are generally made with HTML/CSS/JS so ClojureScript should work just fine because it compiles to JavaScript. That being said, I don't think anyone has actually built a large extension with ClojureScript yet. As a proof of concept here's a general outline of how to make a simple alert extension that will say Zaboomafoo (sorry for that name):
Install Leiningen and lein-cljsbuild first. Read the docs for lein-cljsbuild and check out the wiki on ClojureScript to understand how to use lein-cljsbuild for projects and compiling.
Make a ClojureScript file that displays an alert saying "Zaboomafoo" like this:
(ns Zaboomafoo.hello)
(js/alert "Zaboomafoo")
Compile this with lein cljsbuild
to get a JavaScript file. Then add a basic HTML file and manifest.json for the extension.
Zaboomafoo.html:
<!Doctype html>
<html>
<head>
<title>Zaboomafoo!</title>
</head>
<body>
<script type="text/javascript" src="Zaboomafoo.js"></script>
</body>
</html>
manifest.json:
{
"name": "Displays Zaboomafoo when opening a new tab",
"version": "0.1",
"incognito": "split",
"chrome_url_overrides": {
"newtab": "Zaboomafoo.html"
},
"manifest_version": 2
}
Put the new manifest.json, Zaboomafoo.html, and Zaboomafoo.js into a folder somewhere obvious. Finally, go to the chrome extension page, turn on developer mode, load unpacked extension, and open a new tab. The extension should load an alert that annoyingly says "Zaboomafoo" when you open the tab. Hopefully making browser extensions gets to be a little more popular but this is the general flow of it.

- 389
- 1
- 11
I have just released a simple Chrome extension sample project along with some documentation: https://github.com/binaryage/chromex-sample
It uses Chromex library: https://github.com/binaryage/chromex
Disclaimer: I'm author of the library

- 773
- 9
- 14
I started this project with the exact purpose of writing a Chrome extension using ClojureScript.
While greenyouse
answer does provide you the general directions, as a beginner in ClojureScript I had some trouble using lein
and cljsbuild
and chose to go for the basic setup first. Maybe it will help someone.
Sidenote: I plan to migrate my project to lein
and cljsbuild
once I understant things better. At that point I'll update this answer.

- 2,094
- 2
- 24
- 37
Take a look at this chrome extension written in cljs which allows you to eval clojure code in browser by selection as an example.

- 1,029
- 10
- 16

- 582
- 1
- 3
- 16
-
1It seems like this project (goranjovic/chromeclojure) doesn't use any ClojureScript. Rather the Chrome extension (written in plain JavaScript) sends selected Clojure code to an external Clojure JVM process and returns the result to the browser. I don't think this is really what the poster was looking for. – Aaron Aug 17 '13 at 04:35