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

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

Issue 29361445: Issue 4399 - Add WebView inheritor with ad blocking (Closed)
Patch Set: fixed 2 more members in AdblockEngine Created Dec. 16, 2016, 8:31 a.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
Index: libadblockplus-android-webview/assets/hide.js
diff --git a/libadblockplus-android-webview/assets/hide.js b/libadblockplus-android-webview/assets/hide.js
new file mode 100644
index 0000000000000000000000000000000000000000..6e08c63c2a5149fb22a139831d44038dd124bdab
--- /dev/null
+++ b/libadblockplus-android-webview/assets/hide.js
@@ -0,0 +1,29 @@
+{
+ {{DEBUG}} console.log('started hiding elements');
+ var selectors = JSON.parse({{BRIDGE}}.getElemhideSelectors());
+ {{DEBUG}} console.log('parsed selectors: ' + selectors.length);
+ for (var i = 0; i < selectors.length; i++)
+ {
+ var selector = selectors[i];
+// console.log('testing selector ' + selector);
Felix Dahlke 2016/12/16 13:40:45 Nit: Add {{DEBUG}} or remove?
anton 2016/12/19 13:22:14 Acknowledged.
+ if (selector[0] == '#')
+ {
+ var element = document.getElementById(selector.substr(1));
+ if (element != undefined)
+ {
+ {{DEBUG}} console.log('elem blocked ' + selector);
+ element.style.display = 'none';
+ };
+ }
+ else
+ {
+ var elements = document.getElementsByClassName(selector.substr(1));
+ for (var k=0; k < elements.length; k++)
+ {
+ {{DEBUG}} console.log('elem hidden ' + selector);
+ elements[k].style.display = 'none';
+ }
+ };
+ };
+ {{DEBUG}} console.log('finished hiding elements');
+};

Powered by Google App Engine
This is Rietveld