Example code for a Chrome Extension

Here's an example code for a simple Chrome Extension that replaces all occurrences of the word "lock" with "unlock" on a web page:


  "manifest_version": 2,
  "name": "Locksmith Extension",
  "version": "1.0",
  "description": "Replace all occurrences of 'lock' with 'unlock'.",
  "permissions": ["activeTab"],
  "content_scripts": [{
    "matches": ["http://*/*", "https://*/*"],
    "js": ["content.js"]


// Replace all occurrences of 'lock' with 'unlock'
document.body.innerHTML = document.body.innerHTML.replace(/lock/gi, 'unlock');


In this example, the manifest.json file is used to declare the name, version, and permissions of the extension, as well as to specify the content script that will be injected into web pages. The content.js file is the content script that will be executed on web pages that match the matches property in the manifest.

Note that this is a very basic example and most extensions will be much more complex. Also, keep in mind that the activeTab permission is a powerful permission that allows the extension to access and modify the content of the currently active tab. Use this permission carefully and only when necessary.

How to install my own chrome extension on my phone with google chrome browser

To install your own Chrome extension on your phone using Google Chrome browser, you can follow these steps:

  1. Open the Google Chrome app on your phone.
  2. Go to the Chrome Web Store Developer Dashboard by typing "chrome.google.com/webstore/developer/dashboard" in the address bar or by searching for it on Google.
  3. Sign in with the Google account associated with your extension.
  4. Click on the "Add new item" button and select "Choose file" to upload your extension package. Your extension package should be a ZIP file containing your extension's manifest file and other necessary files.
  5. Fill out the extension details, such as the name, description, and images.
  6. Publish your extension by clicking on the "Publish changes" button.
  7. Wait for the extension to be published, which may take a few minutes or hours.
  8. Open the Google Chrome app on your phone and sign in with the same Google account you used to publish your extension.
  9. Go to the Chrome Web Store and search for your extension.
  10. Tap on the extension's icon to go to its detail page.
  11. Tap on the "Add to Chrome" button.
  12. Review the permissions the extension requires and tap "Add Extension" to confirm.
  13. Wait for the extension to install, which may take a few seconds or minutes depending on the extension's size and complexity.
  14. Once the installation is complete, the extension will appear in your browser's toolbar or menu.

Note that you may need to enable "Developer mode" in the Chrome browser settings on your phone in order to install your own extension. Also, keep in mind that your extension may not work as expected on mobile devices due to differences in screen size, input methods, and other factors.

- All From ChatGPT