Skip to content

Instantly share code, notes, and snippets.

@filipenevola
Last active April 17, 2018 03:37
Show Gist options
  • Select an option

  • Save filipenevola/7f7e0276d8b91d88ebc625e3f6152057 to your computer and use it in GitHub Desktop.

Select an option

Save filipenevola/7f7e0276d8b91d88ebc625e3f6152057 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name Pivotal message for commit
// @namespace http://pathable.com/
// @version 1.0
// @description This is use for get the link from story for commit name
// @match https://www.pivotaltracker.com/*/projects/*
// @require http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js
// @grant GM_setClipboard
// ==/UserScript==
commitCopier = function() {
function exec(fn) {
var script = document.createElement('script');
script.setAttribute("type", "application/javascript");
script.textContent = '(' + fn + ')();';
document.body.appendChild(script); // run the script
document.body.removeChild(script); // clean up
}
// setup styles
var style = document.createElement('style');
style.innerHTML = ".prompt-box { position: absolute; border: 5px gray solid; padding: 10px 30px; border-radius: 5px; width: 500px; min-height: 300px; z-index: 99; background: white; text-align: left; "
+ "font-size: 12px; font-weight: normal; z-index: 1001; }"
+ ".commit_link_btn {float: left; width: 20px; height: 20px; border: 1px solid #FDA35D; border-radius: 5px; background: #FDA35D; margin-right: 10px; text-align: center; padding-top: 5px;"
+ "font-size: 12px; font-weight: bold; color: white; cursor: pointer; position: absolute; z-index: 1000; right: 5%; top: 30px;}"
+ ".commit_link_btn:hover { border-color: white; border-width: 3px; }"
document.body.appendChild(style);
// add the button
var commitLinkBtn = document.createElement("div");
commitLinkBtn.className = "commit_link_btn";
commitLinkBtn.textContent = "#";
$("body").append(commitLinkBtn);
// when clicking
commitLinkBtn.onclick = function() {
var ancs = $("a.selector.selected");
ancs.map(function() {
var story = $(this).closest(".story");
var id = story.attr("class").match(/story_\d+/).toString().replace('story_', '');
var link = 'https://www.pivotaltracker.com/story/show/' + id;
var storyName = story.find("span.story_name").text();
GM_setClipboard('[#' + id.toString() + '] ' + storyName + '\n- \n' + link);
});
};
};
unsafeWindow.addEventListener("load", commitCopier);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment