VK: Safe search

Returns a safe search for videos

< VK: Safe searchについてのフィードバック

レート:良 – スクリプトは良好に動作する

§
投稿日: 2024/10/01

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).

askornot作者
§
投稿日: 2024/10/03

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

返信を投稿

返信を投稿するにはログインしてください。