<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Mike Haslam</title>
    <description>The latest articles on DEV Community by Mike Haslam (@yourdevguy).</description>
    <link>https://dev.to/yourdevguy</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F261724%2F6568de6d-5a30-4f5a-a05b-788b9c744d9a.png</url>
      <title>DEV Community: Mike Haslam</title>
      <link>https://dev.to/yourdevguy</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/yourdevguy"/>
    <language>en</language>
    <item>
      <title>How To Use Firebase Authentication With Gatsby</title>
      <dc:creator>Mike Haslam</dc:creator>
      <pubDate>Wed, 27 Oct 2021 23:57:29 +0000</pubDate>
      <link>https://dev.to/yourdevguy/how-to-use-firebase-authentication-with-gatsby-5b5b</link>
      <guid>https://dev.to/yourdevguy/how-to-use-firebase-authentication-with-gatsby-5b5b</guid>
      <description>&lt;p&gt;I have been working on a new project. And I wanted to share my journey of implementing Firebase Authentication on a Gatsby site. Hope this can be helpful to others. I always appreciate any feedback or questions.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://ongomobile.medium.com/how-to-use-firebase-authentication-with-gatsby-ad4a5cdcb295"&gt;https://ongomobile.medium.com/how-to-use-firebase-authentication-with-gatsby-ad4a5cdcb295&lt;/a&gt;&lt;/p&gt;

</description>
      <category>react</category>
      <category>gatsby</category>
      <category>firebase</category>
      <category>jamstack</category>
    </item>
    <item>
      <title>Learning SwiftUI, MVVM and Firebase</title>
      <dc:creator>Mike Haslam</dc:creator>
      <pubDate>Sun, 09 May 2021 23:00:18 +0000</pubDate>
      <link>https://dev.to/yourdevguy/learning-swiftui-mvvm-and-firebase-oa3</link>
      <guid>https://dev.to/yourdevguy/learning-swiftui-mvvm-and-firebase-oa3</guid>
      <description>&lt;p&gt;SwiftUI is such a pleasure for a new iOS developer like myself. When you combine it with Firebase, it’s so much easier now to build robust apps. I want to share my journey in building a simple social media app.&lt;/p&gt;

&lt;p&gt;Here are the details, including a GitHub repository:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://ongomobile.medium.com/learning-swiftui-mvvm-and-firebase-bbc3e5073a25?sk=2209e869c02840ead810a83724cb6b59"&gt;https://ongomobile.medium.com/learning-swiftui-mvvm-and-firebase-bbc3e5073a25?sk=2209e869c02840ead810a83724cb6b59&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Update I added a few more features, updated like button.&lt;/p&gt;

</description>
      <category>swift</category>
      <category>ios</category>
      <category>beginners</category>
      <category>firebase</category>
    </item>
    <item>
      <title>Ben Awad is building an open-source app similar to ClubHouse</title>
      <dc:creator>Mike Haslam</dc:creator>
      <pubDate>Sun, 14 Mar 2021 19:43:20 +0000</pubDate>
      <link>https://dev.to/yourdevguy/ben-awad-is-building-an-open-source-app-similar-to-clubhouse-2h7a</link>
      <guid>https://dev.to/yourdevguy/ben-awad-is-building-an-open-source-app-similar-to-clubhouse-2h7a</guid>
      <description>&lt;p&gt;It looks pretty cool. It's live, works in the browser.&lt;/p&gt;

&lt;p&gt;Here is a video&lt;br&gt;
&lt;a href="https://lnkd.in/gKMnWPJ"&gt;https://lnkd.in/gKMnWPJ&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here is website&lt;br&gt;
&lt;a href="https://dogehouse.tv/"&gt;https://dogehouse.tv/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here is repo&lt;br&gt;
&lt;a href="https://lnkd.in/gEmSnnC"&gt;https://lnkd.in/gEmSnnC&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  clubhouseapp #startup #opensource #yourdevguy
&lt;/h1&gt;

