$ show danielbuechele/goofy
Goofy is a native macOS desktop application that provides a dedicated interface for Facebook Messenger by embedding a web view of facebook.com/messages and enhancing it with native features. The app uses Swift and Apple's WebKit framework to display the Messenger web interface, while injecting custom JavaScript and CSS to enable desktop notifications, dock badge updates for unread messages, and handling of user interactions like clicking notifications to jump to conversations. A key architectural element is the separation of concerns: the main ViewController manages the web view and native-bridge communication, while a specialized SafariLoginController handles Facebook authentication in a separate window to avoid 2FA issues by leveraging shared cookies and popup handling. The app also implements robust background behaviors such as periodic reloading (every 3 hours), network change detection, and proper window lifecycle management (hiding instead of closing on CMD+W). Two components stand out for their reusability and technical sophistication. First, the SafariLoginController (SafariLoginController.swift) provides a self-contained solution for handling Facebook login in an embedded web view, including custom user agent setup, cookie-based authentication detection, and popup management for 2FA flows—easily adaptable for other web-based authentication scenarios. Second, the observe function in content.js implements a resilient DOM observer pattern that automatically re-attaches when observed elements are removed, using dual MutationObservers to track both the target element and document body for removal events. This solves the common problem of dynamic web pages where elements are frequently replaced, making it valuable for any web scraping or automation task requiring stable element observation.
The LLM identified 2 files worth highlighting for reuse:
Manages Facebook login in a dedicated web view window to avoid 2FA issues, checks for authentication cookies, and handles popups. This self-contained component can be extracted for any app requiring Facebook login via an embedded web view.
Implements a robust DOM observer pattern that automatically re-attaches when the observed element is removed, used for tracking new messages and badge updates in the Facebook Messenger web interface. This solves the common problem of dynamic web pages where elements are frequently replaced.