Safari 17 hidden feature: Always allow this website to open an app
17hidden feature: Always allow this website to open an app
October 20 2023
Safari 17has a new hidden feature that I wasn’t even aware of until a customer brought it to my attention. I haven’t seen it mentioned anywhere by Apple in their release notes. You may already be aware that for a number of years , Safari has asked your permission every time you click on a link, such as an RSS feed, that opens in an app other than Safari :
(Remember when Safarihad RSS support? The good old days !)
Of course Applewouldn’t be Apple if they didn’t give themselves special exemptions, and in this case, certain Apple apps are exempt from requiring your permission to open. One example is an app that should not be exempt: App Store ! Whether you like it or not, the App Store app automatically opens whenever you visit a Mac App Store page in Safari .
That’s why I wrote the free, open source app Stop The Mac App Store. This app turned the tables on Safari , using its own permission system against it. Stop The Mac App Store registers itself as the default handler of App Store URLs, which means that when you visit a Mac App Store page, Safari attempts to open Stop The Mac App Store rather than App Store . But my app does not have a special Apple exemption, so you get the standard permission prompt:
Then you can just press the escape key to cancel and avoid opening the App Storeapp.
If you want to try yourself, the URL in the screenshot is https://apps.apple.com/app/link-unshortener/id1506953658?mt=12, the Mac App Storepage for my app Link Unshortener (which you should buy, thank you).
You might notice, from the darkness of the Safariaddress bar, that the above screenshot is of a private window in Safari . I like to do the majority of my web browsing in private windows, and that’s why I never noticed the new Safari 17 feature. I’ll try again with the same page, but this time in a non-private window:
The permission prompt now has an option to "Always Allow"! This option is new in Safari17.
The irony is that after you select Always Allow, that preference applies to private windows as well as to non-private windows, even though the option does not appear in private windows. Appleworks in mysterious ways…
You might wonder where this new preference is stored on disk. As far as I can tell, there’s no corresponding user interface in Safari Settings, certainly not in the Websites pane. What if you want to undo your selection? What if you select Always Allow by accident? This would be disastrous when using Stop The Mac App Store , because then you would never again have the option to prevent the App Store app from automatically opening.
The good news is that with a little reverse engineering, I found a way to undo the preference. It’s stored on disk in the file ~/Library/Safari/PerSitePreferences.db , which is an SQLite database. You can run SQLite commands in Terminalapp, though you’ll need to grant Full Disk Access to Terminal in the Privacy & Security section of System Settings in order to access the PerSitePreferences.db file. Here’s the Terminal command to view the contents of the file:
sqlite3 ~/Library/Safari/PerSitePreferences.db .dump
Make sure to quit Safaribefore running any operations on its SQLite databases. Here’s the command to remove the Always Allow permission from Stop The Mac App Store :
sqlite3 ~/Library/Safari/PerSitePreferences.db "delete from preference_values where preference=’PerSitePreferencesOpenApplications’ and preference_value=’macappstores‘;"
As you can see, the technical name of the preference is PerSitePreferencesOpenApplications , and here’s how the preference_values table is defined in SQLite, which can be seen using the .dump command above:
CREATE TABLE preference_values (id INTEGER PRIMARY KEY AUTOINCREMENT, domain TEXT NOT NULL, preference TEXT NOT NULL, preference_value NUMERIC, timestamp TEXT, sync_data BLOB, record_name TEXT, UNIQUE(domain, preference));
(It looks like Applescrewed up here a little, because the preference_value is clearly not numeric?)
So there you have it. With Safari 17, Apple has made the Mac slightly less like Windows Vista . Cancel, Allow, or Always Allow .
This new Safarifeature may obsolete my other free, open source app StartTheZoom.