git clone https://github.com/TravelingTechGuy/svcc-chrome-extensionnpm i -g webpack
Extensions are small software programs that can modify and enhance the functionality of the Chrome browser. You write them using web technologies such as HTML, JavaScript, and CSS. ... You can distribute your extension through the Chrome Web Store.
Blocks ads and unwanted trackers
Alters page content and DOM
Attempts to switch to an HTTPS version of every site
Alters page url
Allows your Chrome to pass for other browsers/crawlers
Alters HTTP request header
Shortens urls, using several shortening services
Copies url, changes nothing
And many more at the Chrome web store... all free!
chrome://extensions in the address bar
manifest.json*
background.html
background.js
options.html
popup.html
--|_locales*
--|messages.json
--|icons
--|icon16.png
--|icon19.png
--|icon48.png
--|icon128.png
Files marked with * are mandatory.
manifest.json file
{
"name": "Basic",
"version": "1.0.0",
"manifest_version": 2,
"description": "Basic extension",
"homepage_url": "http://www.TravelingTechGuy.com",
"icons": {
"16": "icons/icon16.png",
"19": "icons/icon19.png",
"48": "icons/icon48.png",
"128": "icons/icon128.png"
},
"default_locale": "en",
"background": {
"page": "background.html",
"persistent": true
},
"options_page": "options.html",
"browser_action": {
"default_icon": "icons/icon19.png",
"default_title": "Basic Extension",
"default_popup": "popup.html"
},
"permissions": [
],
"content_security_policy": "script-src 'self' 'unsafe-eval'; object-src 'self'"
}
package.json).webpack.config.js fileESLint to prevent basic errors and maintain style (also .eslintrc file).
Babel for the latest ES6/7 syntax.npm run build or npm run dist to build the extension.
package.json //NPM modules, and build scripts
webpack.config.js //Webpack configuration files
+build //folder containing he built extension (created)
+dist //folder containing the packed extension (created)
+src //source root folder for Webpack to process
--|manifest.json*
--|background.html //only needed if we want access to clipboard
--|options.html
--|popup.html
--|scripts //All logic goes here
--|background.js //background logic
--|popup.js //React DOM render - can be embedded in HTML
--|options.js //React DOM render - can be embedded in HTML
--|components //React components folder
--|popup.js //component logic
--|popup.css //component stylesheet
--|options.js
--|options.css
--|...
--|_locales*
--|messages.json
--|icons
--|icon16.png
--|icon19.png
--|icon48.png
--|icon128.png
chrome.runtime.sendMessage and chrome.runtime.onMessage.addListenerlocalStorage.setItem and localStorage.getItemchrome.browserAction.setTitle .setBadgeText .setBadgeBackgroundColorwindow.localStorageJSON.stringify)chrome.storage.localchrome.storage.onChanged)localStorage 5MB limitchrome.storage.syncchrome.storage.local, but synced between signed-in Chrome instances.
/