title: Safari Extension Questions
body: <p>I'm in the process of building my first Safari extension--a very simple one--but I've run into a couple of problems. The extension boils down to a single, injected script that attempts to bypass the native feed handler and redirect to an http:// URI. My issues so far are twofold:</p>
  
  <ol>
  <li>The "whitelist" isn't working the way I'd expect. Since all feeds are shown under the "feed://" protocol, I've tried to capture that in the whitelist as "feed://*/*" (with nothing in the blacklist), but I end up in a request loop that I can't understand. If I set <strong>blacklist</strong> values of "<a href="http://*/*" rel="nofollow noreferrer">http://*/*</a>" and "<a href="https://*/*" rel="nofollow noreferrer">https://*/*</a>", everything works as expected.</li>
  <li>I can't figure out how to access my settings from my injected script. The script creates a <code>beforeload</code> event handler, but can't access my settings using the <code>safari.extension.settings</code> path indicated in the documentation.</li>
  </ol>
  
  <p>I haven't found anything in Apple's documentation to indicate that settings shouldn't be available from my script. Since extensions are such a new feature, even Google returns limited relevant results and most of those are from the official documentation. </p>
  
  <p>What am I missing?</p>
  
  <p><strong>UPDATE</strong>
  So I'm hoping that the documentation is incomplete because it's borderline abysmal, but I've learned a bit about settings. It turns out that, from injection scripts, the <code>SafariExtensionSettings</code> object isn't available. Injection scripts only have access to the <code>SafariContentExtension</code> object (which isn't useful at all), but it's aliased in exactly the same manner (<code>safari.extension.settings</code>)--bad idea, IMO. As stated in the <a href="https://developer.apple.com/library/archive/documentation/Tools/Conceptual/SafariExtensionGuide/InjectingScripts/InjectingScripts.html" rel="nofollow noreferrer">injection script documentation</a>:</p>
  
  <blockquote>
    <p>Important: When you use safari.extension from within an injected script, you are not addressing the SafariExtension class. You are addressing the SafariContentExtension class.</p>
  </blockquote>
  
  <p>You have to use the messaging system to talk to a global HTML file which has access to the settings. It's kind of loopy, but I have a message being sent to a <code>global.html</code> file that retrieves the settings and will send a message back to my injection script as soon as I figure out how to go about doing that.</p>
  
  <p>Since I'm doing all of my work before the document loads, all of the methods I've found to send message <em>back</em> rely on a page object that I don't have.</p>