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() {
        tremendous.viewDidLoad()
//        load distant url
        //let url = URL(string: "https://www.true-elements.com/")!
        //webView.load(URLRequest(url: url))
        webView.allowsBackForwardNavigationGestures = true
        self.webView.uiDelegate = self
        webView.load(URLRequest.init(url: URL.init(string: "https://www.true-elements.com/")!))
        
        webView.evaluateJavaScript("doc.getElementByClassName("webview-d-none").type.show='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].type.show = 'none';"
        webView.evaluateJavaScript(tscript)*/
        
       // 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() {
        tremendous.didReceiveMemoryWarning()
        // Eliminate any assets that may be recreated.
    }
  }

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments