A programmer's diary
A programmer's diary
Learning to code browser extensions
About the Book
This is a strange book. Somewhere around 2021 (or so) I thought I would like to learn to write browser extensions, with two goals: to make my life easier by customizing my browser (much like I customize Emacs, my editor of choice), and to write a book to help other people learn the same thing (much like I wrote a book teaching how to customize Emacs).
Another idea I had was that it might be an interesting experiment to document my learning process – in other words, write down my thoughts while studying. I already did something similar back in 2016, when I took part in a blogging contest (however strange it may sound), where I learned a new technology and coded an application while blogging about it three times a week for two and a half months.
This book is the result of that experiment. I don’t know if it will be interesting to anyone, but in case you like it, well, you can buy it here. (And if you don’t like it, you can easily get a refund.)
So, join me in my journey learning some new stuff! I can’t promise any enlightening thoughts or brilliant insights, but what I can promise is some ranting, my thoughts on documentation writing (and web extension APIs etc.), and a rant from time to time. Oh, and did I mention rants?
Table of Contents
- 1 Introduction
- 2 The sources
- 3 Getting started
- 3.1 What are extensions?
- 3.2 Your first extension
- 3.3 Your second extension
- 3.4 Anatomy of an extension
- 3.5 Example extensions
- 3.6 What next?
- 4 Concepts
- 4.1 Using the JavaScript APIs
- 4.2 Content scripts
- 4.3 Background scripts
- 4.4 Match patterns in extension manifests
- 4.5 Working with files
- 4.6 Internationalization
- 4.7 Content Security Policy
- 4.8 Native messaging
- 4.9 Differences between API implementations
- 4.10 Chrome incompatibilities
- 5 User interface
- 5.1 User interface
- 5.2 Toolbar button
- 5.3 Address bar button
- 5.4 Sidebars
- 5.5 Context menu items
- 5.6 Options page
- 5.7 Extension pages
- 5.8 Notifications
- 5.9 Address bar suggestions
- 5.10 devtools panels
- 6 Howtos
- 6.1 Intercept HTTP requests
- 6.2 Modify a web page
- 6.3 Safely inserting external content into a page
- 6.4 Sharing objects with page scripts
- 6.5 Add a button to the toolbar
- 6.6 Implement a settings page
- 6.7 Working with the Tabs API
- 6.8 Work with the Bookmarks API
- 6.9 Work with the Cookies API
- 6.10 Work with contextual identities
- 6.11 Interact with the clipboard
- 6.12 Extending the developer tools
- 6.13 Building a cross-browser extension
- 7 Firefox differentiators
- 8 JavaScript APIs
- 8.1 Browser support for JavaScript APIs
- 8.2 action
- 8.3 alarms
- 8.4 bookmarks
- 8.5 browserAction
- 8.6 browserSettings
- 8.7 browsingData
- 8.8 captivePortal
- 8.9 clipboard
- 8.10 commands
- 8.11 contentScripts
- 8.12 contextualIdentities
- 8.13 cookies
- 8.14 declarativeNetRequest
- 8.15 devtools
- 8.16 dns
- 8.17 dom
- 8.18 downloads
- 8.19 events
- 8.20 extension
- 8.21 extensionTypes
- 8.22 find
- 8.23 history
- 8.24 i18n
- 8.25 identity
- 8.26 idle
- 8.27 management
- 8.28 menus
- 8.29 notifications
- 8.30 omnibox
- 8.31 pageAction
- 8.32 permissions
- 8.33 pkcs11
- 8.34 privacy
- 8.35 proxy
- 8.36 runtime
- 8.37 scripting
- 8.38 search
- 8.39 sessions
- 8.40 sidebarAction
- 8.41 storage
- 8.42 tabs
- 8.43 theme
- 8.44 topSites
- 8.45 types
- 8.46 userScripts
- 8.47 webNavigation
- 8.48 webRequest
- 8.49 windows
- 9 Afterword
Other books by this author
The Leanpub 60 Day 100% Happiness Guarantee
Within 60 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.
Now, this is technically risky for us, since you'll have the book or course files either way. But we're so confident in our products and services, and in our authors and readers, that we're happy to offer a full money back guarantee for everything we sell.
You can only find out how good something is by trying it, and because of our 100% money back guarantee there's literally no risk to do so!
So, there's no reason not to click the Add to Cart button, is there?
See full terms...
Earn $8 on a $10 Purchase, and $16 on a $20 Purchase
We pay 80% royalties on purchases of $7.99 or more, and 80% royalties minus a 50 cent flat fee on purchases between $0.99 and $7.98. You earn $8 on a $10 sale, and $16 on a $20 sale. So, if we sell 5000 non-refunded copies of your book for $20, you'll earn $80,000.
(Yes, some authors have already earned much more than that on Leanpub.)
In fact, authors have earnedover $14 millionwriting, publishing and selling on Leanpub.
Learn more about writing on Leanpub
Free Updates. DRM Free.
If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).
Most Leanpub books are available in PDF (for computers) and EPUB (for phones, tablets and Kindle). The formats that a book includes are shown at the top right corner of this page.
Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.
Learn more about Leanpub's ebook formats and where to read them