-
Notifications
You must be signed in to change notification settings - Fork 1
/
cleanHomescreen.js
50 lines (42 loc) · 1.16 KB
/
cleanHomescreen.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
if (document.documentElement) {
initialize();
} else {
window.addEventListener('DOMContentLoaded', initialize);
}
function initialize() {
updateVisibility();
observeDomChange();
}
function updateVisibility() {
isHidden = ($('pages-panel').className == 'empty');
var css = '#pages-panel.empty {display:none} \n';
if (isHidden) {
css += '#page-indicator-header {display:none}\n';
css += '#shadow {top:0!important}\n';
css += '#panels {height: 100%!important}';
}
setStyle(css);
}
function setStyle(css) {
var style = document.getElementById('injectedStyleFromCleanHomescreenAddOn');
if (style) {
style.parentNode.removeChild(style);
}
style = document.createElement('style');
style.type = 'text/css';
style.id = 'injectedStyleFromCleanHomescreenAddOn';
style.appendChild(document.createTextNode(css));
var head = document.head || document.getElementsByTagName('head')[0];
head.appendChild(style);
}
function observeDomChange() {
var observer = new window.MutationObserver(function(mutations, observer) {
updateVisibility();
});
observer.observe($('pages-panel'), {
attributes: true
});
}
function $(id) {
return document.getElementById(id);
}