Android Question Add onclickListener to facebook video

amidgeha

Active Member
Licensed User
Longtime User
I want to download fb video from webview (https://m.facebook.com) by adding a OnClick to it. I have seen some code in Java :
B4X:
        webView.setWebViewClient(new WebViewClient() {

            public void onLoadResource(WebView webview, String s)
            {
                webView.loadUrl("javascript:(function prepareVideo() { var el = document.querySelectorAll('div[data-sigil]');for(var i=0;i<el.length; i++){var sigil = el[i].dataset.sigil;if(sigil.indexOf('inlineVideo') > -1){delete el[i].dataset.sigil;console.log(i);var jsonData = JSON.parse(el[i].dataset.store);el[i].setAttribute('onClick', 'FBDownloader.processVideo(\"'+jsonData['src']+'\",\"'+jsonData['videoID']+'\");');}}})()");
                webView.loadUrl("javascript:( window.onload=prepareVideo;)()");
            }

            public void onPageFinished(WebView webview, String s)
            {
                webView.loadUrl("javascript:(function() { var el = document.querySelectorAll('div[data-sigil]');for(var i=0;i<el.length; i++){var sigil = el[i].dataset.sigil;if(sigil.indexOf('inlineVideo') > -1){delete el[i].dataset.sigil;var jsonData = JSON.parse(el[i].dataset.store);el[i].setAttribute('onClick', 'FBDownloader.processVideo(\"'+jsonData['src']+'\");');}}})()");
                Log.e("WEBVIEWFIN", s);
            }
        });
How can I implement it in B4A using webviewsettings and webviewextras?​
 
Top