updated code
This commit is contained in:
parent
887d03cf83
commit
18ce95698a
1 changed files with 34 additions and 23 deletions
|
@ -1,26 +1,37 @@
|
||||||
/* compat.js
|
/* compat.js
|
||||||
You shouldn't be opening the HTMLs elsewhere. */
|
You shouldn't be opening the HTMLs elsewhere. */
|
||||||
|
|
||||||
let browser_data = {};
|
// Import modules.
|
||||||
export function refresh() {
|
import texts from "./read.JS";
|
||||||
/* 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() {
|
// Initialize browser data.
|
||||||
/* Restrict pages containing this function from being loaded outside the extension.
|
let browser_data = {};
|
||||||
|
|
||||||
Returns: (bool) page open is correct
*/
|
function refresh() {
|
||||||
|
/* Update variable containing the browser data.
|
||||||
refresh();
|
|
||||||
const browser_extension_URL_contents = new RegExp(`^(?!file:\/\/|http:\/\/|https:\/\/)(.*-extension:\/\/.*)`);
|
Returns: (dict) the updated browser data
|
||||||
const browser_condition_met = browser_extension_URL_contents.test(browser_data.URL);
|
*/
|
||||||
if (!browser_condition_met) {
|
|
||||||
alert("This page can not be opened. \r此网页无法打开。");
|
browser_data.URL = window.location.href;
|
||||||
};
|
return (browser_data.URL);
|
||||||
console.log(browser_data.URL);
|
}
|
||||||
return (browser_condition_met);
|
|
||||||
};
|
export default class compat {
|
||||||
|
static 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(texts.universal(`invalid_open`));
|
||||||
|
}
|
||||||
|
|
||||||
|
return (browser_condition_met);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue