Pop-up window

Open current page or links to a standalone window without UI elements

이 스크립트를 설치하려면 Tampermonkey, Greasemonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey와 같은 확장 프로그램을 설치해야 합니다.

이 스크립트를 설치하려면 Tampermonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey 또는 Userscripts와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 유저 스크립트 관리자 확장 프로그램이 필요합니다.

(이미 유저 스크립트 관리자가 설치되어 있습니다. 설치를 진행합니다!)

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

(이미 유저 스타일 관리자가 설치되어 있습니다. 설치를 진행합니다!)

// ==UserScript==
// @name        Pop-up window
// @namespace   Open current page or links to a standalone window without UI elements
// @match       *://*/*
// @grant       none
// @version     Alpha-v1
// @description Open current page or links to a standalone window without UI elements
// @author      JesusisLord
// @license     MIT
// ==/UserScript==
(function() {
  "use strict";

  function createStandaloneWindow(url, targetWindow = window) {
    const win = targetWindow.open(url, "_blank", "width=800,height=600,toolbar=no,location=no,menubar=no,scrollbars=no");
    win.focus();
    return win;
  }

  const openLinkHandler = (event) => {
    // Prevent default link behavior (needed):
    event.preventDefault();
    const url = event.target.href || event.target.parentNode.href;
    createStandaloneWindow(url);
  };

  const movePageHandler = () => {
    createStandaloneWindow(window.location.href);
  };

  document.addEventListener("click", (event) => {
    if (event.ctrlKey) {
      if (event.target.nodeName === "A") {
        openLinkHandler(event);
      } else if (!event.target.isContentEditable && !event.target.matches('input, textarea, button, select')) {
        event.preventDefault(); // Optional: Prevent default actions on empty space
        movePageHandler();
      }
    }
  });
})();