{"id":43841,"date":"2024-06-24T15:53:45","date_gmt":"2024-06-24T19:53:45","guid":{"rendered":"https:\/\/mjtsai.com\/blog\/?p=43841"},"modified":"2024-06-24T15:53:45","modified_gmt":"2024-06-24T19:53:45","slug":"always-allow-safari-bookmarklets","status":"publish","type":"post","link":"https:\/\/mjtsai.com\/blog\/2024\/06\/24\/always-allow-safari-bookmarklets\/","title":{"rendered":"Always Allow Safari Bookmarklets"},"content":{"rendered":"<p><a href=\"https:\/\/lapcatsoftware.com\/articles\/2023\/10\/6.html\">Jeff Johnson<\/a>:<\/p>\n<blockquote cite=\"https:\/\/lapcatsoftware.com\/articles\/2023\/10\/6.html\"><p>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[&#8230;]<\/p><p>[&#8230;]<\/p><p>The permission prompt now has an option to &ldquo;Always Allow&rdquo;! This option is new in Safari 17.<\/p><\/blockquote>\n<p>This is an improvement, but even with <strong>Always Allow<\/strong> it <a href=\"https:\/\/mastodon.social\/@mjtsai\/112657277557517096\">only remembers per-domain<\/a>. So I&rsquo;m still prompted a lot when using <a href=\"https:\/\/redsweater.com\/blog\/289\/an-even-better-bookmarklet\">MarsEdit<\/a> and <a href=\"https:\/\/c-command.com\/eaglefiler\/bookmarklets\">EagleFiler<\/a> bookmarklets. And it messes up my muscle memory because I had been in the habit of always pressing Enter after invoking a bookmarklet to <strong>Allow<\/strong> it&mdash;Can you see from the slightly bold text in this iOS-style alert that <strong>Allow<\/strong> is the default button?&mdash;but with <strong>Always Allow<\/strong> it&rsquo;s unpredictable. I have to either pause to see whether I need to press Enter or I end up with an extra blank line in my blog post draft.<\/p>\n<blockquote cite=\"https:\/\/lapcatsoftware.com\/articles\/2023\/10\/6.html\">\n<p>You might wonder where this new preference is stored on disk. As far as I can tell, there&rsquo;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?<\/p>\n<p>[&#8230;]<\/p>\n<p>The good news is that with a little reverse engineering, I found a way to undo the preference. It&rsquo;s stored on disk in the file <code>~\/Library\/Safari\/PerSitePreferences.db<\/code>, which is an <a href=\"https:\/\/www.sqlite.org\/index.html\">SQLite<\/a> database.<\/p>\n<\/blockquote>\n\n<p><a href=\"https:\/\/lapcatsoftware.com\/articles\/2024\/6\/6.html\">Jeff Johnson<\/a> (<a href=\"https:\/\/mastodon.social\/@lapcatsoftware\/112660252523654561\">Mastodon<\/a>):<\/p>\n<blockquote cite=\"https:\/\/lapcatsoftware.com\/articles\/2024\/6\/6.html\"><p>To run bookmarklets in Safari on macOS, you need to enable &ldquo;Show features for web developers&rdquo; in Safari Advanced Settings and &ldquo;Allow JavaScript from Smart Search field&rdquo; in Safari Developer Settings.<\/p><\/blockquote>\n<p>I think this is only necessary for testing them. I have this unchecked, and my previously created bookmarklets still work.<\/p>\n<blockquote cite=\"https:\/\/lapcatsoftware.com\/articles\/2024\/6\/6.html\">\n<p>The permission is per-website, which means that every time you use the EagleFiler bookmarklet on a different website, Safari requests your permission <em>again<\/em>!<\/p><\/blockquote>\n<p>But he has a workaround:<\/p>\n<blockquote cite=\"https:\/\/lapcatsoftware.com\/articles\/2024\/6\/6.html\">\n<p>This JavaScript first calls <a href=\"https:\/\/developer.mozilla.org\/docs\/Web\/API\/Window\/open\">window.open()<\/a>, which creates a new <code>about:blank<\/code> tab. It then creates an <a href=\"https:\/\/developer.mozilla.org\/docs\/Web\/HTML\/Element\/a\">HTML anchor<\/a> element&mdash;in other words, a hyperlink&mdash;adds the link to the <code>about:blank<\/code> document, and clicks the link automatically.<\/p>\n<p>[&#8230;]<\/p>\n<p>This time the value of the domain is empty (<code>''<\/code>), because <code>about:blank<\/code> has no domain. The <code>about:blank<\/code> trick allows you to use the same bookmarklet on every website without any additional permission prompts!<\/p><\/blockquote>\n<p>This kind of exposes the permission prompt as security theater, but if it&rsquo;s not protecting us anyway we may as well get rid of the annoyance.<\/p>\n\n<p>Previously:<\/p>\n<ul>\n<li><a href=\"https:\/\/mjtsai.com\/blog\/2024\/04\/10\/universal-macappstore-links\/\">Universal macappstore: Links<\/a><\/li>\n<li><a href=\"https:\/\/mjtsai.com\/blog\/2023\/02\/28\/url-confirmations-in-preview\/\">URL Confirmations in Preview<\/a><\/li>\n<li><a href=\"https:\/\/mjtsai.com\/blog\/2023\/11\/13\/a-picture-is-worth-a-thousand-permissions-requests\/\">A Picture Is Worth a Thousand Permissions Requests<\/a><\/li>\n<li><a href=\"https:\/\/mjtsai.com\/blog\/2016\/12\/15\/macos-10-12-2-impedes-safari-bookmarklets\/\">macOS 10.12.2 Impedes Safari Bookmarklets<\/a><\/li>\n<\/ul>","protected":false},"excerpt":{"rendered":"<p>Jeff Johnson: 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[&#8230;][&#8230;]The permission prompt now has an option to &ldquo;Always Allow&rdquo;! This option is new in Safari 17. This [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"apple_news_api_created_at":"2024-06-24T19:53:48Z","apple_news_api_id":"a4bc07af-8702-43ef-8c6a-6775dc06f372","apple_news_api_modified_at":"2024-06-24T19:53:48Z","apple_news_api_revision":"AAAAAAAAAAD\/\/\/\/\/\/\/\/\/\/w==","apple_news_api_share_url":"https:\/\/apple.news\/ApLwHr4cCQ--Mamd13Abzcg","apple_news_coverimage":0,"apple_news_coverimage_caption":"","apple_news_is_hidden":false,"apple_news_is_paid":false,"apple_news_is_preview":false,"apple_news_is_sponsored":false,"apple_news_maturity_rating":"","apple_news_metadata":"\"\"","apple_news_pullquote":"","apple_news_pullquote_position":"","apple_news_slug":"","apple_news_sections":"\"\"","apple_news_suppress_video_url":false,"apple_news_use_image_component":false,"footnotes":""},"categories":[2],"tags":[627,595,346,30,2385,207,103],"class_list":["post-43841","post","type-post","status-publish","format-standard","hentry","category-technology","tag-bookmarks","tag-eaglefiler","tag-javascript","tag-mac","tag-macos-14-sonoma","tag-marsedit","tag-safari"],"apple_news_notices":[],"_links":{"self":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/43841","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/comments?post=43841"}],"version-history":[{"count":1,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/43841\/revisions"}],"predecessor-version":[{"id":43842,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/43841\/revisions\/43842"}],"wp:attachment":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/media?parent=43841"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/categories?post=43841"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/tags?post=43841"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}