Last active
January 17, 2020 09:41
-
-
Save plugn/d9f28a9fe1622ac5fb142677e242b11a to your computer and use it in GitHub Desktop.
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
| function copyMRDev() { | |
| const confirmMR = () => { | |
| const txt = document.querySelector('.mr-source-target .normal > strong').textContent.replace(/[\s]+/g, ' ').trim() | |
| const url = location.href.replace(/\/diffs\/?/, '') | |
| const msg = txt.replace('Request to merge ', 'MR\n').replace('into', '->') | |
| return [msg, url].join('\n') | |
| } | |
| const writeToClipboard = (txt) => { | |
| return navigator.clipboard.writeText(txt) | |
| } | |
| const txt = confirmMR() | |
| writeToClipboard(txt).then(() => console.log('Copied :\n', txt)) | |
| } | |
| function copyMRTelegram() { | |
| const confirmMR = () => { | |
| const node = document.querySelector('.detail-page-description.content-block .js-task-list-field') || document.querySelector('.detail-page-description.content-block .title') | |
| const txt = node.textContent.replace(/[\s]+/g, ' ').trim() | |
| const url = location.href.replace(/\/diffs\/?/, '') | |
| return [txt, url].join('\n') | |
| } | |
| const writeToClipboard = (txt) => { | |
| return navigator.clipboard.writeText(txt) | |
| } | |
| const txt = confirmMR() | |
| writeToClipboard(txt).then(() => console.log('Copied :\n', txt)) | |
| } | |
| function mkBookmarklet(fn) { | |
| return 'javascript:('+fn.toString().replace(/[\r\n]+/gm, ';')+')()' | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment