Is there a work-around for allowing content/background scripts to execute while open in the chrome web store?

不问归期 提交于 2021-02-19 08:13:05

问题


I've been spending several long hours trying to figure out why my Chrome extension wasn't working as it should only to find that apparently the Google Chrome webstore does not allow extensions to do certain things while it's open.

I've read this thread on SO, though it's 2 years old now and the solutions posted did not work for me: Chrome Extension Content Script on https://chrome.google.com/webstore/

I'm running Chrome version 41.0.2272.118 (64-bit) on OS X Yosemite. As one of the responses suggested, I've run the command open /Applications/Google\ Chrome.app --args --allow-scripting-gallery; but my extension's content script will not run in the webstore still. All I'm trying to do is communicate between the content script and background script using chrome.runtime.sendMessage and chrome.runtime.onMessage.

Has Google decided to completely remove those capabilities or is there a new command now?


回答1:


Yes, they have removed it. I guess it was abused.

You can consult the list of currently supported flags on chrome://flags

Alternatively, there is a list, pulled directly from source, at http://peter.sh/experiments/chromium-command-line-switches/

P.S. For more proof, here's a newer version of the same source file:

bool ChromeExtensionsClient::IsScriptableURL(
    const GURL& url, std::string* error) const {
  // 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;
  }
  return true;
}

As you can see, any kind of switch-based logic is no longer there; the CWS URLs are just always considered non-scriptable.



来源:https://stackoverflow.com/questions/29462932/is-there-a-work-around-for-allowing-content-background-scripts-to-execute-while

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!