shift+c to copy title link
当前为
// ==UserScript==
// @name copy title
// @description shift+c to copy title link
// @name:en copy title
// @description:en shift+c to copy title link
// @name:ko 페이지 제목 복사
// @description:ko shift+c로 페이지 제목 링크 복사
// @namespace https://greasyfork.org/ko/users/713014-nanikit
// @version 201218
// @author nanikit
// @match *://*/*
// @grant none
// ==/UserScript==
'use strict';
const copyTitleHandler = (event) => {
const titleText = document.title;
const anchor = document.createElement('a');
anchor.href = document.location.href;
anchor.innerText = titleText;
const titleHtml = anchor.outerHTML;
event.clipboardData.setData("text/html", titleHtml);
event.clipboardData.setData("text/plain", titleText);
event.preventDefault();
}
const copyTitle = () => {
document.addEventListener("copy", copyTitleHandler);
document.execCommand("copy");
document.removeEventListener("copy", copyTitleHandler);
};
window.addEventListener('keydown', (event) => {
if (event.shiftKey && event.key === 'C') {
copyTitle();
}
});