Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.