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"; | ||||||
|  | 
 | ||||||
|  | // Initialize browser data.
 | ||||||
|  | let browser_data = {}; | ||||||
|  | 
 | ||||||
|  | function refresh() { | ||||||
|   /* Update variable containing the browser data. |   /* Update variable containing the browser data. | ||||||
| 
 | 
 | ||||||
|   Returns: (dict) the updated browser data
	*/ |   Returns: (dict) the updated browser data | ||||||
|   browser_data['URL'] = window.location.href; |   */ | ||||||
|   return (browser_data['URL']); |  | ||||||
| }; |  | ||||||
| 
 | 
 | ||||||
| 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. |     /* Restrict pages containing this function from being loaded outside the extension. | ||||||
| 
 | 
 | ||||||
|   Returns: (bool) page open is correct
	*/ |     Returns: (bool) page open is correct | ||||||
|  |     */ | ||||||
| 
 | 
 | ||||||
|     refresh(); |     refresh(); | ||||||
|  | 
 | ||||||
|     const browser_extension_URL_contents = new RegExp(`^(?!file:\/\/|http:\/\/|https:\/\/)(.*-extension:\/\/.*)`); |     const browser_extension_URL_contents = new RegExp(`^(?!file:\/\/|http:\/\/|https:\/\/)(.*-extension:\/\/.*)`); | ||||||
|     const browser_condition_met = browser_extension_URL_contents.test(browser_data.URL); |     const browser_condition_met = browser_extension_URL_contents.test(browser_data.URL); | ||||||
|     if (!browser_condition_met) { |     if (!browser_condition_met) { | ||||||
|     alert("This page can not be opened. \r此网页无法打开。"); |       alert(texts.universal(`invalid_open`)); | ||||||
|   }; |     } | ||||||
|   console.log(browser_data.URL); | 
 | ||||||
|     return (browser_condition_met); |     return (browser_condition_met); | ||||||
| }; |   } | ||||||
|  | } | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue