Skip to content

Instantly share code, notes, and snippets.

@adunkman
Created June 19, 2015 20:21
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/ec122ce50d41d8975358 to your computer and use it in GitHub Desktop.
Save adunkman/ec122ce50d41d8975358 to your computer and use it in GitHub Desktop.
Hacking the Harvest Platform
(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_item_id=" + encodeURIComponent(ticket),
"&external_item_name=" + encodeURIComponent("#" + ticket + ": " + name)
].join(""));
return true;
}
return false;
};
var bugsnag = function () {
if (window.location.hostname != "bugsnag.com") {
return false;
}
var parts;
if (parts = window.location.pathname.match(/^\/harvest\/([^\/]+)\/errors\/([a-z0-9]{24})/)) {
var project = parts[1];
var error = parts[2]
var url = window.location.href;
var h1 = document.querySelector("#main-content header h1");
var name = h1.querySelector(".error-class").innerText + ": " + h1.querySelector(".error-location").innerText;
window.open([
"https://platform.harvestapp.com/platform/timer",
"?format=platform",
"&app_name=Bugsnag",
"&service=bugsnag.com",
"&base_url=" + encodeURIComponent(url),
"&external_group_id=" + encodeURIComponent(project),
"&external_item_id=" + encodeURIComponent(error),
"&external_item_name=" + encodeURIComponent(name)
].join(""));
return true;
}
return false;
};
return github() || zendesk() || bugsnag();
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment