improve the opening of settings

This commit is contained in:
buzz-lightsnack-2007 2024-04-15 22:45:20 +08:00
parent 62d6a85d36
commit 6b286eafb9
4 changed files with 23 additions and 11 deletions

View file

@ -1,5 +1,5 @@
<html>
<head>
<script src="../../scripts/pages/open/popup.js" type="module"></script>
<script src="/scripts/pages/open.js" type="module"></script>
</head>
</html>

View file

@ -1,8 +1,5 @@
<html>
<head>
<script
src="../../scripts/pages/open/settings.js"
type="module"
></script>
<script src="/scripts/pages/open.js" type="module"></script>
</head>
</html>

View file

@ -9,12 +9,7 @@ let DEBUG = true;
export default class windowman {
static new(URL, height, width) {
this.window = chrome.windows.create({
url: chrome.runtime.getURL(URL),
type: "popup",
width: width ? parseInt(width) : 600,
height: height ? parseInt(height) : 600,
});
this.window = chrome.windows.create({url: (URL.includes(`://`)) ? URL : chrome.runtime.getURL(URL), type: "popup", width: width ? parseInt(width) : 600, height: height ? parseInt(height) : 600});
}
// Prepare the window with its metadata.

20
scripts/pages/open.js Normal file
View file

@ -0,0 +1,20 @@
// Open the settings in a pop-up window.
import windowman from "/scripts/GUI/windowman.JS";
function redirect() {
let location = {};
location[`original`] = window.location.href;
location[`page`] = [...location[`original`].split(`/`)].pop();
location[`target`] = chrome.runtime.getURL("pages/".concat(location[`page`]));
windowman.new(location[`target`]);
window.close();
}
function main() {
redirect();
}
main();