</description>
    </item>
    <item>
      <title>Design thinking for developers</title>
      <dc:creator>Mike Haslam</dc:creator>
      <pubDate>Thu, 18 Feb 2021 02:06:49 +0000</pubDate>
      <link>https://dev.to/yourdevguy/design-thinking-for-developers-cbl</link>
      <guid>https://dev.to/yourdevguy/design-thinking-for-developers-cbl</guid>
      <description>&lt;p&gt;In wanting to get better at design. I came across this interview of David Kelley the founder of IDEO pals with Steve Jobs. What an amazing man that helped so many people. After watching the biggest takeaway for me about Design Thinking is to have empathy for the user and understand their problems. Hope this is helpful for you too.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--fCmKvqev--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wd29l35q3gzcsr0lo8lu.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--fCmKvqev--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wd29l35q3gzcsr0lo8lu.jpeg" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.youtube.com/watch?v=GYkb6vfKMI4"&gt;https://www.youtube.com/watch?v=GYkb6vfKMI4&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>How To Build A Custom Image Picker In React Native &amp; Expo</title>
      <dc:creator>Mike Haslam</dc:creator>
      <pubDate>Thu, 11 Feb 2021 19:43:04 +0000</pubDate>
      <link>https://dev.to/yourdevguy/how-to-build-a-custom-image-picker-in-react-native-expo-3k5g</link>
      <guid>https://dev.to/yourdevguy/how-to-build-a-custom-image-picker-in-react-native-expo-3k5g</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--lDw2F7Ei--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/hdvje69kd9jz2ywvn1pb.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--lDw2F7Ei--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/hdvje69kd9jz2ywvn1pb.jpg" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://ongomobile.medium.com/how-to-build-a-custom-image-picker-in-react-native-expo-afcbf7c0c5a7"&gt;https://ongomobile.medium.com/how-to-build-a-custom-image-picker-in-react-native-expo-afcbf7c0c5a7&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I am working on a React Native app. So I thought I would share some struggles that I found a solution for when dealing with static and user images.&lt;/p&gt;

&lt;p&gt;In the article, I wrote you can try out the code live on different devices in the browser, using Expo Snack it's kinda fun. Let me know what you think?&lt;/p&gt;

</description>
      <category>expo</category>
      <category>ios</category>
      <category>android</category>
      <category>reactnative</category>
    </item>
    <item>
      <title>How To Open Apple Maps From An Address In SwiftUI</title>
      <dc:creator>Mike Haslam</dc:creator>
      <pubDate>Wed, 27 Jan 2021 22:28:41 +0000</pubDate>
      <link>https://dev.to/yourdevguy/how-to-open-apple-maps-from-an-address-in-swiftui-2gfo</link>
      <guid>https://dev.to/yourdevguy/how-to-open-apple-maps-from-an-address-in-swiftui-2gfo</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--GCVxj31v--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/2k1zy3i9kl9s9yn8iyqe.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--GCVxj31v--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/2k1zy3i9kl9s9yn8iyqe.PNG" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In an iOS app I am working on I need to show a map from an address.&lt;br&gt;
But after researching and asking some questions I was able to get it to work. &lt;/p&gt;

&lt;p&gt;I must admit I struggled quite a bit with how to show an alert if the address string was invalid In hindsight, the solution is pretty straightforward. It comes down to just Observing a published property in an Observable Object Class.&lt;/p&gt;

&lt;p&gt;I am finding that SwiftUI has really made things a lot simpler.&lt;br&gt;
I put up a small repository using this feature maybe it would be helpful to others.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/Ongomobile/OpenMapInSwiftUI"&gt;Open Apple Maps In SwiftUI&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;Here are some resources I used in my research.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://developer.apple.com/documentation/corelocation/clgeocoder/1423591-geocodeaddressstring"&gt;Apple docs&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.raywenderlich.com/14255236-swiftui-maps-location-fundamentals"&gt;Ray Wenderlich Tutorial&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.hackingwithswift.com/"&gt;Hacking With Swift&lt;/a&gt;&lt;/p&gt;

</description>
      <category>ios</category>
      <category>swift</category>
      <category>beginners</category>
    </item>
    <item>
      <title># Create a Tags UI Component in React With Styled Components</title>
      <dc:creator>Mike Haslam</dc:creator>
      <pubDate>Tue, 26 Jan 2021 21:27:13 +0000</pubDate>
      <link>https://dev.to/yourdevguy/create-a-tags-ui-component-in-react-and-styled-components-pok</link>
      <guid>https://dev.to/yourdevguy/create-a-tags-ui-component-in-react-and-styled-components-pok</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--e7CTn8bw--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/qd3w1nilkw4ftutx142z.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--e7CTn8bw--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/qd3w1nilkw4ftutx142z.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://bef94.csb.app/"&gt;Try it here&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I need to make a React component that enables users to create tags on their profile.&lt;/p&gt;

