Last active
July 11, 2022 12:14
-
-
Save andfinally/453d93543815587991378222c20c10fa to your computer and use it in GitHub Desktop.
Bookmarklet to copy document title and URL
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
// One-line version: create a bookmark with this content | |
// javascript:( function() { const jsIssueTitle = document.querySelector( '.js-issue-title' ); const title = jsIssueTitle ? jsIssueTitle.textContent : document.title; const blob = new Blob( [ `<a href="${ document.location.href }">${ title }</a>` ], { type: "text/html" } ); const clipboardItem = new ClipboardItem( { [ "text/html" ]: blob } ); navigator.clipboard.write( [ clipboardItem ] ); } )(); | |
// Long version - only included here for legibility use the one-line version prefixed with `javascript:` | |
( function() { | |
// Get GitHub issue/PR title | |
const jsIssueTitle = document.querySelector( '.js-issue-title' ); | |
const title = jsIssueTitle ? jsIssueTitle.textContent : document.title; | |
const blob = new Blob( [ `<a href="${ document.location.href }">${ title }</a>` ], { type: "text/html" } ); | |
const clipboardItem = new ClipboardItem( { [ "text/html" ]: blob } ); | |
navigator.clipboard.write( [ clipboardItem ] ); | |
} )(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment