Przeglądaj źródła

fix da721f03: unsafeWindow must be exposed in grant mode

tophf 2 dni temu
rodzic
commit
cf7216aa05

+ 1 - 1
src/_locales/en/messages.yml

@@ -330,7 +330,7 @@ hintGrantless:
   message: |-
     A sandboxed script cannot change these global properties: $1.
     To fix the script either add `@grant none` to disable the sandbox,
-    or add `@grant unsafeWindow` and use `unsafeWindow` instead of `window`.
+    or use `unsafeWindow` instead of `window`.
 hintInputURL:
   description: Hint for a prompt box to input URL of a user script.
   message: 'Input URL:'

+ 1 - 0
src/injected/web/gm-api-wrapper.js

@@ -46,6 +46,7 @@ export function makeGmApiWrapper(script) {
       async: false,
     }, script, COPY_SCRIPT_PROPS);
     assign(gm, componentUtils);
+    gm.unsafeWindow = global;
     for (let name of grant) {
       let fn, fnGm4, gmName, gm4name;
       if (name::slice(0, 3) === 'GM.' && (gm4name = name::slice(3)) && (fnGm4 = GM4_ALIAS[gm4name])

+ 0 - 1
src/injected/web/gm-api.js

@@ -192,7 +192,6 @@ export const GM_API = {
   },
   // using the native console.log so the output has a clickable link to the caller's source
   GM_log: logging.log,
-  unsafeWindow: global,
 };
 
 function webAddElement(parent, tag, attrs) {