Last active
September 9, 2021 00:16
-
-
Save tkdn/0aecc22deaa07c445fa74649060985ca to your computer and use it in GitHub Desktop.
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 出、出~行永久輪句取奴〜 | |
// @namespace https://gist.github.com/tkdn/0aecc22deaa07c445fa74649060985ca#file-github-get-permalink-user-js | |
// @updateURL https://gist.github.com/tkdn/0aecc22deaa07c445fa74649060985ca/raw/b0d2fdd90a63583df2c70a98a1e0703a13b492db/github-get-permalink.user.js | |
// @downloadURL https://gist.github.com/tkdn/0aecc22deaa07c445fa74649060985ca/raw/b0d2fdd90a63583df2c70a98a1e0703a13b492db/github-get-permalink.user.js | |
// @version 0.1 | |
// @description GitHub のリンク押下時にコピーします | |
// @author tkdn <tkdnation@gmail.com> | |
// @match https://github.com/*/* | |
// @grant none | |
// ==/UserScript== | |
(() => { | |
console.log('出、出~行永久輪句取奴〜') | |
setup() | |
document.addEventListener('pjax:end', setup) | |
function setup() { | |
const $elems = document.querySelectorAll("[data-line-number]") | |
$elems.forEach(elem => { | |
elem.addEventListener('click', async () => { | |
const $lineAction = document.querySelector('.js-file-line-actions') | |
const $permLinkCopy = document.querySelector('#js-copy-permalink') | |
$lineAction.click() | |
await sleep(500) | |
$permLinkCopy.click() | |
}) | |
}) | |
} | |
function sleep(ms) { | |
return new Promise(r => setTimeout(r, ms)) | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment