← all conversations

Chrome extension to monitor CloudResearch.

2023-04-222 turns2,918 charstext-davinci-002-render-sha
chrome-extensionpage-monitoringaudio-notification

Summary

create a chrome extension to monitor cloudresearch page and play an audio notification on changes

Messages

help me write an extension for chrome that will monitor the page connect.cloudresearch.com and play an audio file bell2.mp3 when there are changes to the page
Sure, I can help you with that! Here are the steps to create a Chrome extension that monitors the page connect.cloudresearch.com and plays an audio file bell2.mp3 when there are changes to the page: 1. Create a new folder for your extension, and name it something like "cloudresearch-monitor". 2. Inside this folder, create a new file named "manifest.json". This file is required for all Chrome extensions, and it specifies various details about your extension. 3. Open "manifest.json" in a text editor, and add the following code: ``` { "name": "CloudResearch Monitor", "version": "1.0", "manifest_version": 2, "description": "Monitors connect.cloudresearch.com and plays a bell sound when changes are detected.", "permissions": ["tabs"], "background": { "scripts": ["background.js"], "persistent": false } } ``` This code sets the name and version of your extension, and specifies that it will need permission to access tabs. It also sets up a background script called "background.js" that will run in the background and monitor the page. 4. Create a new file named "background.js" inside the same folder as "manifest.json". This file will contain the code that monitors the page and plays the sound. 5. Open "background.js" in a text editor, and add the following code: ``` chrome.tabs.onUpdated.addListener((tabId, changeInfo, tab) => { if (tab.url.includes("connect.cloudresearch.com")) { chrome.tabs.executeScript(tabId, { code: "document.documentElement.innerHTML" }, (result) => { if (result && result.length > 0) { const html = result[0]; const bell = new Audio(chrome.runtime.getURL("bell2.mp3")); if (html !== localStorage.getItem("cloudresearch-html")) { localStorage.setItem("cloudresearch-html", html); bell.play(); } } }); } }); ``` This code listens for updates to any tabs in Chrome, and checks if the updated tab is on the "connect.cloudresearch.com" page. If it is, it gets the HTML content of the page and compares it to the previous HTML content (stored in localStorage). If there are differences, it plays the "bell2.mp3" sound. 6. Add the "bell2.mp3" file to your extension folder. This is the sound that will be played when there are changes to the page. 7. Open Chrome and go to chrome://extensions. Click the "Load unpacked" button, and select the folder where you saved your extension. 8. Your extension should now be loaded and active. Open a tab to "connect.cloudresearch.com" and make some changes to the page. You should hear the bell sound play when there are changes. That's it! You've successfully created a Chrome extension that monitors the page connect.cloudresearch.com and plays a sound when there are changes.
text-davinci-002-render-sha