A Chrome extension that automates commenting on LinkedIn. It reads a post's text and uses Google's Gemini API to generate a relevant professional comment then posts it into LinkedIn's comment box automatically.
Built as a Final Year Project to demonstrate browser extension development DOM automation and integration with a generative AI API.
- You open a LinkedIn post and click the extension icon.
- The extension reads the text of the post from the page.
- That text is sent to Gemini which generates a short professional comment.
- The extension types the comment into LinkedIn's comment box and clicks Comment for you.
- Chrome Extension Manifest V3 for the extension framework
- JavaScript for core logic
- HTML and CSS for the popup UI
- Google Gemini API for generating comments
- Chrome Extension APIs scripting tabs storage and runtime messaging
manifest.json Extension configuration and permissions
popup.html The popup UI shown when clicking the icon
popup.js Calls Gemini and inserts/posts the comment
background.js Bridges popup and LinkedIn page to extract post text
contentscript.js Injected into LinkedIn pages to read post text
manifest.json sets up the popup the background service worker and a content script that runs on LinkedIn pages along with the permissions needed to read and act on the active tab.
contentscript.js runs automatically on LinkedIn. It finds the post's text block in the page grabs the text inside it and sends that text to the background script.
background.js sits between the popup and the LinkedIn tab. When the popup asks for a post's description it runs a script inside the active tab to scrape the text and sends the result back.
popup.js is where the action happens. It has three buttons:
- Go to Post opens a LinkedIn post URL you paste in
- Fetch Post Description pulls the post's text and shows a preview comment from Gemini
- Auto Comment sends the post text to Gemini gets a generated comment types it into LinkedIn's comment box and clicks Comment to publish it
In short the popup asks the background script for the post text the background script scrapes it from the page that text goes to Gemini and the reply comes back as a comment that gets typed in and posted.
- activeTab to work with the LinkedIn tab you have open
- scripting to run code inside the LinkedIn page for reading and posting
- tabs to read and update the active tab
- storage reserved for extension settings
- Host access to linkedin.com so the extension only runs there
- Download or clone the project
- Get a Gemini API key from Google AI Studio
- Open popup.js and add your key in place of the existing one
- Go to chrome://extensions in Chrome and turn on Developer mode
- Click Load unpacked and select the project folder
- The extension icon should now show up in your toolbar
- Open the LinkedIn post you want to comment on
- Click the extension icon
- Click Fetch Post Description to see the post text and a suggested comment
- Click Auto Comment to have it write and post the comment for you
The extension depends on specific LinkedIn page elements so if LinkedIn changes its layout some selectors may stop working. Automating actions like posting comments may also go against LinkedIn's terms of service so this project is meant for learning and demonstration rather than everyday use.
Saim Maqsood — Final Year Project