Skip to content

Instantly share code, notes, and snippets.

@cs278
Last active May 25, 2017 16:20
Show Gist options
  • Save cs278/8007456 to your computer and use it in GitHub Desktop.
Save cs278/8007456 to your computer and use it in GitHub Desktop.
GitHub PR tag toggle boorkmarklet
(function(tag, domain) {
domain = domain || 'github.com';
// No tag supplied.
if (!tag) return;
// Bail out if not the correct domain.
if (domain !== window.location.hostname) return;
// String.trimLeft() method is required.
if (!String.prototype.trimLeft) return;
document.querySelectorAll('#partial-discussion-header').forEach(function ($pr) {
var $title = $pr.querySelector('[name="issue[title]"]');
var $submit = $title.form.querySelector('button[type=submit]');
var title = $title.value;
if (title.length === 0) {
return;
}
if ($title.value.indexOf(tag) === 0) {
title = title.substring(tag.length).trimLeft();
} else {
title = tag + ' ' + title;
}
if (title !== $title.value) {
$title.value = title;
$submit.click();
}
});
})('[WIP]');
(function(c,d){c&&(d||"github.com")===window.location.hostname&&String.prototype.trimLeft&&document.querySelectorAll("#partial-discussion-header").forEach(function(a){a=a.querySelector('[name="issue[title]"]');var d=a.form.querySelector("button[type=submit]"),b=a.value;0!==b.length&&(b=0===a.value.indexOf(c)?b.substring(c.length).trimLeft():c+" "+b,b!==a.value&&(a.value=b,d.click()))})})("[WIP]");
@le6o
Copy link

le6o commented Aug 1, 2014

They changed it again, #partial-discussion-header

@cs278
Copy link
Author

cs278 commented Aug 4, 2014

Thanks @le6o

@cs278
Copy link
Author

cs278 commented Apr 20, 2016

@le6o Just fixed this if you are still using it.

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