Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to use Clojurescript or Google Closure to write Chrome extensions or web app?

I want to use clojurescript to write chrome extensions.

like image 745
akietta Avatar asked Mar 01 '13 16:03

akietta


People also ask

Is a Chrome extension a web app?

Another major difference between Chrome extensions and web apps is the fact that while extensions are used to enhance the functionality of the Chrome Browser, web apps run within the browser having a different user interface. Unlike web applications, extensions have little or sometimes no UI component.

Can you add extensions to Chrome App?

Open the Chrome Web Store. Find and select the extension you want. Click Add to Chrome. Some extensions will let you know if they need certain permissions or data.

Are Google extensions software?

Extensions are software programs, built on web technologies (such as HTML, CSS, and JavaScript) that enable users to customize the Chrome browsing experience.

Is Chrome getting rid of extensions?

Google is planning to remove inline installation from Chrome for existing extensions starting on September 12th, and Chrome users will be redirected to the Web Store.


2 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.

like image 123
greenyouse Avatar answered Oct 22 '22 16:10

greenyouse


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

like image 37
Antonin Hildebrand Avatar answered Oct 22 '22 15:10

Antonin Hildebrand