forked from brz/Breez-ClickOnce-4C
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontent.js
44 lines (39 loc) · 1.99 KB
/
content.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
//Inject window.breezClickOnceInstalled property into page
const nullthrows = (v) => {
if (v == null) throw new Error("it's a null");
return v;
}
const injectCode = (src) => {
const script = document.createElement('script');
script.src = src;
script.onload = function() {
this.remove();
};
nullthrows(document.head || document.documentElement).appendChild(script);
}
injectCode(chrome.runtime.getURL('windowObjectHelper.js'));
//Show dialog if the helper executable failed to launch
chrome.runtime.onMessage.addListener((request, sender, sendResponse) => {
if(request.showDialog){
showDialog();
}
sendResponse();
});
const showDialog = () => {
const modal = document.createElement('div');
modal.setAttribute("id", "breezClickOnceModal");
modal.style.cssText = "position: fixed; z-index:2147483647; left:0; top:0; width:100%; height:100%; overflow:auto; background-color:rgb(0,0,0); background-color:rgba(0,0,0,0.4); user-select:none; color:#303030;";
const modalContent = document.createElement('div');
modalContent.style.cssText = "background-color: #fefefe; margin: 15% auto; padding: 20px; border: 1px solid #888; width: 80%;";
modal.appendChild(modalContent);
const closeBtn = document.createElement('span');
closeBtn.style.cssText = "color: #aaaaaa; float: right; font-size: 28px; font-weight: bold; cursor:pointer;";
closeBtn.innerHTML = "×";
closeBtn.setAttribute("onclick", "closeBreezClickOnceModal()");
modalContent.appendChild(closeBtn);
const p = document.createElement('p');
p.innerHTML = "To launch the ClickOnce application, <b>Breez ClickOnce Helper</b> needs to be installed on your computer.<br />Click <a href=\"https://breezie.be/dev/clickonce/breezclickoncehelper.exe\" target=\"_blank\">here</a> to download Breez ClickOnce Helper and reload the page after installing.";
modalContent.appendChild(p);
document.body.appendChild(modal);
}
injectCode(chrome.runtime.getURL('modalHelper.js'));