mirror of
https://github.com/Ranchero-Software/NetNewsWire.git
synced 2025-01-10 17:02:54 +01:00
Add isJavascriptEnabled
setting, defaulting to false, and respect it in the web view.
This commit is contained in:
parent
c05ef2344f
commit
dfd778d038
@ -41,6 +41,7 @@ final class AppDefaults {
|
|||||||
static let exportOPMLAccountID = "exportOPMLAccountID"
|
static let exportOPMLAccountID = "exportOPMLAccountID"
|
||||||
static let defaultBrowserID = "defaultBrowserID"
|
static let defaultBrowserID = "defaultBrowserID"
|
||||||
static let currentThemeName = "currentThemeName"
|
static let currentThemeName = "currentThemeName"
|
||||||
|
static let javascriptEnabled = "javascriptEnabled"
|
||||||
|
|
||||||
// Hidden prefs
|
// Hidden prefs
|
||||||
static let showDebugMenu = "ShowDebugMenu"
|
static let showDebugMenu = "ShowDebugMenu"
|
||||||
@ -299,6 +300,15 @@ final class AppDefaults {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var isJavascriptEnabled: Bool {
|
||||||
|
get {
|
||||||
|
UserDefaults.standard.bool(forKey: Key.javascriptEnabled)
|
||||||
|
}
|
||||||
|
set {
|
||||||
|
UserDefaults.standard.set(newValue, forKey: Key.javascriptEnabled)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func registerDefaults() {
|
func registerDefaults() {
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
let showDebugMenu = true
|
let showDebugMenu = true
|
||||||
@ -306,15 +316,18 @@ final class AppDefaults {
|
|||||||
let showDebugMenu = false
|
let showDebugMenu = false
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
let defaults: [String : Any] = [Key.sidebarFontSize: FontSize.medium.rawValue,
|
let defaults: [String : Any] = [
|
||||||
Key.timelineFontSize: FontSize.medium.rawValue,
|
Key.sidebarFontSize: FontSize.medium.rawValue,
|
||||||
Key.detailFontSize: FontSize.medium.rawValue,
|
Key.timelineFontSize: FontSize.medium.rawValue,
|
||||||
Key.timelineSortDirection: ComparisonResult.orderedDescending.rawValue,
|
Key.detailFontSize: FontSize.medium.rawValue,
|
||||||
Key.timelineGroupByFeed: false,
|
Key.timelineSortDirection: ComparisonResult.orderedDescending.rawValue,
|
||||||
"NSScrollViewShouldScrollUnderTitlebar": false,
|
Key.timelineGroupByFeed: false,
|
||||||
Key.refreshInterval: RefreshInterval.everyHour.rawValue,
|
"NSScrollViewShouldScrollUnderTitlebar": false,
|
||||||
Key.showDebugMenu: showDebugMenu,
|
Key.refreshInterval: RefreshInterval.everyHour.rawValue,
|
||||||
Key.currentThemeName: Self.defaultThemeName]
|
Key.showDebugMenu: showDebugMenu,
|
||||||
|
Key.currentThemeName: Self.defaultThemeName,
|
||||||
|
Key.javascriptEnabled: false
|
||||||
|
]
|
||||||
|
|
||||||
UserDefaults.standard.register(defaults: defaults)
|
UserDefaults.standard.register(defaults: defaults)
|
||||||
|
|
||||||
|
@ -95,10 +95,9 @@ final class DetailWebViewController: NSViewController {
|
|||||||
preferences.minimumFontSize = 12.0
|
preferences.minimumFontSize = 12.0
|
||||||
preferences.javaScriptCanOpenWindowsAutomatically = false
|
preferences.javaScriptCanOpenWindowsAutomatically = false
|
||||||
|
|
||||||
|
|
||||||
let configuration = WKWebViewConfiguration()
|
let configuration = WKWebViewConfiguration()
|
||||||
configuration.preferences = preferences
|
configuration.preferences = preferences
|
||||||
configuration.defaultWebpagePreferences.allowsContentJavaScript = false
|
configuration.defaultWebpagePreferences.allowsContentJavaScript = AppDefaults.shared.isJavascriptEnabled
|
||||||
configuration.setURLSchemeHandler(detailIconSchemeHandler, forURLScheme: ArticleRenderer.imageIconScheme)
|
configuration.setURLSchemeHandler(detailIconSchemeHandler, forURLScheme: ArticleRenderer.imageIconScheme)
|
||||||
|
|
||||||
let userContentController = WKUserContentController()
|
let userContentController = WKUserContentController()
|
||||||
|
Loading…
Reference in New Issue
Block a user