Limit Chrome Extension to certain URLs?











up vote
14
down vote

favorite
3












Is there a way to limit a Chrome extension to only run on certain urls?



Say I want the extension to run only if the domain is Amazon.com. I realize you can put a check at the top of the scripts, then execute the rest of the script only if the check matches.



However, can you prevent the extension from running at all?










share|improve this question


























    up vote
    14
    down vote

    favorite
    3












    Is there a way to limit a Chrome extension to only run on certain urls?



    Say I want the extension to run only if the domain is Amazon.com. I realize you can put a check at the top of the scripts, then execute the rest of the script only if the check matches.



    However, can you prevent the extension from running at all?










    share|improve this question
























      up vote
      14
      down vote

      favorite
      3









      up vote
      14
      down vote

      favorite
      3






      3





      Is there a way to limit a Chrome extension to only run on certain urls?



      Say I want the extension to run only if the domain is Amazon.com. I realize you can put a check at the top of the scripts, then execute the rest of the script only if the check matches.



      However, can you prevent the extension from running at all?










      share|improve this question













      Is there a way to limit a Chrome extension to only run on certain urls?



      Say I want the extension to run only if the domain is Amazon.com. I realize you can put a check at the top of the scripts, then execute the rest of the script only if the check matches.



      However, can you prevent the extension from running at all?







      google-chrome google-chrome-extension






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked May 8 '12 at 18:23









      amp343

      611410




      611410
























          3 Answers
          3






          active

          oldest

          votes

















          up vote
          14
          down vote













          Welp, it figures I would find the answer to this right after posting the question, even though I have been stuck for a while...



          http://code.google.com/chrome/extensions/content_scripts.html



          In manifest.json:



          "content_scripts": [
          {
          "matches": [...urls...],
          "exclude_matches": [...urls...],
          "css": [...]
          }
          ]





          share|improve this answer



















          • 4




            FYI This doesn't prevent the script from running, it prevents chrome from injecting it into pages that don't match.
            – Jim Schubert
            May 8 '12 at 18:44






          • 1




            True, I guess that was the nature of my original question, should have worded it more carefully, Thanks.
            – amp343
            May 8 '12 at 18:58


















          up vote
          3
          down vote













          There's a Chrome extension for this: Extension Automation. I had gone the route of modifying manifests before, but this is easier.






          share|improve this answer





















          • It's 404 Not Found.
            – Balasubramani M
            Oct 28 at 5:17


















          up vote
          0
          down vote













          As a user, with Chrome 71 (or maybe even before) with chrome://flags/#extension-active-script-permission (you may need to enable User consent for extension scripts flag) allows you to right click extension icons and select "This can read and change site data" then you can choose:




          • When you click the extension

          • On current-domain-name.com

          • On all sites (default)


          enter image description here



          This way you can limit an extension to only run on certain domains very quickly.






          share|improve this answer























          • Limit as a user, or as a developer?
            – Xan
            Nov 15 at 11:27










          • @Xan You're right the question isn't very clear either, so I added "as a user".
            – Wernight
            Nov 19 at 13:56










          • I believe that from the context: 1) It's a question on StackOverflow (and not, say, Super User), 2) The original author self-responded with "how to do it through an extension manifest", the intent here is a developer question. Which makes it important to at least note that developers have no control over this mechanism. Though it's not fully off-topic as developers need to be aware of this, and may need to inform the users of this.
            – Xan
            Nov 19 at 14:02











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f10504239%2flimit-chrome-extension-to-certain-urls%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          3 Answers
          3






          active

          oldest

          votes








          3 Answers
          3






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          up vote
          14
          down vote













          Welp, it figures I would find the answer to this right after posting the question, even though I have been stuck for a while...



          http://code.google.com/chrome/extensions/content_scripts.html



          In manifest.json:



          "content_scripts": [
          {
          "matches": [...urls...],
          "exclude_matches": [...urls...],
          "css": [...]
          }
          ]





          share|improve this answer



















          • 4




            FYI This doesn't prevent the script from running, it prevents chrome from injecting it into pages that don't match.
            – Jim Schubert
            May 8 '12 at 18:44






          • 1




            True, I guess that was the nature of my original question, should have worded it more carefully, Thanks.
            – amp343
            May 8 '12 at 18:58















          up vote
          14
          down vote













          Welp, it figures I would find the answer to this right after posting the question, even though I have been stuck for a while...



          http://code.google.com/chrome/extensions/content_scripts.html



          In manifest.json:



          "content_scripts": [
          {
          "matches": [...urls...],
          "exclude_matches": [...urls...],
          "css": [...]
          }
          ]





          share|improve this answer



















          • 4




            FYI This doesn't prevent the script from running, it prevents chrome from injecting it into pages that don't match.
            – Jim Schubert
            May 8 '12 at 18:44






          • 1




            True, I guess that was the nature of my original question, should have worded it more carefully, Thanks.
            – amp343
            May 8 '12 at 18:58













          up vote
          14
          down vote










          up vote
          14
          down vote









          Welp, it figures I would find the answer to this right after posting the question, even though I have been stuck for a while...



          http://code.google.com/chrome/extensions/content_scripts.html



          In manifest.json:



          "content_scripts": [
          {
          "matches": [...urls...],
          "exclude_matches": [...urls...],
          "css": [...]
          }
          ]





          share|improve this answer














          Welp, it figures I would find the answer to this right after posting the question, even though I have been stuck for a while...



          http://code.google.com/chrome/extensions/content_scripts.html



          In manifest.json:



          "content_scripts": [
          {
          "matches": [...urls...],
          "exclude_matches": [...urls...],
          "css": [...]
          }
          ]






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited May 9 '16 at 10:31









          Skarlinski

          1,627521




          1,627521










          answered May 8 '12 at 18:38









          amp343

          611410




          611410








          • 4




            FYI This doesn't prevent the script from running, it prevents chrome from injecting it into pages that don't match.
            – Jim Schubert
            May 8 '12 at 18:44






          • 1




            True, I guess that was the nature of my original question, should have worded it more carefully, Thanks.
            – amp343
            May 8 '12 at 18:58














          • 4




            FYI This doesn't prevent the script from running, it prevents chrome from injecting it into pages that don't match.
            – Jim Schubert
            May 8 '12 at 18:44






          • 1




            True, I guess that was the nature of my original question, should have worded it more carefully, Thanks.
            – amp343
            May 8 '12 at 18:58








          4




          4




          FYI This doesn't prevent the script from running, it prevents chrome from injecting it into pages that don't match.
          – Jim Schubert
          May 8 '12 at 18:44




          FYI This doesn't prevent the script from running, it prevents chrome from injecting it into pages that don't match.
          – Jim Schubert
          May 8 '12 at 18:44




          1




          1




          True, I guess that was the nature of my original question, should have worded it more carefully, Thanks.
          – amp343
          May 8 '12 at 18:58




          True, I guess that was the nature of my original question, should have worded it more carefully, Thanks.
          – amp343
          May 8 '12 at 18:58












          up vote
          3
          down vote













          There's a Chrome extension for this: Extension Automation. I had gone the route of modifying manifests before, but this is easier.






          share|improve this answer





















          • It's 404 Not Found.
            – Balasubramani M
            Oct 28 at 5:17















          up vote
          3
          down vote













          There's a Chrome extension for this: Extension Automation. I had gone the route of modifying manifests before, but this is easier.






          share|improve this answer





















          • It's 404 Not Found.
            – Balasubramani M
            Oct 28 at 5:17













          up vote
          3
          down vote










          up vote
          3
          down vote









          There's a Chrome extension for this: Extension Automation. I had gone the route of modifying manifests before, but this is easier.






          share|improve this answer












          There's a Chrome extension for this: Extension Automation. I had gone the route of modifying manifests before, but this is easier.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Jul 7 '16 at 16:16









          Joe Fusion

          414




          414












          • It's 404 Not Found.
            – Balasubramani M
            Oct 28 at 5:17


















          • It's 404 Not Found.
            – Balasubramani M
            Oct 28 at 5:17
















          It's 404 Not Found.
          – Balasubramani M
          Oct 28 at 5:17




          It's 404 Not Found.
          – Balasubramani M
          Oct 28 at 5:17










          up vote
          0
          down vote













          As a user, with Chrome 71 (or maybe even before) with chrome://flags/#extension-active-script-permission (you may need to enable User consent for extension scripts flag) allows you to right click extension icons and select "This can read and change site data" then you can choose:




          • When you click the extension

          • On current-domain-name.com

          • On all sites (default)


          enter image description here



          This way you can limit an extension to only run on certain domains very quickly.






          share|improve this answer























          • Limit as a user, or as a developer?
            – Xan
            Nov 15 at 11:27










          • @Xan You're right the question isn't very clear either, so I added "as a user".
            – Wernight
            Nov 19 at 13:56










          • I believe that from the context: 1) It's a question on StackOverflow (and not, say, Super User), 2) The original author self-responded with "how to do it through an extension manifest", the intent here is a developer question. Which makes it important to at least note that developers have no control over this mechanism. Though it's not fully off-topic as developers need to be aware of this, and may need to inform the users of this.
            – Xan
            Nov 19 at 14:02















          up vote
          0
          down vote













          As a user, with Chrome 71 (or maybe even before) with chrome://flags/#extension-active-script-permission (you may need to enable User consent for extension scripts flag) allows you to right click extension icons and select "This can read and change site data" then you can choose:




          • When you click the extension

          • On current-domain-name.com

          • On all sites (default)


          enter image description here



          This way you can limit an extension to only run on certain domains very quickly.






          share|improve this answer























          • Limit as a user, or as a developer?
            – Xan
            Nov 15 at 11:27










          • @Xan You're right the question isn't very clear either, so I added "as a user".
            – Wernight
            Nov 19 at 13:56










          • I believe that from the context: 1) It's a question on StackOverflow (and not, say, Super User), 2) The original author self-responded with "how to do it through an extension manifest", the intent here is a developer question. Which makes it important to at least note that developers have no control over this mechanism. Though it's not fully off-topic as developers need to be aware of this, and may need to inform the users of this.
            – Xan
            Nov 19 at 14:02













          up vote
          0
          down vote










          up vote
          0
          down vote









          As a user, with Chrome 71 (or maybe even before) with chrome://flags/#extension-active-script-permission (you may need to enable User consent for extension scripts flag) allows you to right click extension icons and select "This can read and change site data" then you can choose:




          • When you click the extension

          • On current-domain-name.com

          • On all sites (default)


          enter image description here



          This way you can limit an extension to only run on certain domains very quickly.






          share|improve this answer














          As a user, with Chrome 71 (or maybe even before) with chrome://flags/#extension-active-script-permission (you may need to enable User consent for extension scripts flag) allows you to right click extension icons and select "This can read and change site data" then you can choose:




          • When you click the extension

          • On current-domain-name.com

          • On all sites (default)


          enter image description here



          This way you can limit an extension to only run on certain domains very quickly.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Nov 19 at 13:54

























          answered Nov 15 at 8:47









          Wernight

          21.3k1696116




          21.3k1696116












          • Limit as a user, or as a developer?
            – Xan
            Nov 15 at 11:27










          • @Xan You're right the question isn't very clear either, so I added "as a user".
            – Wernight
            Nov 19 at 13:56










          • I believe that from the context: 1) It's a question on StackOverflow (and not, say, Super User), 2) The original author self-responded with "how to do it through an extension manifest", the intent here is a developer question. Which makes it important to at least note that developers have no control over this mechanism. Though it's not fully off-topic as developers need to be aware of this, and may need to inform the users of this.
            – Xan
            Nov 19 at 14:02


















          • Limit as a user, or as a developer?
            – Xan
            Nov 15 at 11:27










          • @Xan You're right the question isn't very clear either, so I added "as a user".
            – Wernight
            Nov 19 at 13:56










          • I believe that from the context: 1) It's a question on StackOverflow (and not, say, Super User), 2) The original author self-responded with "how to do it through an extension manifest", the intent here is a developer question. Which makes it important to at least note that developers have no control over this mechanism. Though it's not fully off-topic as developers need to be aware of this, and may need to inform the users of this.
            – Xan
            Nov 19 at 14:02
















          Limit as a user, or as a developer?
          – Xan
          Nov 15 at 11:27




          Limit as a user, or as a developer?
          – Xan
          Nov 15 at 11:27












          @Xan You're right the question isn't very clear either, so I added "as a user".
          – Wernight
          Nov 19 at 13:56




          @Xan You're right the question isn't very clear either, so I added "as a user".
          – Wernight
          Nov 19 at 13:56












          I believe that from the context: 1) It's a question on StackOverflow (and not, say, Super User), 2) The original author self-responded with "how to do it through an extension manifest", the intent here is a developer question. Which makes it important to at least note that developers have no control over this mechanism. Though it's not fully off-topic as developers need to be aware of this, and may need to inform the users of this.
          – Xan
          Nov 19 at 14:02




          I believe that from the context: 1) It's a question on StackOverflow (and not, say, Super User), 2) The original author self-responded with "how to do it through an extension manifest", the intent here is a developer question. Which makes it important to at least note that developers have no control over this mechanism. Though it's not fully off-topic as developers need to be aware of this, and may need to inform the users of this.
          – Xan
          Nov 19 at 14:02


















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.





          Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


          Please pay close attention to the following guidance:


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f10504239%2flimit-chrome-extension-to-certain-urls%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          "Incorrect syntax near the keyword 'ON'. (on update cascade, on delete cascade,)

          Alcedinidae

          Origin of the phrase “under your belt”?