Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: libadblockplus-android-webview/assets/inject.js

Issue 29351744: Issue 4399 - Add WebView inheritor with ad blocking (Closed)
Patch Set: minor codestyle fixes Created Oct. 20, 2016, 1:16 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « libadblockplus-android-webview/assets/hide.js ('k') | libadblockplus-android-webview/build.gradle » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..0ba180b3e8406c92705cb44d75e6c28c792caeb3
--- /dev/null
+++ b/libadblockplus-android-webview/assets/inject.js
@@ -0,0 +1,45 @@
+var hideElements = function()
+{
+
+ // no need to invoke if already invoked on another event
+ if (jsBridge.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);
+
+};
« no previous file with comments | « libadblockplus-android-webview/assets/hide.js ('k') | libadblockplus-android-webview/build.gradle » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld