Note that there are some explanatory texts on larger screens.

plurals
  1. POMultiple whitelists/blacklists for content script injection?
    text
    copied!<p>I'm building a Safari extension with two different content scripts. One script needs to be injected into all http pages (but not https pages). The other one only gets injected into google.com pages regardless of scheme.</p> <p>In order to achieve this, I have set <code>Extension Website Access</code> to:</p> <p><img src="https://i.stack.imgur.com/G4vGS.png" alt="Extension Website Access"></p> <p>This should mean that at a high level, content scripts in my extension should be able to access all pages.</p> <p>To get more fine-grained control, I then programatically inject the content scripts into URLs which match my patterns.</p> <pre><code>App = { content: { // Inject into unsecure pages. whitelist: ['http://*/*'], // But not into secure pages. blackList: ['https://*/*'], loc: safari.extension.baseURI + 'data/content.js' }, results: { // Inject this script into all google.com pages whiteList: ['http://*.google.com/*', 'https://*.google.com/*'], // Surely I don't need a blacklist if I specify a whitelist? blacklist: undefined, loc: safari.extension.baseURI + 'data/results.js', } }; // Inject the first content script. safari.extension.addContentScriptFromURL(App.content.loc, App.content.whitelist, App.content.blacklist, false); // Inject the second content script. safari.extension.addContentStyleSheetFromURL(App.results.cssLoc, App.results.whitelist, App.results.blacklist, false); </code></pre> <p>The problem is that both scripts are being injected into all pages. It's as if my white and blacklists do nothing. What am I doing wrong?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload