Created
September 21, 2016 16:14
-
-
Save nerdinand/2b6c982c26a65b903aefcc2a002fcb4e to your computer and use it in GitHub Desktop.
This file contains 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 isJiraPage() { | |
return window.location.href.indexOf("jira") > -1; | |
}; | |
function isJiraSprintPage() { | |
return window.location.href.indexOf("selectedIssue") > -1; | |
}; | |
function isBasecampPage() { | |
return window.location.href.indexOf("basecamp.com") > -1; | |
}; | |
function isTrelloPage() { | |
return window.location.href.indexOf("trello.com") > -1; | |
}; | |
function jiraTag() { | |
return isJiraSprintPage() ? document.querySelector('[data-field-id="issuekey"]').textContent : document.getElementById('key-val').textContent; | |
}; | |
function jiraTitle() { | |
return isJiraSprintPage() ? document.querySelector('[data-field-id="summary"]').textContent : document.getElementById('summary-val').textContent; | |
}; | |
function basecampTitle() { | |
return document.getElementsByClassName('todo show')[0].getElementsByClassName('content_for_perma')[0].textContent; | |
}; | |
function basecampTag() { | |
hrefParts = window.location.href.split('/'); | |
return hrefParts[hrefParts.length - 1]; | |
}; | |
function trelloTitle() { | |
return document.getElementsByClassName('mod-card-back-title')[0].value; | |
}; | |
function trelloTag() { | |
var idRegex = /c\/(.*)\/.*/; | |
var location = window.location.pathname; | |
var match = idRegex.exec(location); | |
return match[1]; | |
}; | |
function showPrompt(tag, title) { | |
prompt("Copy to clipboard: Ctrl+C, Enter", "#" + tag + " " + title); | |
}; | |
if (isJiraPage()) { | |
showPrompt(jiraTag(), jiraTitle()); | |
} else if (isBasecampPage()) { | |
showPrompt(basecampTag(), basecampTitle()); | |
} else if (isTrelloPage()) { | |
showPrompt(trelloTag(), trelloTitle()); | |
} else { | |
alert("This bookmarklet only supports Jira, Basecamp and Trello so far."); | |
} | |
void(0); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment