Pop-up window

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

目前为 2024-01-12 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name Pop-up window
  3. // @namespace Open current page or links to a standalone window without UI elements
  4. // @match *://*/*
  5. // @grant none
  6. // @version Alpha-v1
  7. // @description Open current page or links to a standalone window without UI elements
  8. // @author JesusisLord
  9. // @license MIT
  10. // ==/UserScript==
  11. (function() {
  12. "use strict";
  13.  
  14. function createStandaloneWindow(url, targetWindow = window) {
  15. const win = targetWindow.open(url, "_blank", "width=800,height=600,toolbar=no,location=no,menubar=no,scrollbars=no");
  16. win.focus();
  17. return win;
  18. }
  19.  
  20. const openLinkHandler = (event) => {
  21. // Prevent default link behavior (needed):
  22. event.preventDefault();
  23. const url = event.target.href || event.target.parentNode.href;
  24. createStandaloneWindow(url);
  25. };
  26.  
  27. const movePageHandler = () => {
  28. createStandaloneWindow(window.location.href);
  29. };
  30.  
  31. document.addEventListener("click", (event) => {
  32. if (event.ctrlKey) {
  33. if (event.target.nodeName === "A") {
  34. openLinkHandler(event);
  35. } else if (!event.target.isContentEditable && !event.target.matches('input, textarea, button, select')) {
  36. event.preventDefault(); // Optional: Prevent default actions on empty space
  37. movePageHandler();
  38. }
  39. }
  40. });
  41. })();