Greasy Fork is available in English.

VK: Safe search

Returns a safe search for videos

< Feedback on VK: Safe search

Review: Good - script works

§
Posted: 01.10.2024

Proposed change to increase compatibility

Thanks for the script. I suggest using this code:

  window.fetch = exportFunction(new Proxy(window.fetch, {
    apply(...args) {
      const argumentsList = args.at(-1);
      const [url, options] = argumentsList;
      if (url.includes(target)) {
        argumentsList.at(-1).body += '&adult=1';
      }
      return Reflect.apply(...args);
    },
  }), unsafeWindow);

The only change was wrapping the function with exportFunction(new Proxy(...), unsafeWindow) so that it works properly in Firefox under some scenarios, for instance for those like me using FireMonkey extension instead of Violentmonkey. It will still be compatible compatible with Violentmonkey and Chrome, don't worry.

This is needed because Firefox has a security layer so that window in UserScripts context is different than window in page context (aka unsafeWindow). In this case, objects and functions defined in UserScript have restricted access in page context unless they are exported using exportFunction (for functions) or cloneInto (for objects).

askornotAuthor
§
Posted: 03.10.2024

Hi there, thank you for your suggestion. Implemented — v1.1.0.

Post reply

Sign in to post a reply.