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?
A content script is a part of your extension that runs in the context of a particular web page (as opposed to background scripts which are part of the extension, or scripts which are part of the website itself, such as those loaded using the <script> element).
To open up your extensions page, click the menu icon (three dots) at the top right of Chrome, point to “More Tools,” then click on “Extensions.” You can also type chrome://extensions/ into Chrome's Omnibox and press Enter.
Click the blue HTTPS Everywhere extension icon in the browser's toolbar. By default, HTTPS Everywhere is enabled. To disable the extension, uncheck Enable HTTPS Everywhere. If you want to completely block any unencrypted requests, check the Block all unencrypted requests box.
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)'}); });
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With