27

Is Chrome blocking access to the webstore url?

I would like to make an extension that displays a like button beside the +1 button, but it looks like that content scripts are not working on https://chrome.google.com/webstore/*

Is that true?

0

1 Answer 1

37

TL;DR The webstore cannot be scripted by extensions, and the flag that previously allowed you to do that (--allow-scripting-gallery) has been removed in Chrome 35.

Chrome extensions cannot execute Content scripts / insert CSS the Chrome Web Store. This is explicitly defined in the source code, at function IsScriptableURL (click on the previous link to see the full logic).

  // The gallery is special-cased as a restricted URL for scripting to prevent
  // access to special JS bindings we expose to the gallery (and avoid things
  // like extensions removing the "report abuse" link).
  // TODO(erikkay): This seems like the wrong test.  Shouldn't we we testing
  // against the store app extent?
  GURL store_url(extension_urls::GetWebstoreLaunchURL());
  if (url.host() == store_url.host()) {
    if (error)
      *error = manifest_errors::kCannotScriptGallery;
    return false;
  }

manifest_errors::kCannotScriptGallery is defined here:

const char kCannotScriptGallery[] =
    "The extensions gallery cannot be scripted.";

The error can be viewed in the background page's console when you use chrome.tabs.executeScript to inject a script in a Web Store tab. For instance, open https://chrome.google.com/webstore/, then execute the following script in the background page of an extension (via the console, for live debugging):

chrome.tabs.query({url:'https://chrome.google.com/webstore/*'}, function(result) {
    if (result.length) chrome.tabs.executeScript(result[0].id, {code:'alert(0)'});
});
Sign up to request clarification or add additional context in comments.

7 Comments

Ok Content Scripts not working, is there maybe a way via Background Pages? Or is there no possible way to get this working (except via command line parameter)
This doesn't seem to be working any more (in Chrome 31). I submitted a bug - code.google.com/p/chromium/issues/detail?id=342090
@kzahel I have just fixed that bug. You should be able to use the --allow-scripting-gallery again (at least with Canary builds).
FYI CSS can not be inserted via the insertCSS function, however any CSS you have declared in your manifest will load - while your content_script does not. Booooo on Google
@sboy031 FYI, what you described was a bug, and it has already been fixed since Chrome 36.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.