mirror of
https://github.com/BetterSEQTA/BetterSEQTA-Plus.git
synced 2026-06-06 03:34:40 +00:00
Refactor extension settings popup and iframe
This commit is contained in:
+25
-29
@@ -799,42 +799,38 @@ export function closeSettings() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function addExtensionSettings() {
|
function addExtensionSettings() {
|
||||||
let link = document.createElement('link');
|
const link = document.createElement('link');
|
||||||
link.href = chrome.runtime.getURL('popup/popup.css');
|
link.href = chrome.runtime.getURL('popup/popup.css');
|
||||||
link.type = 'text/css';
|
link.type = 'text/css';
|
||||||
link.rel = 'stylesheet';
|
link.rel = 'stylesheet';
|
||||||
document.getElementsByTagName('html')[0].appendChild(link);
|
document.querySelector('html').appendChild(link);
|
||||||
|
|
||||||
let Settings =
|
const extensionPopup = document.createElement('div');
|
||||||
stringToHTML(
|
extensionPopup.classList.add('outside-container', 'hide');
|
||||||
String.raw`
|
extensionPopup.id = 'ExtensionPopup';
|
||||||
<div class="outside-container hide" id="ExtensionPopup">
|
document.body.appendChild(extensionPopup);
|
||||||
</div>
|
|
||||||
`);
|
|
||||||
document.body.append(Settings.firstChild);
|
|
||||||
|
|
||||||
let iframe = document.createElement('iframe');
|
const extensionIframe = document.createElement('iframe');
|
||||||
iframe.src = chrome.runtime.getURL('interface/index.html');
|
extensionIframe.src = chrome.runtime.getURL('interface/index.html');
|
||||||
iframe.id = 'ExtensionIframe';
|
extensionIframe.id = 'ExtensionIframe';
|
||||||
iframe.allowTransparency = 'true';
|
extensionIframe.allowTransparency = true;
|
||||||
iframe.style.width = '384px';
|
extensionIframe.style.width = '384px';
|
||||||
iframe.style.height = '600px';
|
extensionIframe.style.height = '600px';
|
||||||
iframe.style.border = 'none';
|
extensionIframe.style.border = 'none';
|
||||||
iframe.setAttribute('excludeDarkCheck', 'true');
|
extensionIframe.setAttribute('excludeDarkCheck', true);
|
||||||
|
extensionPopup.appendChild(extensionIframe);
|
||||||
document.getElementById('ExtensionPopup').append(iframe);
|
|
||||||
|
|
||||||
var container = document.getElementById('container');
|
const container = document.getElementById('container');
|
||||||
var extensionsettings = document.getElementById('ExtensionPopup');
|
const closeExtensionPopup = () => {
|
||||||
var extensionIframe = document.getElementById('ExtensionIframe');
|
if (!SettingsClicked) {
|
||||||
|
extensionPopup.classList.add('hide');
|
||||||
container.onclick = function (event) {
|
extensionIframe.contentWindow.postMessage('popupClosed', '*');
|
||||||
|
}
|
||||||
|
SettingsClicked = false;
|
||||||
|
};
|
||||||
|
container.onclick = (event) => {
|
||||||
if (event.target.id !== 'AddedSettings') {
|
if (event.target.id !== 'AddedSettings') {
|
||||||
if (!SettingsClicked) {
|
closeExtensionPopup();
|
||||||
extensionsettings.classList.add('hide');
|
|
||||||
extensionIframe.contentWindow.postMessage('popupClosed', '*');
|
|
||||||
}
|
|
||||||
SettingsClicked = false;
|
|
||||||
} else {
|
} else {
|
||||||
SettingsClicked = false;
|
SettingsClicked = false;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user