Explorar el Código

ref: unimportant stuff

Sv443 hace 1 mes
padre
commit
fee2b20a22
Se han modificado 3 ficheros con 3 adiciones y 4 borrados
  1. 1 1
      docs.md
  2. 1 2
      lib/DataStore.ts
  3. 1 1
      lib/dom.ts

+ 1 - 1
docs.md

@@ -541,7 +541,7 @@ Tries to use `GM.openInTab` to open the given URL in a new tab, or as a fallback
 If `background` is set to true, the tab will be opened in the background. Leave `undefined` to use the browser's default behavior.  
 If `additionalProps` is set and `GM.openInTab` is not available, the given properties will be added or overwritten on the created anchor element.  
   
-⚠️ Needs the `@grant GM.openInTab` directive, otherwise only the fallback behavior will be used and the warning below is extra important:  
+⚠️ You should add the `@grant GM.openInTab` directive, otherwise only the fallback behavior will be used and the warning below is extra important:  
 ⚠️ For the fallback to work, this function needs to be run in response to a user interaction event, else the browser might reject it.  
   
 <details><summary><b>Example - click to view</b></summary>

+ 1 - 2
lib/DataStore.ts

@@ -59,6 +59,7 @@ export type DataStoreOptions<TData> = Prettify<
     storageMethod?: "GM" | "localStorage" | "sessionStorage";
   }
   & (
+    // make sure that encodeData and decodeData are *both* either defined or undefined
     | {
       /**
        * Function to use to encode the data prior to saving it in persistent storage.  
@@ -338,8 +339,6 @@ export class DataStore<TData extends object = object> {
     return JSON.parse(decRes ?? data) as TData;
   }
 
-  //#region misc
-
   /** Copies a JSON-compatible object and loses all its internal references in the process */
   protected deepCopy<T>(obj: T): T {
     return JSON.parse(JSON.stringify(obj));

+ 1 - 1
lib/dom.ts

@@ -111,7 +111,7 @@ export function interceptEvent<
   predicate: (event: TPredicateEvt) => boolean = () => true,
 ): void {
   // @ts-ignore
-  if((eventObject === window || eventObject === getUnsafeWindow()) && GM?.info?.scriptHandler && GM.info.scriptHandler === "FireMonkey")
+  if(GM?.info?.scriptHandler && GM.info.scriptHandler === "FireMonkey" && (eventObject === window || eventObject === getUnsafeWindow()))
     throw new Error("Intercepting window events is not supported on FireMonkey due to the isolated context the userscript runs in.");
 
   // default is 25 on FF so this should hopefully be more than enough