Questions tagged [wkuserscript]

Used when a user script is to be injected into a webpage.

Used when a user script is to be injected into a webpage.

10 questions
6
votes
2 answers

WKUserScript not working

I want to inject a script using WKWebview API. For some reason it isn't working and I can't figure it out. I've tried debugging in Safari developer console and I can't find the JavaScript code in there either. Implementation Code as…
Avner Barr
  • 13,049
  • 14
  • 82
  • 152
2
votes
0 answers

javascript injection not being executed

I have included my function and the way im calling it it does print "injecting" in console but the javascript dosent seem to be injected i have tested the js in safari console and chrome console it works but dosent work in the wkwebview…
kishan
  • 47
  • 8
1
vote
0 answers

How to evaluateJavaScript when app goes to background WKWebView?

I am create html page with HTML5 IMA SDK player and then load this page to WKWebView, all work fine pause, playing content etc, but I want "pause" content when app goes to background for achieve this I did tried used "WKWebView evaluateJavaScript"…
1
vote
2 answers

Refresh an external webpage every few seconds

For work, I spend a lot of time on domain-specific forums. Throughout the day, I check those forums to see if there are any questions and answers relevant to what I am working on. However, the particular site I am using does not automatically…
0
votes
0 answers

Can't load Javascript into WKWebView reason: 'data parameter is nil'

I've objective-C codes like this: #import "QHArticle.h" #import -(instancetype)init { self = [super init]; if (self) { _helperWebView = [[WKWebView alloc] init]; NSString *path = [[NSBundle mainBundle]…
wdyz
  • 155
  • 3
  • 18
0
votes
0 answers

WKWebView “goback” function does not execute refresh and javascript code

I have a ViewController that is embedded in a NavigationController and this ViewController adds WKWebView as a subview. The problem is that after navigating to any web page; if I call the function "goback", the previous page will be present and…
0
votes
1 answer

Removing a single specific user script from WKUserContentController

I'm using addUserScript() to add a user script to my WKWebView's WKUserContentController. I noticed that even if call loadRequest() the script stays around. For certain use cases I may need to remove certain scripts and add others. However, it…
Locksleyu
  • 4,822
  • 6
  • 46
  • 68
0
votes
1 answer

WKUserScript forMainFrameOnly

WKUserScript has this init init(source: String, injectionTime: WKUserScriptInjectionTime, forMainFrameOnly: Bool) Simply what is meant by 'MainFrame' ?
RyanTCB
  • 5,944
  • 3
  • 36
  • 55
0
votes
1 answer

WKUserScript not call in iOS10, but works in iOS9

I'm having code which perfectly works in iOS 9, but not working in iOS 10, specifically doBar() not called. Here in WKWebView I'm injecting javascript code. let jsFoo = "function doFoo() { window.webkit.messageHandlers.doFoo.postMessage(\"doFoo\");…
Jurasic
  • 1,476
  • 1
  • 14
  • 26
-1
votes
1 answer

WKUserScript init Crash on iOS 14: Use of unimplemented initializer init(source:injectionTime:forMainFrameOnly:in:)

Crash while executing this init method in ios 14 Use of unimplemented initializer init(source:injectionTime:forMainFrameOnly:in:) class MyScript: WKUserScript { init(source: String) { super.init(source: source, injectionTime:…