- Copy
bookmarklet-remove-unreachable-refs.js
- Add new Bookmark in your browser
- Instead of url, use contents of
bookmarklet-remove-unreachable-refs.js
- Enjoy
Last active
May 23, 2017 07:13
-
-
Save Xiphe/2b7f6afe7067b0464f99bb563361d050 to your computer and use it in GitHub Desktop.
simple script that gets rid of unreachable references in issues and pull requests
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
javascript: (function(){var a=null;document.querySelectorAll('a.js-selected-navigation-item').forEach(function(b){'Code'===b.innerText.trim()&&(a=b.href)}),document.querySelectorAll('.discussion-item-ref').forEach(function(b){var c=b.querySelector('.commit-meta a');c&&window.fetch(a+'/branch_commits/'+c.innerText).then(function(d){return d.text()}).then(function(d){d.trim().length||b.remove()})})})(); |
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
(() => { | |
var baseUrl = null; | |
document.querySelectorAll('a.js-selected-navigation-item').forEach((elm) => { | |
if (elm.innerText.trim() === 'Code') { | |
baseUrl = elm.href; | |
} | |
}); | |
document.querySelectorAll('.discussion-item-ref').forEach((refNode) => { | |
const commitMetaNode = refNode.querySelector('.commit-meta a'); | |
if (!commitMetaNode) { | |
return; | |
} | |
window.fetch(`${baseUrl}/branch_commits/${commitMetaNode.innerText}`) | |
.then((r) => r.text()) | |
.then((r) => { | |
if (!r.trim().length) { | |
refNode.remove(); | |
} | |
}); | |
}); | |
})(); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
❤️ 👍 🚀