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
|
||||
You shouldn't be opening the HTMLs elsewhere. */
|
||||
|
||||
let browser_data = {};
|
||||
export function refresh() {
|
||||
// Import modules.
|
||||
import texts from "./read.JS";
|
||||
|
||||
// Initialize browser data.
|
||||
let browser_data = {};
|
||||
|
||||
function refresh() {
|
||||
/* Update variable containing the browser data.
|
||||
|
||||
Returns: (dict) the updated browser data
*/
|
||||
browser_data['URL'] = window.location.href;
|
||||
return (browser_data['URL']);
|
||||
};
|
||||
Returns: (dict) the updated browser data
|
||||
*/
|
||||
|
||||
export function restrict() {
|
||||
browser_data.URL = window.location.href;
|
||||
return (browser_data.URL);
|
||||
}
|
||||
|
||||
export default class compat {
|
||||
static restrict() {
|
||||
/* Restrict pages containing this function from being loaded outside the extension.
|
||||
|
||||
Returns: (bool) page open is correct
*/
|
||||
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);
|
||||
alert(texts.universal(`invalid_open`));
|
||||
}
|
||||
|
||||
return (browser_condition_met);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue