From a3c715249718b7294e02d39ef0d20eec17279944 Mon Sep 17 00:00:00 2001 From: buzz-lightsnack-2007 <73412182+buzz-lightsnack-2007@users.noreply.github.com> Date: Sun, 17 Mar 2024 18:09:44 +0800 Subject: [PATCH] Stop attempting to open the file as it is. Use the extension to test itself. --- gui/popup.htm | 1 + gui/scripts/compat.js | 1 + gui/settings.htm | 1 + 3 files changed, 3 insertions(+) create mode 100644 gui/scripts/compat.js diff --git a/gui/popup.htm b/gui/popup.htm index e69de29..088c842 100644 --- a/gui/popup.htm +++ b/gui/popup.htm @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/gui/scripts/compat.js b/gui/scripts/compat.js new file mode 100644 index 0000000..cb4f8b2 --- /dev/null +++ b/gui/scripts/compat.js @@ -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); }; \ No newline at end of file diff --git a/gui/settings.htm b/gui/settings.htm index e69de29..263ced8 100644 --- a/gui/settings.htm +++ b/gui/settings.htm @@ -0,0 +1 @@ + \ No newline at end of file