&lt;p&gt;So I went looking to see if anyone had already created such a component. I did find this component on CodePen by Fabio here is a link to his pen&lt;br&gt;
 &lt;a href="https://lnkd.in/gE-rDmT"&gt;Codepen&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;I decided instead of Willy Nilly cutting and pasting into my project, I would instead refactor to use Functional Components managing state with Hooks and styling with Styled Components.&lt;/p&gt;

&lt;p&gt;I have found that refactoring other people’s code really forces you to understand how the code actually works instead of just following along.&lt;/p&gt;

&lt;p&gt;Here is a Code Sandbox of my refactor have a look let me know what you think or if you have any optimization suggestions.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://lnkd.in/g4swwEg"&gt;My Code Sandbox&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;&lt;a href="https://dev.to/t/UI"&gt;#UI&lt;/a&gt;&lt;br&gt;
&lt;a href="https://dev.to/t/ReactComponents"&gt;#ReactComponents&lt;/a&gt;&lt;br&gt;
&lt;a href="https://det.to/t/React"&gt;#ReactComponents&lt;/a&gt;&lt;br&gt;
&lt;a href="https://det.to/t/StyledComponents"&gt;#StyledComponents&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Fun with React and Styled Components</title>
      <dc:creator>Mike Haslam</dc:creator>
      <pubDate>Mon, 04 Jan 2021 03:51:26 +0000</pubDate>
      <link>https://dev.to/yourdevguy/fun-with-react-and-styled-components-57pk</link>
      <guid>https://dev.to/yourdevguy/fun-with-react-and-styled-components-57pk</guid>
      <description>&lt;p&gt;I need to make a React component that enables users to create tags on their profile. It's for a &lt;a href="https://www.namjai.io/"&gt;React project&lt;/a&gt; of mine, still a work in progress.&lt;/p&gt;

&lt;p&gt;So I went looking to see if anyone had already created such a component. I did find this component on CodePen by Fabio here is a &lt;a href="https://codepen.io/fabioioio/pen/mmZZVo"&gt;link to his pen&lt;/a&gt;  &lt;/p&gt;

&lt;p&gt;I decided instead of Willy Nilly cutting and pasting into my project, I would instead refactor to use Functional Components managing state with Hooks and styling with Styled Components.&lt;/p&gt;

&lt;p&gt;I have found that refactoring other people’s code really forces you to understand how the code actually works instead of just following along.&lt;/p&gt;

&lt;p&gt;Here is &lt;a href="https://codesandbox.io/s/ui-styledtags-9x3cl"&gt;My CodeSandbox&lt;/a&gt; of my refactor have a look let me know what you think or if you have any optimization suggestions.&lt;/p&gt;

&lt;p&gt;Here is a link to &lt;a href="https://github.com/Ongomobile/Lets_Share_Code"&gt;my repository&lt;/a&gt; with a few other styled-components would be cool if others wanted to contribute I could add some more also.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>How To Built A Chrome Extension</title>
      <dc:creator>Mike Haslam</dc:creator>
      <pubDate>Thu, 31 Dec 2020 21:15:19 +0000</pubDate>
      <link>https://dev.to/yourdevguy/how-to-built-a-chrome-extension-k1a</link>
      <guid>https://dev.to/yourdevguy/how-to-built-a-chrome-extension-k1a</guid>
      <description>&lt;p&gt;My inspiration was my Love of Thailand and curiosity about a new rabbit hole.&lt;/p&gt;

&lt;p&gt;I was doing my normal routine when I came across the &lt;a href="https://momentumdash.com/" rel="noopener noreferrer"&gt;Momentum&lt;/a&gt; Chrome extension. It was very inspiring and totally worth the pro price.&lt;br&gt;
So my analytical mind said it would be fun to reverse engineer this.&lt;/p&gt;

&lt;p&gt;So I did what most people do and did a search on google. My first query was how to create a chrome extension.  What I found initially that caught my attention was a post on Medium by &lt;a href="https://medium.com/coding-in-simple-english/how-to-create-chrome-extension-7dd396e884ef" rel="noopener noreferrer"&gt;Andrei Elekes&lt;/a&gt; it got me started and was very helpful. But I wanted to learn more so I went to the &lt;a href="https://developer.chrome.com/docs/extensions/mv3/getstarted/" rel="noopener noreferrer"&gt;Google docs&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Having not built a Chrome Extension before, I did what most developers do to get familiar and I started to build the Hello World version from the docs. &lt;/p&gt;

