Skip to content

Instantly share code, notes, and snippets.

@adunkman adunkman/README.md
Created May 5, 2015

Embed
What would you like to do?
Platform bookmarklet
(function () {
var github = function () {
var parts;
if (parts = window.location.pathname.match(/^\/([^\/]+\/[^\/]+)\/(?:issues|pull)\/(\d+)/)) {
var repo = parts[1];
var issue = parts[2];
var url = window.location.href;
var name = document.querySelector(".js-issue-title").innerText;
window.open([
"https://platform.harvestapp.com/platform/timer",
"?format=platform",
"&app_name=GitHub",
"&service=github.com",
"&base_url=" + encodeURIComponent(url),
"&external_group_id=" + encodeURIComponent(repo),
"&external_group_name=" + encodeURIComponent(repo),
"&external_item_id=" + encodeURIComponent(issue),
"&external_item_name=" + encodeURIComponent("#" + issue + ": " + name)
].join(""));
return true;
}
return false;
};
var zendesk = function () {
var parts;
if (parts = window.location.pathname.match(/^\/agent\/tickets\/(\d+)/)) {
var ticket = parts[1];
var url = window.location.href;
var name = document.querySelector(".ticket.section .pane_header input:not([disabled])").value;
window.open([
"https://platform.harvestapp.com/platform/timer",
"?format=platform",
"&app_name=Zendesk",
"&service=zendesk.com",
"&base_url=" + encodeURIComponent(url),
"&external_group_id=0",
"&external_item_id=" + encodeURIComponent(ticket),
"&external_item_name=" + encodeURIComponent("#" + ticket + ": " + name)
].join(""));
return true;
}
return false;
};
return github() || zendesk();
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.