dralletje / Windowed

Chrome extension to keep fullscreen windows contained
167 stars 16 forks source link

[feature request] add option to automatically go into a specific mode on every website #51

Open Wowfunhappy opened 2 years ago

Wowfunhappy commented 2 years ago

Hi, this extension is awesome! I have a shameless feature request. :3

It's already possible to tell this extension to always use e.g. in-window fullscreen mode on a specific website, such as youtube.com. However, I'd really like to change the default mode for every website I visit. Is this feasible?

In my specific case, I always want to use Windowed mode because when I really do want to fullscreen something, I'd rather use OS X's native fullscreen feature so the content appears in its own Mission Control space.

Thank you!

thesobercoder commented 1 year ago

@dralletje @Gitoffthelawn Would really appreciate this feature. Thanks for all your hard work!

Wowfunhappy commented 1 year ago

Alright, well I made a hack that works for me. On line 281 of content.js, I added:

mode = "windowed";

And now the extension always defaults to "windowed" mode. If you want it to default to something else, add mode = "fullscreen"; or mode = "in-window";, respectively.

If you click the extension icon to set a different behavior for a particular host, that will still work. Note that I'm using Chromium 114 and version 31 of the extension.


In case the line numbers change in the future, you want to find this block of code, in the let create_popup function:

    if (pip === true && video_element != null) {
      video_element.requestPictureInPicture();
      onEscapePress(() => {
        // @ts-ignore
        document.exitPictureInPicture();
      });
      return "PICTURE-IN-PICTURE";
    }

    if (mode === "fullscreen" || mode === "windowed" || mode === "in-window") {
      if (mode === "fullscreen") {
        let element = document.querySelector(`[data-${fullscreen_select}]`);
        disable_selector(element, fullscreen_select);
        element.requestFullscreen();
        return "FULLSCREEN";
      }
      if (mode === "windowed") {
        await go_into_fullscreen();
        return "WINDOWED";
      }
      if (mode === "in-window") {
        await go_in_window();
        return "IN-WINDOW";
      }
    }

and change it to:

    if (pip === true && video_element != null) {
      video_element.requestPictureInPicture();
      onEscapePress(() => {
        // @ts-ignore
        document.exitPictureInPicture();
      });
      return "PICTURE-IN-PICTURE";
    }
    mode = "windowed"; //WOWFUNHAPPY HACK TO DEFAULT TO WINDOWED MODE!
    if (mode === "fullscreen" || mode === "windowed" || mode === "in-window") {
      if (mode === "fullscreen") {
        let element = document.querySelector(`[data-${fullscreen_select}]`);
        disable_selector(element, fullscreen_select);
        element.requestFullscreen();
        return "FULLSCREEN";
      }
      if (mode === "windowed") {
        await go_into_fullscreen();
        return "WINDOWED";
      }
      if (mode === "in-window") {
        await go_in_window();
        return "IN-WINDOW";
      }
    }