問題タブ [wkwebviewconfiguration]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
javascript - How to inject multiple user scripts in WKWebView to obtain darkmode effect?
I have successfully obtained darkmode effect for random HTML on a website html page using source from this great tutorial.
I have uploaded these photos to explain better what I obtained.
I am trying to obtain the same on a WKWebView. The HTML is loaded from an API so I use the WKWebView.loadHTMLString method. For this example the demo HTML is saved in a file in the Xcode project. Also I've added 2 javascript files in Xcode: darkmode.min.js (which is the library) and darkmode-options.js (the position and text label for the toggle in the bottom of the page). I think that I do not inject correctly the 2 scripts using WKUserScript. Obviously the darkmode.min.js must be loaded before darkmode-options.js. That is why I used WKUserScriptInjectionTime.atDocumentStart and WKUserScriptInjectionTime.atDocumentEnd.
Also when I print in the console the view source of the HTML, it does not show the scripts that have been inserted.
#xA;The project is uploaded on github: https://github.com/CristiGhn/darkmode-webview. The Xcode project also contains a darkmode.html that works and shows the exact as the photos above.
Thank you!
javascript - マージンの変更
および目標cのwkwebviewキット
HTML文字列のスペースを減らしたかったのです。以下は、使用しているコードです
私もJavascriptを使用してみましたが、複数の行間隔ではなく1行の間隔のみを与えるJavaスクリプトを正確に渡す必要があるかどうかはわかりません:
しかし、間隔を適切に削除することはできません。