- Navigate to the extensions page
(chrome://extensions/)in Google Chrome - Turn on "Developer mode". (Toggle in top right corner)
- Click on "Load Unpacked" and select the folder on your machine containing the extension's code
- The file
content-script.jsinitialises the functionality by injecting a JS file calledpost-message.jsinto every website visited when the extension is enabled - If
window.Shopifyexists on that websitepost-message.jscollects data from thewindowobject and sends it back tocontent-script.js - The extension then needs to check if the user has admin access to that Shopify store.
service-worker.jsperforms a fetch request to thehttps://admin.shopify.com/store/{storeName}/shop.jsonendpoint which only succeeds when the user is signed in and has admin rightsservice-worker.jsreturns the collected shop data tocontent-script.jscontent-script.jsstores the shop data insessionStorageso the extension only needs to perform one fetch request per session, per store.
- When the user clicks on the extension 'popup.js' requests the shop data from
content-script.js- When shop data exists the popup displays helpful links relevant to the current page being viewed by the user