let config = WKWebViewConfiguration.init()
config.preferences = WKPreferences.init()
config.preferences.minimumFontSize = 10
config.preferences.javaScriptEnabled = true
config.preferences.javaScriptCanOpenWindowsAutomatically = false
config.processPool = WKProcesspool.shared
config.selectionGranularity = WKSelectionGranularity.character
config.allowsInlineMediaPlayback = true
let cookies = HTTPCookieStorage.shared.cookies!
var cookieStr = ""
for cookie in cookies {
print("\(cookie.name):\(cookie.value)")
//必须加上path否则会出现很多问题
cookieStr.append("document.cookie = '\(cookie.name)=\(cookie.value);path=/jxapp';")
}
let cookieScript = WKUserScript(source:cookieStr,
injectionTime:WKUserScriptInjectionTime.atDocumentStart,forMainFrameOnly:false)
let userContentController = WKUserContentController.init()
userContentController.addUserScript(cookieScript)
config.userContentController = userContentController