&lt;p&gt;I got into the first couple of steps then encountered my first error, hey no problem I thought let's just read it?&lt;/p&gt;

&lt;p&gt;“&lt;strong&gt;The “background.scripts” key cannot be used with manifest_version 3. Use the “background.service_worker” key instead.”&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;What I found after researching and banging around a bit was google is in the process of implementing V3 that uses services workers instead of background. &lt;/p&gt;

&lt;p&gt;This is one of V3 changes, but in the getting started tutorial in the manifest file it says “manifest_version”: 3 but it still had the V2&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;background”: {
    “scripts”: [“background.js”],
    “persistent”: false
  },
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Seeing that as of 12/29/20 the getting started tutorial has not been updated, I decided just to go forward with the getting started tutorial in manifest  V2   &lt;strong&gt;The answer to the initial error for me is just declaring “manifest_version”: 2&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;After finding focus again and wanting to close this rabbit hole. I decided I wanted to create a basic Chrome Extension using manifest V3 that would load a random background Image in the chrome browser tab. &lt;strong&gt;Details Below&lt;/strong&gt; To continue to get familiar I continued with the &lt;a href="https://developer.chrome.com/docs/extensions/mv3/getstarted/" rel="noopener noreferrer"&gt;getting started tutorial in the docs&lt;/a&gt; It’s actually quite good and easy to follow in the context of manifest V2. &lt;/p&gt;

&lt;p&gt;Rather than re-creating each step, this is what I found it gives you the fundamentals and is not hard to implement. In the end, it has a popup and has a button you can change colors in options this is great to understand the fundamentals. &lt;/p&gt;

&lt;p&gt;I was hungry for more so in my digging I discovered this file in google docs.&lt;br&gt;
&lt;a href="https://github.com/GoogleChrome/chrome-extensions-samples" rel="noopener noreferrer"&gt;GitHub - GoogleChrome/chrome-extensions-samples: Chrome Extensions Samples&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the tutorials section, the get_started_complete file you can see the popup.js has a variation where the onclick listener can change the background color of the URL that is listening for the message in background.js&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;So how did I make my simple extension that adds a random background image on chrome browser?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;First I did what most developers do I googled. In the end, what I found was if I asked the right question sooner it would have been much quicker to find the solution. &lt;/p&gt;

&lt;p&gt;It was actually quite simple in that I had already written the code for setting a random Image on the body tag in the first single-page JavaScript app I built  &lt;a href="https://www.thailandexplorer.org/" rel="noopener noreferrer"&gt;Thailand explorer&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;What was the right question?  &lt;a href="https://stackoverflow.com/questions/39916079/how-to-create-a-chrome-extension-to-change-the-default-tab" rel="noopener noreferrer"&gt;How to create a chrome extension to change the default tab&lt;/a&gt; &lt;/p&gt;
&lt;h2&gt;
  
  
  Steps to create random image background extension version1.0
&lt;/h2&gt;

&lt;p&gt;Set up file structure root directory folder, images folder, manifest.json, newTab.html, newTab.css, newTab.js. &lt;strong&gt;Optional Files to use later&lt;/strong&gt; options.html, options.js, popup.html, popup.js&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Create the  initial manifest&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
  “name”: “Random Image”,
  “version”: “1.0”,
  “description”: “A random  background image generator”,
  “manifest_version”: 3
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Add Your directory as an extension in developer mode&lt;/strong&gt; &lt;/p&gt;

