Skip to content

Instantly share code, notes, and snippets.

@mreq
Created February 11, 2021 09:08
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 mreq/6fda6c196f184077297583706ef094be to your computer and use it in GitHub Desktop.
Save mreq/6fda6c196f184077297583706ef094be to your computer and use it in GitHub Desktop.
Copies number and issue title to clipboard on click
// ==UserScript==
// @name github issue title
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author You
// @match https://github.com/*
// @grant GM_setClipboard
// ==/UserScript==
(function() {
'use strict';
document.addEventListener('click', (e) => {
let title
if (e.target.classList.contains('gh-header-title') && e.target.firstElementChild.classList.contains('js-issue-title')) {
title = e.target.firstElementChild
} else if (e.target.classList.contains('js-issue-title')) {
title = e.target
} else {
return
}
title.parentElement.style.backgroundColor = '#c2e5f9'
setTimeout(() => { title.parentElement.style.backgroundColor = '' }, 300)
let number = (title.nextElementSibling && title.nextElementSibling.classList.contains('f1-light')) ? `${title.nextElementSibling.innerText}: ` : ''
GM_setClipboard(`${number}${title.innerText}`)
})
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment