Skip to content

Instantly share code, notes, and snippets.

@lalibi
Last active November 20, 2023 08:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lalibi/8069ba479069e1b2071b1fb779e4bfdc to your computer and use it in GitHub Desktop.
Save lalibi/8069ba479069e1b2071b1fb779e4bfdc to your computer and use it in GitHub Desktop.
Copy Site Reference - Tampermonkey script
// ==UserScript==
// @name Copy Site Reference
// @namespace https://lalibi.org/
// @version 0.4.0
// @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) {
const url = 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