问题
WKUserScript has this init
init(source: String, injectionTime: WKUserScriptInjectionTime, forMainFrameOnly: Bool
)
Simply what is meant by 'MainFrame' ?
回答1:
WebView is the core view class in the WebKit framework that manages interactions between the WebFrame and WebFrameView classes.WebFrame objects encapsulate the content contained in a single frame element.
A hierarchy of WebFrame objects is used to model an entire webpage where the root is called the main frame.
There is a WebFrameView object per WebFrame object used to display the frame content. Therefore, there is a parallel hierarchy of WebFrameView objects used to render an entire page. The WebView object is also the parent view of this hierarchy. You do not need to create WebFrame and WebFrameView objects directly. These objects are automatically created when the page loads, either programmatically or by the user clicking a link.
Note
In apps that run in OS X 10.10 and later, use the WKWebView class instead of using WebView.
来源:https://stackoverflow.com/questions/49850682/wkuserscript-formainframeonly