fluttercommunity / flutter_webview_plugin

Community WebView Plugin - Allows Flutter to communicate with a native WebView.
https://pub.dev/packages/flutter_webview_plugin
Other
1.48k stars 930 forks source link

Is any way to block all css in FlutterWebviewPlugin ? #820

Open Bes79 opened 3 years ago

Bes79 commented 3 years ago

Hi! I want to block all requests for css files from link tag. Is any way to do it?

shinriyo commented 3 years ago

run javascript

    var disableFileName = "aaa.css"; // css name
    for(var i = 0; i < document.styleSheets.length; i++) {
        var styleSheetPath = document.styleSheets[i].href;
        var fileName = styleSheetPath.substring(styleSheetPath.lastIndexOf('/')+1, styleSheetPath.length);
        if (fileName === disableFileName) {
            document.styleSheets[i].disabled = true;
        }
    }