From 2af2592b8e48fcd94146a127bd994f19782639d7 Mon Sep 17 00:00:00 2001 From: Dominic Drees Date: Sat, 1 Nov 2025 15:37:37 +0100 Subject: [PATCH] add license and readme --- LICENSE.md | 21 ++++++++++++++++++ README.md | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 85 insertions(+) create mode 100644 LICENSE.md create mode 100644 README.md diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000..a0311a6 --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2025 DevsForge ( undeaDD ) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..77d57a2 --- /dev/null +++ b/README.md @@ -0,0 +1,64 @@ +# FakeWebKit +A lightweight ( 520 lines of code ) drop-in WebKit wrapper for tvOS, supporting user scripts, JS message handlers, and cookies — no WebKit dependency. + +> **Notice:** `FakeWebView` uses `UIWebView` internally, which is a private API on tvOS. Use with caution as it may be rejected by App Store review. + +## Features +- Drop-in replacement for WKWebView on tvOS +- User scripts injection (atDocumentStart / atDocumentEnd) +- JavaScript message handlers via window.webkit.messageHandlers +- Cookie management via WKCookieStore +- Supports custom user agent and basic navigation delegate callbacks +- ... + +## Installation + +Add the package via Swift Package Manager: + +> In Xcode: File > Swift Packages > Add Package Dependency + +https://github.com/undeadd/FakeWebKit.git + +Usage +> Use it just like the normal WKWwebView from Webkit: + +```swift + +#if os(tvOS) + import FakeWebKit +#else + import WebKit +#endif + +// Add a JS message handler +let configuration = WKWebViewConfiguration() +configuration.userContentController.add(MyMessageHandler(), name: "scriptTest") + +// Create the WKWebView +let webView = WKWebView(frame: .zero, configuration: configuration) + +// Inject a user script +let testScript = WKUserScript( + source: """ + (function() { + if (window.webkit?.messageHandlers?.scriptTest?.postMessage) { + window.webkit.messageHandlers.scriptTest.postMessage("Hello from JS"); + } + })(); + """, + injectionTime: .atDocumentEnd, + forMainFrameOnly: true +) +configuration.userContentController.addUserScript(testScript) + +// Load a URL +webView.load(URLRequest(url: URL(string: "https://example.com")!)) +``` + +## Contributing + +Contributions are welcome! Open an issue or PR for bug fixes, improvements, or new features. + +## License + +MIT License.