-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpanel.js
37 lines (29 loc) · 973 Bytes
/
panel.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
'use strict';
if (window.top !== window) { // only in frames
let id;
const resize = () => {
window.top.postMessage({
type: 'resize',
height: document.body.getBoundingClientRect().height
}, "*");
};
document.addEventListener('DOMContentLoaded', () => {
const observer = new MutationObserver(() => {
window.clearTimeout(id);
id = window.setTimeout(resize, 500);
});
observer.observe(document.body, {
attributes: false,
childList: true,
characterData: false,
subtree: true,
});
// preventing panel from prompting alert or confirm; this needs to be injected to the unwrapped window object to let overwrite alert and confirm functions
const script = document.createElement('script');
script.textContent = 'window.alert = window.confirm = function() {return true;}';
document.body.appendChild(script);
}, false);
}
function onError(error) {
console.error(`Error: ${error}`);
}