<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Sierra Saitta on Medium]]></title>
        <description><![CDATA[Stories by Sierra Saitta on Medium]]></description>
        <link>https://medium.com/@ssaitta13?source=rss-ff7ad6b748c2------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*XT7nejO4gjnKIPUB93b58A.jpeg</url>
            <title>Stories by Sierra Saitta on Medium</title>
            <link>https://medium.com/@ssaitta13?source=rss-ff7ad6b748c2------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 21 Nov 2026 17:42:06 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@ssaitta13/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[ReciPal: A First Chrome Extension]]></title>
            <link>https://medium.com/@ssaitta13/recipal-a-first-chrome-extension-18c2848cf822?source=rss-ff7ad6b748c2------2</link>
            <guid isPermaLink="false">https://medium.com/p/18c2848cf822</guid>
            <category><![CDATA[full-stack]]></category>
            <category><![CDATA[tech]]></category>
            <category><![CDATA[chrome-extension]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Sierra Saitta]]></dc:creator>
            <pubDate>Wed, 03 Jan 2018 20:30:08 GMT</pubDate>
            <atom:updated>2018-01-05T18:01:11.561Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/327/1*mr2aPqhianh8O-vR-TEi_g.jpeg" /></figure><p>I love to try new recipes I find online, but I hate reading them. It’s always when my hands are covered in raw chicken and the onions are about to burn that I can’t remember how much white wine I’m supposed to add to deglaze the pan. The answer is tantalizingly close, just one scroll up, and yet…out of reach! So I decided it was time to put my other skills to use and help myself out in the kitchen.</p><p>That’s how ReciPal, my first Chrome extension, was born.</p><p>In addition to being an amateur cook, I am in the middle of a full-stack javascript bootcamp, the Grace Hopper program. When we finally got some time to ourselves over Christmas break, I got to work on ReciPal, a Chrome extension I have long wished for. Originally, the idea for ReciPal started as a tool to highlight all the ingredients within the directions of online recipes because of how many times I had left something out as I quickly read, and skimmed right past the garlic or quarter teaspoon of turmeric. Then I figured, while I’m at it, why not add a tooltip telling the reader the amount of that ingredient the recipe called for?</p><p>Here’s how it looks now 🌈</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2Fl0HUa81GZSmIEsAMM%2Ftwitter%2Fiframe&amp;url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2Fl0HUa81GZSmIEsAMM%2Fgiphy.gif&amp;image=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2Fl0HUa81GZSmIEsAMM%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="286" frameborder="0" scrolling="no"><a href="https://medium.com/media/5969236e7f1778034e08ab2c7fc7f596/href">https://medium.com/media/5969236e7f1778034e08ab2c7fc7f596/href</a></iframe><p>I still had a few other little features I wanted to add, but seeing as I didn’t know the first thing about making a Chrome extension, I thought this was enough to get started with.</p><p>Chrome’s documentation for making an extension isn’t bad. But when I had a specific question I found myself much more frequently on Stack Overflow than on Chrome’s docs. I’m the kind of learner who needs to jump in and try it before reading a whole bunch of documentation, so I walked through Chrome’s “getting started” tutorial before reading anything else.</p><p>The lessons in the getting started tutorial are pretty basic and my big takeaway was, <strong>every chrome extension needs a manifest.json file</strong>, which sets the stage for the basic functionality, permissions, and files which are going to be used in the extension. This file is mandatory for your extension to work. Here is what mine looked like at the beginning:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/586/1*EDbjNZ2890474Zatn2LrsQ.png" /></figure><p>The browser action is the little icon that appears when you install an extension. It can have event listeners attached to it. The only thing I specified about my browser action was the icon, but they can also display popups with HTML in them, which in turn can call on js files that will run (but more on that later).</p><p>The permissions section reflects which Chrome API’s are used in your extension. I used chrome.tabs and chrome.storage, and then also gave it matching patterns for the three recipe websites I knew I wanted the extension to work with. If you want to use Chorme API’s, permissions often need to be specified in your manifest file. (Here’s a <a href="https://developer.chrome.com/extensions/declare_permissions">link</a> to Chrome’s Docs about permissions.)</p><p>The other files contained in a chrome extension are any images you want to use as your icon image, html, and js files, where all the real magic happens! ✨</p><p>My first hurdle going from the getting started tutorial to my own project was that the tutorial really only implements a background script without even mentioning content scripts. But, if I’m honest, the real issue was that, in my eagerness to get going, I didn’t bother to read the “Learn Basics” section. I spent an embarrassingly long time using a background script to try to gain access to the HTML for the page I was on before giving up, returning to Chrome, reading the “Learn Basics” section, and learning about content scripts.😅</p><p>So my next lesson for anyone who wants to build a Chrome extension is <strong>background vs content scripts</strong>. Anything you want to do within the context of the webpage you are currently on, like modify the DOM, must be done in the content script, and anything that you want to be done in the context of the browser, like retrieve the url of the active tab, is controlled in the background script. And most importantly (and difficult), these two scripts work in what Chrome calls “isolated worlds”.</p><p>This means that your content scripts exist in a different Javascript environment from the rest of your extension files, raising the question of how to pass information between your scripts. Chrome calls this “message passing” and in my extension I chose to use Chrome’s storage API. The storage API lets you save data in an object which can be accessed by both your content and background scripts. I needed access to the active tabs URL to determine which HTML tags to search the DOM for, so I set a key called ‘url’ to the active tabs URL in my background script, and then used the chrome.storage API to access it within my content script. Here is how that looked:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/596/1*tDnuqnaCMAPIeOoVYh4UPw.png" /><figcaption>The background script where the storage was set</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/420/1*c6OXTik4Yd8Shj5qOzc3Eg.png" /><figcaption>The content script where the data was retrieved</figcaption></figure><p>It is important to remember that many chrome API’s function are asynchronous, so if the rest of your script needs this data retrieved first, you need to account for the execution order of your functions. In my case, I only needed the URL, and then the rest of my script could run, so I wrapped the rest of my script in a function and invoked it in the callback of chrome.storage API.</p><p>Now that I had my background and content scripts up and running and speaking to each other, I needed to update my manifest file. Initially I added both scripts to my manifest file, which now looked like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/782/1*B1Z0B3Accx_r40mwakFRWg.png" /></figure><p>However, this gave me some unwanted functionality. If you write your content script like this in your manifest file then it will automatically run. Maybe that is something you want, I didn’t, so I simply removed it and so the only time the content script runs is when the browser action is clicked (you can see this listener set up above).</p><p>The last problem I faced was how to debug my code. If you debug like me, then you are throwing out console.logs left, right, and center. The problem was: I couldn’t find any of them!</p><p>Here’s where they all were: logs in your content script<em> </em>will go to the browser’s console. If you have created a popup for your browser action that calls on a js file of it’s own then those logs are in the popup’s console. You can see this by right clicking on the browser action and “Inspect popup”:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/246/1*wpKdWb86QV58l2lXJFO03w.png" /><figcaption>Mine is disabled because there is no popup</figcaption></figure><p>And lastly, the<em> </em>logs you put in a background script are found in the console located on chrome://extensions/ (the page you load your extension on) in a section called “Inspect views”:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/764/1*cLZSED1V2F9Bl4ly8sVVmQ.png" /></figure><p>That’s all there is to it! I hope this helps ease you through some of the rough patches I hit as you build your own awesome extensions.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=18c2848cf822" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>