
- #Swift share extension open app update#
- #Swift share extension open app code#
- #Swift share extension open app download#
How did I find which elements need to be hidden? If you don't have the Develop menu on your Mac Safari top action bar, go to Safari > Preferences > Advanced > Show Develop menu in menu bar and enable it. For most cases, you would want to use window.onload or the DOMContentLoaded event, but the Reddit pop-ups load after those events, so I needed the interval.
#Swift share extension open app code#
I replaced this code with simple JS to use document.querySelector to find the elements we need to delete and delete them, and run that function on an interval.

I also didn't need that, so I deleted it. When you open the content.js file, you'll see a message system set up. This is a simple extension which doesn't need any background processes, so I commented out the JS in background.js and removed its declaration from the manifest file. All of this follows the same standards as Chrome extension development, which is pretty nice because it means there's lots of information online about the manifest fields and extension development.įor my extension, I needed to add a script to modify the page HTML. It also includes a manifest.json which tells Safari about your extension - which files are used for what, which permissions your extension needs, etc. This folder also has a Resources folder with all of the HTML/CSS/JS for a basic extension. This project template is designed for web developers! So, the main app has all of the Swift needed for a simple extension already written, and it has a Resources folder with an HTML file, Main.html, for designing the app interface.įor now, we'll focus on the Extension folder. You'll notice two main folders in your project, which represent two targets - the main app, and the Safari Extension. In the template selection menu, search for "safari" and choose Safari Extension App.Ĭhoose a name for your extension, I made mine Viewwit, and hit Next.
#Swift share extension open app download#
You'll need macOS Monterey, which is available in a public beta, and the newest version of Xcode, which you can download from the Mac App Store. So we'll create an extension to block these intrusive popups! It's a pretty dark design pattern designed to move people to the app, for seemingly no benefit to the user. Some people don't like using the app at all. If I found a Reddit thread or subreddit through a Google search, I probably don't want to open the app. Sometimes you can "Continue in Safari" but other times, the prompts are completely blocking, like this:

One annoyance I hit a lot when I'm browsing on my iPhone is the Reddit "Open in App" prompts. In this article, I'll take you through the process of building one of these extensions! If you're just interested in checking out the extension, here is the code, and here it is on the App Store.
#Swift share extension open app update#
This update lets us build full-fledged extensions for iOS users, including JS/CSS injection, full user-interfaces written in web languages, and more. IOS 15 revamps the extension system built into iOS and iPad OS.
