2015-04-05 16 views
1

我一直花費數個小時的時間試圖弄清楚爲什麼我的Chrome擴展程序無法正常工作,因爲它應該只能發現Google Chrome網上商店顯然不允許擴展程序在打開時執行某些操作。是否有解決方案允許在chrome網絡商店中打開時執行內容/後臺腳本?

我讀過這個線程因此,雖然它現在是2歲張貼的解決方案並沒有爲我工作:Chrome Extension Content Script on https://chrome.google.com/webstore/

我在OS X上運行的優勝美地Chrome版本41.0.2272.118 (64-bit)。 作爲建議的迴應之一,我運行了命令open /Applications/Google\ Chrome.app --args --allow-scripting-gallery;,但我的擴展的內容腳本仍然不會在webstore中運行。我所要做的就是使用chrome.runtime.sendMessagechrome.runtime.onMessage在內容腳本和後臺腳本之間進行通信。

Google是否決定徹底刪除這些功能,或者現在是否有新的命令?

回答

2

是的,他們已經刪除它。我猜它被濫用了。

您可以諮詢當前支持的旗幟上chrome://flags

或者列表中,有一個列表,直接從源中提取出來,在http://peter.sh/experiments/chromium-command-line-switches/

附:對於更多的證據,這是同樣的源文件的newer version

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; 
} 

正如你可以看到,任何一種基於交換機的邏輯不再存在; CWS URL只是被認爲是不可編寫的。

+0

此限制是否適用於webRequest API?我試圖使用'onBeforeRequest'函數重定向用戶;據我所知,這是在TCP連接完成之前觸發的;那麼Chrome怎麼會阻止我的腳本呢? – Grandclosing 2015-04-05 23:54:48

相關問題