diff --git a/gui/popup.htm b/gui/popup.htm index 088c842..09e22a8 100644 --- a/gui/popup.htm +++ b/gui/popup.htm @@ -1 +1,3 @@ -
\ No newline at end of file + + + diff --git a/gui/scripts/compat.js b/gui/scripts/compat.js index cb4f8b2..36b34b9 100644 --- a/gui/scripts/compat.js +++ b/gui/scripts/compat.js @@ -1 +1,26 @@ -/* 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 +/* 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此网页无法打开。"); + }; + console.log(browser_data.URL); + return (browser_condition_met); +}; diff --git a/gui/scripts/popup.js b/gui/scripts/popup.js new file mode 100644 index 0000000..d12f86b --- /dev/null +++ b/gui/scripts/popup.js @@ -0,0 +1,12 @@ + +// Call the main function. +function main() { + +} + +/* Run detection */ +import {restrict} from "./compat.js"; + +if (!restrict()) { + main(); +}