sha*_*dox 6 javascript android webview
我在无法控制的 WebView 中注入了一些 Javascript。我正在尝试使用 MutationObserver 但它不会在发生更改时通知我。除突变外,一切正常:
(function(){
if(typeof androidControlbarListener !== "undefined"){
var controlbar = document.getElementsByClassName(\"controlbar\")[0];
var displayStyle = window.getComputedStyle(controlbar).display;
if(displayStyle !== \'none\') {
androidControlbarListener.controlbarVisible();
var config = { attributes: true, childList: true, subtree: true, characterData: true };
MutationObserver = window.MutationObserver || window.WebKitMutationObserver;
var observer = new MutationObserver(function(mutations) {
mutations.forEach(function(mutation) {
var currentValue = mutation.target.style.display;
//some processing here
androidControlbarListener.controlbarChanged();
});
});
observer.observe(controlbar, config);
}
return true;
} else {
return false;
}
})()
Run Code Online (Sandbox Code Playgroud)
我@JavascriptInterface用于回调和evaluateJavascript方法。我从来没有接到过androidControlbarListener.