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

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

Issue 29351744: Issue 4399 - Add WebView inheritor with ad blocking (Closed)
Patch Set: changed packages, now using AdblockEngine (original ABPEngine), improved demo app Created Oct. 25, 2016, 11:20 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
« no previous file with comments | « libadblockplus-android-webview/AndroidManifest.xml ('k') | libadblockplus-android-webview/assets/empty.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: libadblockplus-android-webview/assets/css.js
diff --git a/libadblockplus-android-webview/assets/css.js b/libadblockplus-android-webview/assets/css.js
new file mode 100644
index 0000000000000000000000000000000000000000..708c1e5b6954d8d5eded3289f1c4353fe7591942
--- /dev/null
+++ b/libadblockplus-android-webview/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');
+}
« no previous file with comments | « libadblockplus-android-webview/AndroidManifest.xml ('k') | libadblockplus-android-webview/assets/empty.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld