Index: libadblockplus-android-webview/assets/inject.js |
diff --git a/libadblockplus-android-webview/assets/inject.js b/libadblockplus-android-webview/assets/inject.js |
new file mode 100644 |
index 0000000000000000000000000000000000000000..d6c4599f47e9bf5994a4be1ebd312916a49665c0 |
--- /dev/null |
+++ b/libadblockplus-android-webview/assets/inject.js |
@@ -0,0 +1,44 @@ |
+var hideElements = function() |
+{ |
+ // no need to invoke if already invoked on another event |
+ if ({{BRIDGE}}.isElementsHidden()) |
+ { |
+ {{DEBUG}} console.log('already hidden, exiting'); |
+ return; |
+ } |
+ |
+ // hide using element visibility (to be replaced with script body) |
+ {{HIDE}} |
+ |
+ {{BRIDGE}}.setElementsHidden(true); // set flag not to do it again |
+}; |
+ |
+if ({{BRIDGE}}.getAddDomListener() && document.readyState != 'complete') |
+{ |
+ {{BRIDGE}}.setAddDomListener(false); |
+ |
+ // onreadystatechange event |
+ document.onreadystatechange = function() |
+ { |
+ {{DEBUG}} console.log('onreadystatechange() event fired (' + document.readyState + ')') |
+ if (document.readyState == 'interactive') |
+ { |
+ hideElements(); |
+ } |
+ } |
+ |
+ // load event |
+ window.addEventListener('load', function(event) |
+ { |
+ {{DEBUG}} console.log('load() event fired'); |
+ hideElements(); |
+ }); |
+ |
+ // DOMContentLoaded event |
+ document.addEventListener('DOMContentLoaded', function() |
+ { |
+ {{DEBUG}} console.log('DOMContentLoaded() event fired'); |
+ hideElements(); |
+ }, false); |
+ |
+}; |