forked from hsbakshi/reddit-check
-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathoverlay.js
32 lines (31 loc) · 1.02 KB
/
overlay.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
function adjustWidth(e) {
let ti = document.getElementById("thredd-iframe");
if (e.matches) {
ti.style.width = "100%";
} else {
ti.style.width = "525px";
}
}
if (document.getElementById('thredd-overlay')) {
document.getElementById("thredd-overlay").remove();
} else {
let thredd_overlay = document.createElement('div');
thredd_overlay.id = 'thredd-overlay';
document.body.appendChild(thredd_overlay);
let thredd_dragbar = document.createElement('div');
let overlay = document.createElement('iframe');
overlay.id = 'thredd-iframe';
overlay.height = "100%";
overlay.src = chrome.extension.getURL("popup.html");
style = overlay.style;
style.position = "fixed";
style.zIndex = 2147483646;
style.top = 0;
style.right = 0;
style.background = "#FFFFFF";
thredd_overlay.appendChild(overlay);
// adjust width if device is less than max-width
let wmm = window.matchMedia("(max-width: 525px)");
adjustWidth(wmm);
wmm.addListener(adjustWidth);
}