Copy current url

Copy current website url by pressing yy

目前為 2025-01-02 提交的版本,檢視 最新版本

// ==UserScript==
// @name         Copy current url
// @namespace    https://gf.qytechs.cn/en/users/901750-gooseob
// @version      1.0.2
// @description  Copy current website url by pressing yy
// @author       GooseOb
// @license      MIT
// @match        *://*/*
// ==/UserScript==

(function () {
  let isPressed = false;
  const isInput = (element) =>
    element.tagName === "input" ||
    element.tagName === "textarea" ||
    element.isContentEditable;

  document.addEventListener("keyup", (e) => {
    if (e.key === "y" && !isInput(e.target)) {
      if (isPressed) {
        navigator.clipboard.writeText(window.location.href);
        isPressed = false;
      } else {
        isPressed = true;
        setTimeout(() => {
          isPressed = false;
        }, 1000);
      }
    }
  });
})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址