Last active
May 25, 2017 16:20
-
-
Save cs278/8007456 to your computer and use it in GitHub Desktop.
GitHub PR tag toggle boorkmarklet
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(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]'); |
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(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]"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
They changed it again,
#partial-discussion-header