Skip to content

Instantly share code, notes, and snippets.

@adunkman
Created May 5, 2015 14:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adunkman/8179bb406e035452d927 to your computer and use it in GitHub Desktop.
Save adunkman/8179bb406e035452d927 to your computer and use it in GitHub Desktop.
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