mirror of
https://github.com/undeaDD/FakeWebKit.git
synced 2026-03-11 19:00:22 +01:00
add license and readme
This commit is contained in:
21
LICENSE.md
Normal file
21
LICENSE.md
Normal file
@@ -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.
|
||||||
64
README.md
Normal file
64
README.md
Normal file
@@ -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.
|
||||||
Reference in New Issue
Block a user