&lt;p&gt;Open the Extension Management page by navigating to &lt;br&gt;
          &lt;a href="https://dev.tochrome://extensions/"&gt;chrome://extensions&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Enable Developer Mode by clicking the toggle switch &lt;br&gt;
            next to &lt;strong&gt;Developer mode&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Click the &lt;strong&gt;LOAD UNPACKED&lt;/strong&gt; button and select the &lt;br&gt;
            extension directory.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Frir8yu21ytszqdu7bfys.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Frir8yu21ytszqdu7bfys.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Add icons&lt;/strong&gt;  You can create your own or grab these from the Google getting started tutorial. Here is a link to docs on sizes and what they are for. &lt;a href="https://developer.chrome.com/docs/extensions/mv3/user_interface/#icons" rel="noopener noreferrer"&gt;Icon Docs&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Update manifest.json&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
  “name”: “Random Image”,
  “version”: “1.0”,
  “description”: “A random  background image generator”,
  “chrome_url_overrides”: {
    “newtab”: “newtab.html”
   },
   “action”: {
    “default_icon”: {
      “16”: “images/icon16.png”,
      “32”: “images/icon32.png”,
      “48”: “images/icon48.png”,
      “128”: “images/icon128.png”
    },
    “default_title”: “Random Image”,
    “default_popup”: “popup.html”
   },
   “icons”: {
    “16”: “images/icon16.png”,
    “32”: “images/icon32.png”,
    “48”: “images/icon48.png”,
    “128”: “images/icon128.png”
   },
    “manifest_version”: 3
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Create newTab.html&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;!DOCTYPE html&amp;gt;
&amp;lt;html lang=“en”&amp;gt;
  &amp;lt;head&amp;gt;
    &amp;lt;meta charset=“UTF-8” /&amp;gt;
    &amp;lt;meta name=“viewport” content=“width=device-width, initial-scale=1.0” /&amp;gt;
    &amp;lt;title&amp;gt;Thailand Images&amp;lt;/title&amp;gt;
    &amp;lt;link rel=“stylesheet” href=“newTab.css” /&amp;gt;
  &amp;lt;/head&amp;gt;
  &amp;lt;body class=“pageBody”&amp;gt;
    &amp;lt;script src=“newTab.js”&amp;gt;&amp;lt;/script&amp;gt;
  &amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Create newTab.css&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;body {
  background: linear-gradient(rgba(0, 0, 0, 0.4), rgba(0, 0, 0, 0.4)),
    url(“https://thailand-exp-images.s3-us-west-2.amazonaws.com/komloy.jpg”);
  background-repeat: no-repeat;
  background-size: cover;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Create newTab.js&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const pageBody = document.body;
const ready = (callback) =&amp;gt; {
  if (document.readyState != “loading”) callback();
  else document.addEventListener(“DOMContentLoaded”, callback);
};

// TODO: Add images dynamically from extension settings
const setRandomImage = () =&amp;gt; {
  const IMG_URL = “https://thailand-exp-images.s3-us-west-2.amazonaws.com/“;
  const backgroundImages = [
    “riceLady.jpg”,
    “raileyBeach.jpg”,
    “monksTemple.jpg”,
    “monkeys.jpg”,
    “manChang.jpg”,
    “maeYai.jpg”,
    “girlsWater.jpg”,
    “girlChang.jpg”,
    “floatingMarket.jpg”,
    “buddha.jpg”,
    “boyBudah.jpg”,
    “ancient.jpg”,
    “thaiBackground.jpg”,
    “Yipeng.jpg”,
    “islands.jpg”,
    “Loy_Krathong.jpg”,
    “thaiBudah.jpg”,
    “komloy.jpg”,
  ];

  const randomImage =
    backgroundImages[Math.floor(Math.random() * backgroundImages.length)];
  pageBody.style.backgroundImage = `url(${IMG_URL}${randomImage})`;
};

ready(() =&amp;gt; {
  setRandomImage();
});

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Optional files for later options &amp;amp; popup&lt;/p&gt;




&lt;p&gt;If you like to see code here is my repo’s&lt;br&gt;
&lt;a href="https://github.com/Ongomobile/random-bg-extension" rel="noopener noreferrer"&gt;GitHub - Ongomobile/random-bg-extension&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/Ongomobile/change-bg-color-chrome-extension" rel="noopener noreferrer"&gt;GitHub - Ongomobile/change-bg-color-chrome-extension&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The next challenge is to add images in options or popup and not be dependent on hardcoded images.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;I hope this has been helpful please feel free to reach out with feedback or questions.&lt;/p&gt;

&lt;p&gt;If you would like to learn more you can find me on: &lt;br&gt;
&lt;a href="https://www.linkedin.com/in/ongo-mobile/" rel="noopener noreferrer"&gt;LinkedIn&lt;/a&gt;, &lt;a href="https://twitter.com/OngoMobile" rel="noopener noreferrer"&gt;Twitter&lt;/a&gt;, &lt;a href="https://www.facebook.com/ongomobile" rel="noopener noreferrer"&gt;Facebook&lt;/a&gt;, &lt;a href="https://ongomobile.medium.com/" rel="noopener noreferrer"&gt;Medium&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Cheers,&lt;br&gt;
Mike Haslam&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>html</category>
      <category>tutorial</category>
    </item>
  </channel>
</rss>
