Friday, August 19, 2022
HomeiOS Developmentjavascript - How can I conceal component by class in wkwebview in...

javascript – How can I conceal component by class in wkwebview in swift ios?

I’ve to cover component utilizing javascript in swift. During which file i would like do do adjustments??
I’ve tried a number of choices however nothing labored till now. I need to conceal google sign-in choice on internet view.

Code for reference

import UIKit
import WebKit
import JavaScriptCore

class ViewController: UIViewController,WKNavigationDelegate,WKUIDelegate, UIScrollViewDelegate{
     var webView: WKWebView!
    override func viewDidLoad() {
//        load distant url
        //let url = URL(string: "")!
        //webView.load(URLRequest(url: url))
        webView.allowsBackForwardNavigationGestures = true
        self.webView.uiDelegate = self
        webView.load(URLRequest.init(url: URL.init(string: "")!))
        webView.evaluateJavaScript("doc.getElementByClassName("webview-d-none")'none';", completionHandler: { (res, error) -> Void in
                //Right here you may verify for outcomes if wanted (res) or whether or not the execution was profitable (error)
//        load native html file
//        let url = Bundle.predominant.url(forResource: "instance", withExtension: "html", subdirectory: "local_html")!
//        webView.loadFileURL(url, allowingReadAccessTo: url)
//        let request = URLRequest(url: url)
//        webView.load(request)
    override func loadView() {
        webView = WKWebView()
        webView.navigationDelegate = self
        view = webView
        /*let tscript = " doc.getElementsByClassName('webview-d-none')[0] = 'none';"
       // let jsString = "var script = doc.getElementsByClassName('webview-d-none')[0].type.visibility = 'hidden';"
        //    webView.evaluateJavaScript(jsString)
       // webView.evaluateJavaScript("doc.getElementsByClassName('webview-d-none')[0].type.visibility = 'hidden';")
  override func didReceiveMemoryWarning() {
        // Eliminate any assets that may be recreated.



Please enter your comment!
Please enter your name here

Most Popular

Recent Comments