-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
47 lines (39 loc) · 1.35 KB
/
index.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
// If injecting into an app that was already running at the time
// the app was enabled, simply initialize it.
if (document.documentElement) {
initialize();
}
// Otherwise, we need to wait for the DOM to be ready before
// starting initialization since add-ons are injected
// *before* `document.documentElement` is defined.
else {
window.addEventListener('DOMContentLoaded', initialize);
}
function initialize() {
if (document.querySelector('.fxos-banner')) {
// Already injected, abort.
return;
} else {
var body = document.querySelector('body');
var fxosBanner = document.createElement('div');
fxosBanner.classList.add('fxos-banner');
var bannerText = document.createElement('p');
var closeBtn = document.createElement('button');
bannerText.style.position = "absolute";
bannerText.style.top = "50%";
bannerText.style.left = "50%"
bannerText.style.right = "50%";
bannerText.style.zIndex = "30000";
bannerText.style.color = "blue";
bannerText.style.fontFamily = "Arial";
bannerText.style.fontSize = "larger";
fxosBanner.appendChild(bannerText);
fxosBanner.appendChild(closeBtn);
body.appendChild(fxosBanner);
closeBtn.textContent = 'X';
bannerText.textContent = 'Wow, you have an extension installed!';
closeBtn.onclick = function() {
fxosBanner.parentNode.removeChild(fxosBanner);
}
}
}