Skip to content

Instantly share code, notes, and snippets.

@shotasenga
Last active April 18, 2023 21:13
Show Gist options
  • Save shotasenga/95f23b84f1e3f4f71f104931800b50fa to your computer and use it in GitHub Desktop.
Save shotasenga/95f23b84f1e3f4f71f104931800b50fa to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name Copy page info to the clipboard
// @namespace https://shotasenga.com/
// @version 1.0.2
// @description CTRL+C to copy page info
// @author [email protected]
// @match *://*/*
// @grant GM_setClipboard
// @grant GM_notification
// ==/UserScript==
(function () {
"use strict";
document.addEventListener("keydown", (e) => {
if (e.key === "c" && e.metaKey && window.getSelection().type !== 'Range') {
copyPageInfo();
GM_notification({
title: "GM_notification",
text: "Page info is copied!",
});
}
});
function copyPageInfo() {
const title = document.title;
const url = location.href;
GM_setClipboard([title, url].join("\n"), "text");
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment