Last active
April 18, 2023 21:13
-
-
Save shotasenga/95f23b84f1e3f4f71f104931800b50fa to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==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