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

Unified Diff: libadblockplus-android/assets/css.js

Issue 29351744: Issue 4399 - Add WebView inheritor with ad blocking (Closed)
Patch Set: Created Sept. 8, 2016, 12:52 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
Index: libadblockplus-android/assets/css.js
diff --git a/libadblockplus-android/assets/css.js b/libadblockplus-android/assets/css.js
new file mode 100644
index 0000000000000000000000000000000000000000..708c1e5b6954d8d5eded3289f1c4353fe7591942
--- /dev/null
+++ b/libadblockplus-android/assets/css.js
@@ -0,0 +1,21 @@
+{
+ {{DEBUG}} console.log('starting injecting css rules');
+ var selectors = JSON.parse({{BRIDGE}}.getElemhideSelectors());
+ {{DEBUG}} console.log('parsed selectors: ' + selectors.length);
+ var head = document.getElementsByTagName("head")[0];
+ var style = document.createElement("style");
+ head.appendChild(style);
+ var sheet = style.sheet ? style.sheet : style.styleSheet;
+ for (var i=0; i<selectors.length; i++)
+ {
+ if (sheet.insertRule)
+ {
+ sheet.insertRule(selectors[i] + ' { display: none !important; }', 0);
+ }
+ else
+ {
+ sheet.addRule(selectors[i], 'display: none !important;', 0);
+ }
+ }
+ {{DEBUG}} console.log('finished injecting css rules');
+}

Powered by Google App Engine
This is Rietveld