Created
May 27, 2020 15:02
-
-
Save alshakero/b6d1aa065fc08ac390f43a5a5c752411 to your computer and use it in GitHub Desktop.
Adds a context menu option to copy the text fragment URL
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 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