Ask Your Question
1

What is the method to have a Chrome extension show up automatically upon visiting a specific website?

asked 2021-09-22 11:00:00 +0000

huitzilopochtli gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2021-08-05 08:00:00 +0000

qstack gravatar image

To have a Chrome extension show up automatically upon visiting a specific website, you can use the content script feature of Chrome extensions.

  1. Open your extension's manifest.json file.

  2. Add the "content_scripts" field and configure it to match the URL of the website where you want your extension to show up.

Example:

"content_scripts": [
   {
      "matches": ["https://www.website.com/*"],
      "js": ["content_script.js"]
   }
]

Here, the "matches" field specifies the URL pattern to match and the "js" field specifies the name of the JavaScript file that contains your content script.

  1. Create your content script file (e.g. content_script.js) and add the logic for your extension to execute on the specified website.

Example:

if (window.location.href.includes("https://www.website.com/")) {
   // extension logic here
}
  1. Save your changes and reload your extension to see it automatically appear when you visit the specified website.
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2021-09-22 11:00:00 +0000

Seen: 10 times

Last updated: Aug 05 '21