简体   繁体   中英

Is there a way to add Pop-up Exceptions using the chrome API?

I'm developing an extension that includes a feature to launch the Omniture DigitalPulse Debugger from a context-menu link. The debugger can be launched from a fixed number of domains that are stored in the extension's settings.

Unfortunately, when users click the link on a domain without a Pop-Up Exception, the pop-up is blocked until they allow it and/or manually add an exception. Is it possible to automatically add exceptions when the extension is installed or updated?

Currently, the click handler launches the debugger using a "javascript:" URL. There may be a better way to do it, but it is the only way I've found to allow the pop-up to have access to the tab's context. Here is the code:

/**
 * loads DigitalPulse omniture debugger in a new window
 * @param {Object} info Click event info
 * @param {Object} tab Tab info
 */
omnitureDebugger: function (info, tab) {
    var script = 'window.open("", "dp_debugger", "width=600,height=600,location=0,menubar=0,status=1,toolbar=0,resizable=1,scrollbars=1").document.write("<script id=\'dbg\' src=\'http://www.digitalpulse.omniture.com/dp/debugger.js\'></"+"script>");'
    chrome.tabs.update(tab.id, { url: "javascript:" + script });
}

You can use use chrome.contentSettings.popups API to add an exception. This API is available in Chrome 16 or later (currently in the beta channel).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM