This project is an example of a Google Chrome extension, that uses RequireJS to load code modules and at the same time is compliant with Manifest file v2 limitations. For more details on this topic, please see this presentation by Daniel Prentis.
The extension demonstates the usage of background page, extension popup window and inserting content scripts into the target pages. Communication between the background window and the content scripts is implemented using messaging. Also, both the content script and the popup window use Mustache templates.
The goal of this project is to have a skeleton for Google Chrome extensions, so you can download it or fork it, and then develop your own extension without spending too much time with figuring out the basics.
Should you have any comments, don't hesitate and let us know!
/code
/css
/html
/templates
/images
/js
/lib
/modules
/type_a
/type_b
/...
/util
/tests
/test
/modules
/specs
In code
directory you will find:
css
- any css files used by the extensionhtml
- any html files used by the extensionhtml/templates
- html Mustache templates used for rendering html codeimages
- any graphics used by the extnesionjs
- code javascript files (entry point for background script, content script(s), and popup scriptjs/lib
- third party libraries, see README.md file there for detailsjs/modules
- all extension-specific code in AMD modules (can be organised in sub-directories, e.g.type_a
, ...js/util
- common functionality (messaging and templates) for the extensions, written as AMD modules
In tests
directory you will find:
test
- test related JavaScript code forJasmine-nodemodules
- unit test-specific utility and RequireJS configurationspecs
- unit test modules
-
Install jasmine-node first:
npm install -g jasmine-node
-
In
tests
directory runrun-tests.sh
(it installs required dependencies first)