|  | @@ -165,6 +165,12 @@ static NSDictionary* customCertificatesForHost;
 | 
	
		
			
			| 165 | 165 |  
 | 
	
		
			
			| 166 | 166 |        WKUserScript *script = [[WKUserScript alloc] initWithSource:source injectionTime:WKUserScriptInjectionTimeAtDocumentStart forMainFrameOnly:YES];
 | 
	
		
			
			| 167 | 167 |        [wkWebViewConfig.userContentController addUserScript:script];
 | 
	
		
			
			|  | 168 | +        
 | 
	
		
			
			|  | 169 | +      if (_injectedJavaScriptBeforeContentLoaded) {
 | 
	
		
			
			|  | 170 | +        // If user has provided an injectedJavascript prop, execute it at the start of the document
 | 
	
		
			
			|  | 171 | +        WKUserScript *injectedScript = [[WKUserScript alloc] initWithSource:_injectedJavaScriptBeforeContentLoaded injectionTime:WKUserScriptInjectionTimeAtDocumentStart forMainFrameOnly:YES];
 | 
	
		
			
			|  | 172 | +        [wkWebViewConfig.userContentController addUserScript:injectedScript];
 | 
	
		
			
			|  | 173 | +      }
 | 
	
		
			
			| 168 | 174 |      }
 | 
	
		
			
			| 169 | 175 |  
 | 
	
		
			
			| 170 | 176 |      wkWebViewConfig.allowsInlineMediaPlayback = _allowsInlineMediaPlayback;
 | 
	
	
		
			
			|  | @@ -949,19 +955,19 @@ static NSDictionary* customCertificatesForHost;
 | 
	
		
			
			| 949 | 955 |   * Called when the navigation is complete.
 | 
	
		
			
			| 950 | 956 |   * @see https://fburl.com/rtys6jlb
 | 
	
		
			
			| 951 | 957 |   */
 | 
	
		
			
			| 952 |  | -- (void)      webView:(WKWebView *)webView
 | 
	
		
			
			|  | 958 | +- (void)webView:(WKWebView *)webView
 | 
	
		
			
			| 953 | 959 |    didFinishNavigation:(WKNavigation *)navigation
 | 
	
		
			
			| 954 | 960 |  {
 | 
	
		
			
			| 955 |  | -  if (_injectedJavaScript) {
 | 
	
		
			
			| 956 |  | -    [self evaluateJS: _injectedJavaScript thenCall: ^(NSString *jsEvaluationValue) {
 | 
	
		
			
			| 957 |  | -      NSMutableDictionary *event = [self baseEvent];
 | 
	
		
			
			| 958 |  | -      event[@"jsEvaluationValue"] = jsEvaluationValue;
 | 
	
		
			
			| 959 |  | -
 | 
	
		
			
			| 960 |  | -      if (self.onLoadingFinish) {
 | 
	
		
			
			| 961 |  | -        self.onLoadingFinish(event);
 | 
	
		
			
			| 962 |  | -      }
 | 
	
		
			
			| 963 |  | -    }];
 | 
	
		
			
			| 964 |  | -  } else if (_onLoadingFinish) {
 | 
	
		
			
			|  | 961 | +   if (_injectedJavaScript) {
 | 
	
		
			
			|  | 962 | +     [self evaluateJS: _injectedJavaScript thenCall: ^(NSString *jsEvaluationValue) {
 | 
	
		
			
			|  | 963 | +       NSMutableDictionary *event = [self baseEvent];
 | 
	
		
			
			|  | 964 | +       event[@"jsEvaluationValue"] = jsEvaluationValue;
 | 
	
		
			
			|  | 965 | +
 | 
	
		
			
			|  | 966 | +       if (self.onLoadingFinish) {
 | 
	
		
			
			|  | 967 | +         self.onLoadingFinish(event);
 | 
	
		
			
			|  | 968 | +       }
 | 
	
		
			
			|  | 969 | +     }];
 | 
	
		
			
			|  | 970 | +   } else if (_onLoadingFinish) {
 | 
	
		
			
			| 965 | 971 |      _onLoadingFinish([self baseEvent]);
 | 
	
		
			
			| 966 | 972 |    }
 | 
	
		
			
			| 967 | 973 |  }
 |