Stop attempting to open the file as it is.
Use the extension to test itself.
This commit is contained in:
parent
663081c8ab
commit
a3c7152497
3 changed files with 3 additions and 0 deletions
|
@ -0,0 +1 @@
|
|||
<html>
<head>
<script type="module">
import {restrict} from "./scripts/compat.js";
restrict();
</script>
</head>
</html>
|
1
gui/scripts/compat.js
Normal file
1
gui/scripts/compat.js
Normal file
|
@ -0,0 +1 @@
|
|||
/* compat.js
You shouldn't be opening the HTMLs elsewhere. */
let browser_data = {};
export function refresh() {
/* Update variable containing the browser data.
Returns: (dict) the updated browser data
*/
browser_data['URL'] = window.location.href;
return (browser_data['URL']);
};
export function restrict() {
/* Restrict pages containing this function from being loaded outside the extension.
Returns: (bool) page open is correct
*/
refresh();
const browser_extension_URL_contents = new RegExp(`^(?!file:\/\/|http:\/\/|https:\/\/)(.*-extension:\/\/.*)`);
const browser_condition_met = browser_extension_URL_contents.test(browser_data.URL);
if (!browser_condition_met) {
alert("This page can not be opened. \r此网页无法打开。");
};
return (browser_condition_met);
};
|
|
@ -0,0 +1 @@
|
|||
<html>
<head>
<script type="module">
import {restrict} from "./scripts/compat.js";
restrict();
</script>
</head>
</html>
|
Loading…
Add table
Add a link
Reference in a new issue