Skip to content

Instantly share code, notes, and snippets.

@Xiphe
Last active May 23, 2017 07:13
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 Xiphe/2b7f6afe7067b0464f99bb563361d050 to your computer and use it in GitHub Desktop.
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

install

  1. Copy bookmarklet-remove-unreachable-refs.js
  2. Add new Bookmark in your browser
  3. Instead of url, use contents of bookmarklet-remove-unreachable-refs.js
  4. Enjoy
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()})})})();
(() => {
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();
}
});
});
})();
@HerrBertling
Copy link

❤️ 👍 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment