Last active
July 1, 2024 07:21
-
-
Save lalibi/8069ba479069e1b2071b1fb779e4bfdc to your computer and use it in GitHub Desktop.
Copy Site Reference - Tampermonkey script
This file contains 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 Site Reference | |
// @namespace https://lalibi.org/ | |
// @version 0.4.1 | |
// @description Copy title and shorten URL from site | |
// @author lalibi | |
// @match *://*/* | |
// @updateURL https://gist.githubusercontent.com/lalibi/8069ba479069e1b2071b1fb779e4bfdc/raw/ | |
// @downloadURL https://gist.githubusercontent.com/lalibi/8069ba479069e1b2071b1fb779e4bfdc/raw/ | |
// @icon https://www.google.com/s2/favicons?sz=64&domain=tinyurl.com | |
// @grant GM_setClipboard | |
// @grant GM_notification | |
// @grant GM.xmlHttpRequest | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
document.addEventListener('keydown', (e) => { | |
// Use https://keycode.info to get keys | |
if (e.altKey && e.shiftKey && e.keyCode == 82) { // Alt+Shift+R | |
const url = encodeURIComponent(window.location.href); | |
GM.xmlHttpRequest({ | |
method: "GET", | |
url: `https://tinyurl.com/api-create.php?url=${url}`, | |
onload: (response) => { | |
var text = `${document.title} - ${response.responseText}`; | |
GM_setClipboard(text); | |
GM_notification("Reference copied!", text); // alert(`Reference copied!\n\n${text}`); | |
} | |
}); | |
} | |
}, true); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment