Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save alshakero/b6d1aa065fc08ac390f43a5a5c752411 to your computer and use it in GitHub Desktop.
Save alshakero/b6d1aa065fc08ac390f43a5a5c752411 to your computer and use it in GitHub Desktop.
Adds a context menu option to copy the text fragment URL
// ==UserScript==
// @name Copy text fragment URL
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Copies the text fragment URL for you
// @author Omar Alshaker (@alshakero)
// @include *
// @grant GM.setClipboard
// @run-at context-menu
// ==/UserScript==
(function() {
'use strict';
const url = new URL(window.location);
url.hash = ':~:text=' + document.getSelection();
GM.setClipboard(url.href);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment