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

Side by Side Diff: libadblockplus-android/assets/inject.js

Issue 29351744: Issue 4399 - Add WebView inheritor with ad blocking (Closed)
Patch Set: Created Sept. 8, 2016, 12:52 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 var hideElements = function()
2 {
3
4 // no need to invoke if already invoked on another event
5 if (jsBridge.isElementsHidden())
6 {
7 {{DEBUG}} console.log('already hidden, exiting');
8 return;
9 }
10
11 // hide using element visibility (to be replaced with script body)
12 {{HIDE}}
13
14 {{BRIDGE}}.setElementsHidden(true); // set flag not to do it again
15 };
16
17 if ({{BRIDGE}}.getAddDomListener() && document.readyState != 'complete')
18 {
19 {{BRIDGE}}.setAddDomListener(false);
20
21 // onreadystatechange event
22 document.onreadystatechange = function()
23 {
24 {{DEBUG}} console.log('onreadystatechange() event fired (' + document.readyS tate + ')')
25 if (document.readyState == 'interactive')
26 {
27 hideElements();
28 }
29 }
30
31 // load event
32 window.addEventListener('load', function(event)
33 {
34 {{DEBUG}} console.log('load() event fired');
35 hideElements();
36 });
37
38 // DOMContentLoaded event
39 document.addEventListener('DOMContentLoaded', function()
40 {
41 {{DEBUG}} console.log('DOMContentLoaded() event fired');
42 hideElements();
43 }, false);
44
45 };
OLDNEW

Powered by Google App Engine
This is Rietveld