
Let badWords = "w3schools|david|walsh|jquery.".split('|') // looolĭocument.title = (' ').map(word =>

FIREFOX WEB EXTENSIONS API CODE
The following code searches the document.title for bad words and replaces them with asterisks: The filter.js file contains all of the web extension's logic.

For the sake of this simple web extension, I want it to be loaded for every hostname and the meat of the extension will live in filter.js. The content_scripts key is important, listing the JavaScript files to include on which hostnames. "description": "Filters out filthy words from document titles", The following is the very simple manifest I used for my extension: The manifest.json file holds all of the extension properties including images, title, description, requested permissions, which scripts to run on which hostnames, and more. The more complex the extension, the more files and structure will likely be needed. + foulmouth-filter // (name of your plugin here)Īll of the file names and subdirectories can be named how you like with the exception of manifest.json that is a standard file name which must be at the root of the extension. The extension must be contained within a single directory - this is how I recommend the simple extension be structured: Let me walk you through how simple creating a basic web extension is!

In the end I created a very simple web extension that continuously monitors the document.title to replace foul words with asterisks, a safety measure to avoid embarrassment when sharing your screen or having people looking over your shoulder. Today we have the Web Extension API which is supported by most major browsers, a critical step in alleviating many of the problems developers and users experience today.Īt Mozilla's recent all hands event in Hawaii I set out to create my first web extension I wanted the extension to be useful but simple, something with a real use case. For years each browser had its own language and method for installing add-ons, leading to security exploits, performance problems, painful maintenance for developers, and frustrating user experiences. Much like multimedia support in the browser, we initially did browser add-ons all wrong.
