mirror of
https://github.com/Ranchero-Software/NetNewsWire.git
synced 2025-01-10 17:02:54 +01:00
Fix build errors in PreloadedWebView.
This commit is contained in:
parent
3de86ba877
commit
bb04233a33
@ -14,16 +14,6 @@ class PreloadedWebView: WKWebView {
|
|||||||
private var isReady: Bool = false
|
private var isReady: Bool = false
|
||||||
private var readyCompletion: (() -> Void)?
|
private var readyCompletion: (() -> Void)?
|
||||||
|
|
||||||
static let userScripts: [WKUserScript] = {
|
|
||||||
var scripts = [WKUserScript]()
|
|
||||||
for fileName in ["main.js", "main_ios.js", "newsfoot.js"] {
|
|
||||||
let scriptSource = try! String(contentsOf: baseURL.appending(path: fileName, directoryHint: .notDirectory))
|
|
||||||
let script = WKUserScript(source: scriptSource, injectionTime: .atDocumentStart, forMainFrameOnly: true, in: appScriptsWorld)
|
|
||||||
scripts.append(script)
|
|
||||||
}
|
|
||||||
return scripts
|
|
||||||
}()
|
|
||||||
|
|
||||||
init(articleIconSchemeHandler: ArticleIconSchemeHandler) {
|
init(articleIconSchemeHandler: ArticleIconSchemeHandler) {
|
||||||
let preferences = WKPreferences()
|
let preferences = WKPreferences()
|
||||||
preferences.javaScriptCanOpenWindowsAutomatically = false
|
preferences.javaScriptCanOpenWindowsAutomatically = false
|
||||||
@ -36,13 +26,6 @@ class PreloadedWebView: WKWebView {
|
|||||||
configuration.mediaTypesRequiringUserActionForPlayback = .audio
|
configuration.mediaTypesRequiringUserActionForPlayback = .audio
|
||||||
configuration.setURLSchemeHandler(articleIconSchemeHandler, forURLScheme: ArticleRenderer.imageIconScheme)
|
configuration.setURLSchemeHandler(articleIconSchemeHandler, forURLScheme: ArticleRenderer.imageIconScheme)
|
||||||
|
|
||||||
let userContentController = WKUserContentController()
|
|
||||||
let appScriptsWorld = WKContentWorld.world(name: "NetNewsWire")
|
|
||||||
for script in Self.userScripts {
|
|
||||||
userContentController.addUserScript(script)
|
|
||||||
}
|
|
||||||
configuration.userContentController = userContentController
|
|
||||||
|
|
||||||
super.init(frame: .zero, configuration: configuration)
|
super.init(frame: .zero, configuration: configuration)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -90,3 +73,4 @@ private extension PreloadedWebView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user