Inspired by this post by Lindsay Grizzard on how to make a simple Chrome extension, I decided to try my own.
According to the docs over at developer.chrome.com an extension should be a small program with a single, narrow purpose. Extensions are used to customize the browsing experience.
I started by following the beginning of Lindsay’s walkthrough to make an extension that renders a custom HTML page each time you open a new tab.
I made a directory with an index.html file and a manifest.json file.

Every extension needs to have a manifest. It needs a name, description, version and manifest version. Manifest version should be set to ‘2.’ That’s the supported version right now. The other version is your project version number.
chrome_url_overrides is what’s going to let us start customizing. For the basic walkthrough we just told each new tab to load our simple index.html.

To test it, we go to chrome://extensions and use the toggle in the upper right corner to switch to developer mode. Click “load unpacked” and select the extension directory. Now when I open a new tab ….

That’s exciting, but I wanted to try something a little more fun.
With just one more file and a few more lines of code I made my extension trigger an alert on Twitter when you click the retweet button!
First, I made a very simple index.js file:
console.log('Hello Twitter')
Then I made an addition to manifest.json.
The content scripts run on certain websites. Matches sets a match pattern. This one will match any URL with twitter.com in it. Then I specify the path to my new index.js file. After the updates were made and saved, I had return to Chrome developer mode and tell the extension to refresh so it would get those changes.
Then, when I navigated to Twitter and checked the console to make sure index.js was connected. 
It was! Next I spent some time poking around in the console. I practiced using querySelectorAll and getElementsByClassName to figure out how I was going to grab what I wanted to change.
I ended up selecting the retweet buttons by class name. Then I turned them into an array so I could map over them and add event listeners that would trigger my alert on click.

Back at the Chrome developer mode I refreshed again and headed back to Twitter and started trying to retweet things.

It works. It’s not ready for the Chrome Extension Store, but it’s fun to practice on!








