fixed class referencing
This commit is contained in:
		
							parent
							
								
									6a1ea8eb7d
								
							
						
					
					
						commit
						543fe2f913
					
				
					 9 changed files with 383 additions and 377 deletions
				
			
		|  | @ -13,7 +13,9 @@ export default class logging { | |||
|   static error(ERROR_CODE, ERROR_MESSAGE, critical = true) { | ||||
|     (async () => { | ||||
|       // Import the templating.
 | ||||
|       const texts = await import(chrome.runtime.getURL("gui/scripts/read.js")); | ||||
|       const texts = ( | ||||
|         await import(chrome.runtime.getURL("gui/scripts/read.js")) | ||||
|       )[`texts`]; | ||||
| 
 | ||||
|       // Display the error message.
 | ||||
|       console.error(texts.read(`error_msg`, [ERROR_CODE, ERROR_MESSAGE])); | ||||
|  |  | |||
|  | @ -1,12 +1,11 @@ | |||
| import {windowman} from '../../windowman.JS'; | ||||
| import { windowman } from "../../windowman.JS"; | ||||
| 
 | ||||
| function redirect() { | ||||
|   new windowman(`gui/pages/settings.htm`); | ||||
|   windowman.new(`gui/pages/settings.htm`); | ||||
| 
 | ||||
|   window.close(); | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| function main() { | ||||
|   redirect(); | ||||
| } | ||||
|  |  | |||
|  | @ -1,14 +1,13 @@ | |||
| // Open the settings in a pop-up window.
 | ||||
| 
 | ||||
| import {windowman} from '../../windowman.JS'; | ||||
| import { windowman } from "../../windowman.JS"; | ||||
| 
 | ||||
| function redirect() { | ||||
|   new windowman(`gui/pages/settings.htm`); | ||||
|   windowman.new(`gui/pages/settings.htm`); | ||||
| 
 | ||||
|   window.close(); | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| function main() { | ||||
|   redirect(); | ||||
| } | ||||
|  |  | |||
|  | @ -3,13 +3,23 @@ | |||
| */ | ||||
| 
 | ||||
| // Import modules.
 | ||||
| import { windowman } from "../windowman.js"; | ||||
| let secretariat = await import(chrome.runtime.getURL("scripts/secretariat.js")); | ||||
| //import { windowman } from "../windowman.js";
 | ||||
| 
 | ||||
| async function build() { | ||||
|   let secretariat = ( | ||||
|     await import(chrome.runtime.getURL("scripts/secretariat.js")) | ||||
|   ).secretariat; | ||||
|   let windowman = ( | ||||
|     await import(chrome.runtime.getURL("gui/scripts/windowman.js")) | ||||
|   ).windowman; | ||||
| 
 | ||||
|   let window = new windowman(); | ||||
| } | ||||
| 
 | ||||
| /* | ||||
|     Arrange the interface. | ||||
|     */ | ||||
| function arrange() { | ||||
| /*function arrange() { | ||||
|   async function openLast() { | ||||
|     let last_opened = ( | ||||
|       await Promise.all([secretariat.read([`view`, window.location.href], 1)]) | ||||
|  | @ -26,17 +36,24 @@ function arrange() { | |||
|   openLast(); | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| function main() { | ||||
|   windowman.fill(); | ||||
|   events(); | ||||
|   arrange(); | ||||
| }*/ | ||||
| 
 | ||||
| /* | ||||
|     Define the mapping of each button. | ||||
|     */ | ||||
| function events() { | ||||
|   windowman.events(); | ||||
| 
 | ||||
|   if (document.querySelector(`[data-action="filters,update"]`)) { | ||||
|     document | ||||
|       .querySelector(`[data-action="filters,update"]`) | ||||
|       .addEventListener(`click`, async () => { | ||||
|         let filters = await import(chrome.runtime.getURL(`scripts/filters.js`)); | ||||
|         let filters = ( | ||||
|           await import(chrome.runtime.getURL(`scripts/filters.js`)) | ||||
|         ).default; | ||||
|         filters.update(); | ||||
|       }); | ||||
|   } | ||||
|  | @ -44,19 +61,22 @@ function events() { | |||
|     document | ||||
|       .querySelector(`[data-action="storage,clear"]`) | ||||
|       .addEventListener(`click`, async () => { | ||||
|         let storage = await import( | ||||
|           chrome.runtime.getURL(`scripts/secretariat.js`) | ||||
|         ); | ||||
|         let storage = ( | ||||
|           await import(chrome.runtime.getURL(`scripts/secretariat.js`)) | ||||
|         )["secretariat"]; | ||||
|         storage.forget(`sites`); | ||||
|       }); | ||||
|   } | ||||
| } | ||||
| 
 | ||||
| function main() { | ||||
|   windowman.prepare(); | ||||
|   windowman.fill(); | ||||
| //main();
 | ||||
| function load() { | ||||
|   document.addEventListener("DOMContentLoaded", function () { | ||||
|     M.AutoInit(); | ||||
|   }); | ||||
| 
 | ||||
|   build(); | ||||
|   events(); | ||||
|   arrange(); | ||||
| } | ||||
| 
 | ||||
| main(); | ||||
| load(); | ||||
|  |  | |||
|  | @ -1,63 +1,108 @@ | |||
| /* windowman | ||||
| Window management */ | ||||
| Window and window content management */ | ||||
| 
 | ||||
| import texts from "./read.js"; | ||||
| 
 | ||||
| class windowman { | ||||
|   /* Initialize the window frame. */ | ||||
|   static prepare() { | ||||
|     try { | ||||
|       let UI = { | ||||
|         library: [ | ||||
|           chrome.runtime.getURL("gui/styles/interface.external.css"), | ||||
|           chrome.runtime.getURL("gui/styles/ui.css"), | ||||
|         ], | ||||
|         script: chrome.runtime.getURL( | ||||
|           "gui/scripts/external/interface.external.js", | ||||
|         ), | ||||
|       }; | ||||
| 
 | ||||
|       UI.library.forEach((source) => { | ||||
|         $(`head`).append( | ||||
|           `<link rel="stylesheet" type="text/css" href="${source}">`, | ||||
|         ); | ||||
|       }); | ||||
| 
 | ||||
|       $(`head`).append(`<script type="module" src="${UI.script}"></script>`); | ||||
|     } catch (error) { | ||||
|       console.error(texts.localized(`error_fileNotFound`, [error])); | ||||
|     } | ||||
| 
 | ||||
|     // Prevent scaling, similar to a real window.
 | ||||
|     $(`head`).append( | ||||
|       `<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />`, | ||||
|     ); | ||||
|   } | ||||
| 
 | ||||
|   constructor(URL, height, width) { | ||||
|   static new(URL, height, width) { | ||||
|     this.window = chrome.windows.create({ | ||||
|       url: chrome.runtime.getURL(URL), | ||||
|       type: "popup", | ||||
|       width: width ? parseInt(width) : 400, | ||||
|       width: width ? parseInt(width) : 600, | ||||
|       height: height ? parseInt(height) : 600, | ||||
|     }); | ||||
|   } | ||||
| 
 | ||||
|   static fill() { | ||||
|     function text() { | ||||
|       let text_elements = document.querySelectorAll("[data-text]"); | ||||
|   // Prepare the window with its metadata.
 | ||||
|   constructor() { | ||||
|     function headers() { | ||||
|       let UI = { | ||||
|         library: [ | ||||
|           chrome.runtime.getURL( | ||||
|             "gui/styles/external/mdi/materialdesignicons.min.css", | ||||
|           ), | ||||
|           chrome.runtime.getURL( | ||||
|             "gui/styles/external/materialize/css/materialize.css", | ||||
|           ), | ||||
|           chrome.runtime.getURL("gui/styles/ui.css"), | ||||
|         ], | ||||
|       }; | ||||
| 
 | ||||
|       text_elements.forEach((text_element) => { | ||||
|       UI.library.forEach((source) => { | ||||
|         let metadata_element = document.createElement(`link`); | ||||
|         metadata_element.setAttribute(`rel`, `stylesheet`); | ||||
|         metadata_element.setAttribute(`type`, `text/css`); | ||||
|         metadata_element.setAttribute(`href`, source); | ||||
|         document.querySelector(`head`).appendChild(metadata_element); | ||||
|       }); | ||||
|     } | ||||
| 
 | ||||
|     // Get the window.
 | ||||
|     this[`metadata`] = chrome.windows.getCurrent(); | ||||
| 
 | ||||
|     /* | ||||
|     window_metadata[`id`] = window.id; | ||||
|     window_metadata[`focused`] = window.focused; | ||||
|     window_metadata[`state`] = window.state; | ||||
|     window_metadata[`type`] = window.type; | ||||
|     window_metadata[`incognito`] = window.incognito; | ||||
|     window_metadata[`alwaysOnTop`] = window.alwaysOnTop; | ||||
|     window_metadata[`sessionId`] = window.sessionId; | ||||
|     window_metadata[`tabs`] = window.tabs;*/ | ||||
| 
 | ||||
|     /* Fill in data and events.  */ | ||||
|     function appearance() { | ||||
|       function icons() { | ||||
|         let target_elements = document.querySelectorAll(`[data-icon]`); | ||||
| 
 | ||||
|         target_elements.forEach((element) => { | ||||
|           // Get the content before removing it.
 | ||||
|           let element_data = {}; | ||||
| 
 | ||||
|           // Swap the placement of the existing content.
 | ||||
|           function swap() { | ||||
|             element_data[`content`] = element.innerHTML; | ||||
|             element.innerHTML = ``; | ||||
| 
 | ||||
|             let element_text = document.createElement(`span`); | ||||
|             element_text.innerHTML = element_data[`content`]; | ||||
| 
 | ||||
|             element.appendChild(element_text); | ||||
|           } | ||||
| 
 | ||||
|           // Add the icon.
 | ||||
|           function iconify() { | ||||
|             // Get the icon.
 | ||||
|             element_data[`icon`] = element.getAttribute(`data-icon`); | ||||
| 
 | ||||
|             // Get the icon.
 | ||||
|             let icon_element = document.createElement(`i`); | ||||
|             icon_element.className = `mdi mdi-`.concat(element_data[`icon`]); | ||||
|             element.prepend(icon_element); | ||||
|           } | ||||
| 
 | ||||
|           swap(); | ||||
|           iconify(); | ||||
|         }); | ||||
|       } | ||||
| 
 | ||||
|       function text() { | ||||
|         let text_elements = {}; | ||||
|         text_elements[`content`] = document.querySelectorAll("[for]"); | ||||
|         text_elements[`alt`] = document.querySelectorAll("[alt-for]"); | ||||
|         text_elements[`title`] = document.querySelectorAll("[title-for]"); | ||||
| 
 | ||||
|         text_elements[`content`].forEach((text_element) => { | ||||
|           let text_inserted = texts.localized( | ||||
|           text_element.getAttribute(`data-text`), | ||||
|             text_element.getAttribute(`for`), | ||||
|             false, | ||||
|           text_element.hasAttribute(`data-text-parameter`) | ||||
|             ? text_element.getAttribute(`data-text-parameter`).split(",") | ||||
|             text_element.hasAttribute(`for-parameter`) | ||||
|               ? text_element.getAttribute(`for-parameter`).split(",") | ||||
|               : null, | ||||
|           ); | ||||
|           if (!text_inserted) { | ||||
|             text_inserted = texts.localized( | ||||
|             `term_`.concat(text_element.getAttribute(`data-text`)), | ||||
|               `term_`.concat(text_element.getAttribute(`for`)), | ||||
|             ); | ||||
|           } | ||||
| 
 | ||||
|  | @ -67,10 +112,33 @@ class windowman { | |||
|             text_element.innerText = text_inserted; | ||||
|           } | ||||
|         }); | ||||
| 
 | ||||
|         delete text_elements[`content`]; | ||||
|         Object.keys(text_elements).forEach((key) => { | ||||
|           if (text_elements[key]) { | ||||
|             text_elements[key].forEach((text_element) => { | ||||
|               let text_inserted = texts.localized( | ||||
|                 text_element.getAttribute(key.concat(`-for`)), | ||||
|                 false, | ||||
|                 text_element.hasAttribute(key.concat(`for-parameter`)) | ||||
|                   ? text_element | ||||
|                       .getAttribute(key.concat(`for-parameter`)) | ||||
|                       .split(",") | ||||
|                   : null, | ||||
|               ); | ||||
|               if (!text_inserted) { | ||||
|                 text_inserted = texts.localized( | ||||
|                   `term_`.concat(text_element.getAttribute(key.concat(`-for`))), | ||||
|                 ); | ||||
|               } | ||||
| 
 | ||||
|     function storage() { | ||||
|       (async () => { | ||||
|               text_element.setAttribute(key, text_inserted); | ||||
|             }); | ||||
|           } | ||||
|         }); | ||||
|       } | ||||
| 
 | ||||
|       async function storage() { | ||||
|         // Import the module.
 | ||||
|         const secretariat = await import( | ||||
|           chrome.runtime.getURL("scripts/secretariat.js") | ||||
|  | @ -108,18 +176,17 @@ class windowman { | |||
|             } | ||||
|           }); | ||||
|         }); | ||||
|       })(); | ||||
|       } | ||||
| 
 | ||||
|       text(); | ||||
|       icons(); | ||||
|       storage(); | ||||
|     } | ||||
| 
 | ||||
|   /* Add click events. */ | ||||
|   static events() { | ||||
|     // Adds events to the window.
 | ||||
|     function events() { | ||||
|       /* Add events related to storage. */ | ||||
|     function storage() { | ||||
|       (async () => { | ||||
|       async function storage() { | ||||
|         // Import the module.
 | ||||
|         const secretariat = await import( | ||||
|           chrome.runtime.getURL("scripts/secretariat.js") | ||||
|  | @ -160,87 +227,6 @@ class windowman { | |||
| 
 | ||||
|           input_element.addEventListener("change", element[`event`]); | ||||
|         }); | ||||
|       })(); | ||||
|     } | ||||
| 
 | ||||
|     /* Make it feel more like a native window. */ | ||||
|     function functionality() { | ||||
|       /* Adjust the interface based on events. */ | ||||
|       function changeUI() { | ||||
|         function tabs() { | ||||
|           let menus = document.querySelectorAll("menu[role=tablist]"); | ||||
| 
 | ||||
|           if (menus) { | ||||
|             menus.forEach((menu) => { | ||||
|               let buttons = menu.querySelectorAll("button, a"); | ||||
| 
 | ||||
|               if (buttons) { | ||||
|                 buttons.forEach((button) => { | ||||
|                   let event = function () { | ||||
|                     // Prevent selection.
 | ||||
|                     let MENU = this.parentElement; | ||||
|                     let BUTTONS = MENU.querySelectorAll("button, a"); | ||||
| 
 | ||||
|                     BUTTONS.forEach((BUTTON) => { | ||||
|                       BUTTON.setAttribute( | ||||
|                         `aria-selected`, | ||||
|                         String( | ||||
|                           BUTTON.getAttribute(`for`) == | ||||
|                             this.getAttribute(`for`), | ||||
|                         ), | ||||
|                       ); | ||||
|                     }); | ||||
| 
 | ||||
|                     let CONTAINER = document.getElementById( | ||||
|                       MENU.getAttribute(`for`), | ||||
|                     ); | ||||
|                     let SECTIONS = CONTAINER.querySelectorAll( | ||||
|                       `#${CONTAINER.id} > section`, | ||||
|                     ); | ||||
| 
 | ||||
|                     SECTIONS.forEach((SECTION) => { | ||||
|                       // SECTION.setAttribute(`hidden`, true);
 | ||||
| 
 | ||||
|                       if (!this.getAttribute(`for`).includes(SECTION.id)) { | ||||
|                         SECTION.setAttribute( | ||||
|                           `hidden`, | ||||
|                           this.getAttribute(`for`).includes(SECTION.id), | ||||
|                         ); | ||||
|                       } else { | ||||
|                         SECTION.removeAttribute(`hidden`); | ||||
|                       } | ||||
|                     }); | ||||
| 
 | ||||
|                     // Save.
 | ||||
|                     (async () => { | ||||
|                       const secretariat = await import( | ||||
|                         chrome.runtime.getURL("scripts/secretariat.js") | ||||
|                       ); | ||||
| 
 | ||||
|                       // Write the data.
 | ||||
|                       secretariat.write( | ||||
|                         [`view`, window.location.href], | ||||
|                         parseInt(this.getAttribute(`tab`)), | ||||
|                         1, | ||||
|                       ); | ||||
|                     })(); | ||||
|                   }; | ||||
| 
 | ||||
|                   button.addEventListener("click", event); | ||||
|                 }); | ||||
|               } | ||||
|             }); | ||||
|           } | ||||
|         } | ||||
| 
 | ||||
|         tabs(); | ||||
|       } | ||||
| 
 | ||||
|       document.addEventListener("contextmenu", (event) => | ||||
|         event.preventDefault(), | ||||
|       ); | ||||
| 
 | ||||
|       changeUI(); | ||||
|       } | ||||
| 
 | ||||
|       /* Map buttons to their corresponding action buttons. */ | ||||
|  | @ -252,46 +238,22 @@ class windowman { | |||
|             buttons.forEach((button) => { | ||||
|               let event = function () { | ||||
|                 // Get the data from the button.
 | ||||
|               let file = {}; | ||||
|               file[`target`] = this.getAttribute(`href`); | ||||
|                 let target = {}; | ||||
|                 target[`source`] = this.getAttribute(`href`); | ||||
| 
 | ||||
|               // Check if the file exists to only open it when it is the case.
 | ||||
|               function testUrl(URL) { | ||||
|                 // Code from https://stackoverflow.com/questions/3646914/how-do-i-check-if-file-exists-in-jquery-or-pure-javascript
 | ||||
|                 const HTTP = new XMLHttpRequest(); | ||||
|                 try { | ||||
|                   HTTP.open(`HEAD`, URL, false); | ||||
|                   HTTP.send(); | ||||
|                   return HTTP.status != 404; | ||||
|                 } catch (error) { | ||||
|                   return false; | ||||
|                 } | ||||
|               } | ||||
|                 // Get the correct path.
 | ||||
|                 target[`path`] = ( | ||||
|                   !target[`source`].includes(`://`) | ||||
|                     ? window.location.pathname | ||||
|                         .split(`/`) | ||||
|                         .slice(0, -1) | ||||
|                         .join(`/`) | ||||
|                         .concat(`/`) | ||||
|                     : `` | ||||
|                 ).concat(target[`source`]); | ||||
| 
 | ||||
|               if (!file[`target`].includes(`://`)) { | ||||
|                 // Get the current path.
 | ||||
|                 file[`path`] = window.location.pathname.split(`/`); | ||||
|                 file[`path`] = | ||||
|                   file[`path`].slice(0, file[`path`].length - 1).join(`/`) + | ||||
|                   `/`; | ||||
|                 file[`location`] = file[`path`].concat(file[`target`]); | ||||
|               } else { | ||||
|                 file[`location`] = file[`target`]; | ||||
|               } | ||||
| 
 | ||||
|               let open_combinations = [``, `.htm`, `.html`]; | ||||
|               for ( | ||||
|                 let open_combination = 0; | ||||
|                 open_combination < open_combinations.length; | ||||
|                 open_combination++ | ||||
|               ) { | ||||
|                 if ( | ||||
|                   testUrl( | ||||
|                     file[`location`] + open_combinations[open_combination], | ||||
|                   ) | ||||
|                 ) { | ||||
|                   new windowman( | ||||
|                     file[`location`] + open_combinations[open_combination], | ||||
|                 windowman.new( | ||||
|                   target[`path`], | ||||
|                   this.getAttribute(`tab-height`) | ||||
|                     ? this.getAttribute(`tab-height`) | ||||
|                     : null, | ||||
|  | @ -299,9 +261,6 @@ class windowman { | |||
|                     ? this.getAttribute(`tab-width`) | ||||
|                     : null, | ||||
|                 ); | ||||
|                   break; | ||||
|                 } | ||||
|               } | ||||
|               }; | ||||
|               button.addEventListener("click", event); | ||||
|             }); | ||||
|  | @ -352,10 +311,14 @@ class windowman { | |||
|       } | ||||
| 
 | ||||
|       storage(); | ||||
|     functionality(); | ||||
|       actions(); | ||||
|       updates(); | ||||
|     } | ||||
| 
 | ||||
|     headers(); | ||||
|     appearance(); | ||||
|     events(); | ||||
|   } | ||||
| } | ||||
| 
 | ||||
| export { windowman }; | ||||
|  |  | |||
|  | @ -2,7 +2,7 @@ | |||
| This does not stand for "FamiCom" but instead on Finalization and Completion. This script provides installation run scripts. | ||||
| */ | ||||
| 
 | ||||
| import { read, write, init } from "./secretariat.js"; | ||||
| import { init } from "./secretariat.js"; | ||||
| 
 | ||||
| let config = chrome.runtime.getURL("config/config.json"); | ||||
| 
 | ||||
|  |  | |||
|  | @ -2,24 +2,36 @@ | |||
| Manage filters. | ||||
| */ | ||||
| 
 | ||||
| export default class filters { | ||||
|   constructor() { | ||||
|     this.all = {}; | ||||
|   } | ||||
| 
 | ||||
|   /* Select the most appropriate filter based on a URL. | ||||
| 
 | ||||
|   @param {string} URL the current URL | ||||
|   */ | ||||
| export async function select(URL = window.location.href) {} | ||||
|   static select(URL = window.location.href) { | ||||
|     this.one = {}; | ||||
|   } | ||||
| 
 | ||||
|   /* Update all filters or just one. | ||||
| 
 | ||||
|   @param {string} URL the URL to update | ||||
|   @return {boolean} the state | ||||
|   */ | ||||
| export async function update(URL) { | ||||
|   static update(URL) { | ||||
|     (async () => { | ||||
|       // Import the updater.
 | ||||
|       const secretariat = await import( | ||||
|         chrome.runtime.getURL("scripts/secretariat.js") | ||||
|       ); | ||||
|       const net = await import(chrome.runtime.getURL("scripts/net.js")); | ||||
|   const texts = await import(chrome.runtime.getURL("gui/scripts/read.js")); | ||||
|       const texts = (await import(chrome.runtime.getURL("gui/scripts/read.js"))) | ||||
|         .default; | ||||
|       const alerts = ( | ||||
|         await import(chrome.runtime.getURL("gui/scripts/alerts.js")) | ||||
|       ).default; | ||||
| 
 | ||||
|       // Apparently, JS doesn't have a native queueing system, but it might best work here.
 | ||||
|       class Queue { | ||||
|  | @ -67,8 +79,10 @@ export async function update(URL) { | |||
|           let filter_URL = filters.dequeue(); | ||||
| 
 | ||||
|           // Inform the user of download state.
 | ||||
|       console.log( | ||||
|         texts.read(`settings_filters_update_status`, null, [filter_URL]), | ||||
|           alerts.log( | ||||
|             texts.localized(`settings_filters_update_status`, null, [ | ||||
|               filter_URL, | ||||
|             ]), | ||||
|           ); | ||||
| 
 | ||||
|           // Create promise of downloading.
 | ||||
|  | @ -80,24 +94,29 @@ export async function update(URL) { | |||
|                 // Write the filter to storage.
 | ||||
|                 secretariat.write(["filters", filter_URL], result, -1); | ||||
|                 console.log( | ||||
|               texts.read(`settings_filters_update_status_complete`, null, [ | ||||
|                 filter_URL, | ||||
|               ]), | ||||
|                   texts.localized( | ||||
|                     `settings_filters_update_status_complete`, | ||||
|                     null, | ||||
|                     [filter_URL], | ||||
|                   ), | ||||
|                 ); | ||||
|               } | ||||
|             }) | ||||
|             .catch((error) => { | ||||
|               // Inform the user of the download failure.
 | ||||
|               console.log( | ||||
|             texts.read(`settings_filters_update_status_failure`, null, [ | ||||
|               error, | ||||
|               filter_URL, | ||||
|             ]), | ||||
|                 texts.localized( | ||||
|                   `settings_filters_update_status_failure`, | ||||
|                   null, | ||||
|                   [error, filter_URL], | ||||
|                 ), | ||||
|               ); | ||||
|             }); | ||||
|         } | ||||
|       } else { | ||||
|         // Inform the user of the download being unnecessary.
 | ||||
|     console.log(texts.read(`settings_filters_update_stop`)); | ||||
|         alerts.warn(texts.localized(`settings_filters_update_stop`)); | ||||
|       } | ||||
|     })(); | ||||
|   } | ||||
| } | ||||
|  |  | |||
|  | @ -27,11 +27,11 @@ export async function read(DATA_NAME, CLOUD = 0, PARAMETER_TEST = null) { | |||
|   } | ||||
| 
 | ||||
|   /* | ||||
| 		Find the data now. | ||||
|       Get all dataset. | ||||
| 
 | ||||
|       @param {number} SOURCE the data source | ||||
|   */ | ||||
|   function read_database(SOURCE = -1) { | ||||
|   async function read_database(SOURCE = -1) { | ||||
|     let data = {}; | ||||
|     let data_returned; | ||||
| 
 | ||||
|  | @ -263,7 +263,9 @@ export function forget(preference, subpreference, CLOUD = 0) { | |||
| 
 | ||||
|   (async () => { | ||||
|     // Import alerts module.
 | ||||
|     let alerts = await import(chrome.runtime.getURL(`gui/scripts/alerts.js`)); | ||||
|     let alerts = (await import(chrome.runtime.getURL(`gui/scripts/alerts.js`)))[ | ||||
|       `alerts` | ||||
|     ]; | ||||
| 
 | ||||
|     // Confirm the action.
 | ||||
|     let forget_action = alerts.confirm_action(); | ||||
|  | @ -388,7 +390,7 @@ Run a script when the browser storage has been changed. | |||
| 
 | ||||
| @param {object} reaction the function to run | ||||
| */ | ||||
| export async function observe(reaction) { | ||||
| export function observe(reaction) { | ||||
|   chrome.storage.onChanged.addListener((changes, namespace) => { | ||||
|     reaction(changes, namespace); | ||||
|   }); | ||||
|  |  | |||
|  | @ -7,8 +7,10 @@ Be sensitive to changes and update the state. | |||
|   let secretariat = await import( | ||||
|     chrome.runtime.getURL("scripts/secretariat.js") | ||||
|   ); | ||||
|   let filters = await import(chrome.runtime.getURL("scripts/filters.js")); | ||||
|   let reader = await import(chrome.runtime.getURL("scripts/reader.js")); | ||||
|   let filters = (await import(chrome.runtime.getURL("scripts/filters.js")))[ | ||||
|     `filters` | ||||
|   ]; | ||||
|   // let reader = await import(chrome.runtime.getURL("scripts/reader.js"));
 | ||||
| 
 | ||||
|   class watchman { | ||||
|     /* Check the current URL. | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue