A proof-of-concept of a more different way of using the Harvest Platform.
Created
May 5, 2015 14:56
-
-
Save adunkman/8179bb406e035452d927 to your computer and use it in GitHub Desktop.
Platform bookmarklet
This file contains hidden or 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(){var e=function(){var e;if(e=window.location.pathname.match(/^\/([^\/]+\/[^\/]+)\/(?:issues|pull)\/(\d+)/)){var n=e[1],t=e[2],o=window.location.href,r=document.querySelector(".js-issue-title").innerText;return window.open(["https://platform.harvestapp.com/platform/timer","?format=platform","&app_name=GitHub","&service=github.com","&base_url="+encodeURIComponent(o),"&external_group_id="+encodeURIComponent(n),"&external_group_name="+encodeURIComponent(n),"&external_item_id="+encodeURIComponent(t),"&external_item_name="+encodeURIComponent("#"+t+": "+r)].join("")),!0}return!1},n=function(){var e;if(e=window.location.pathname.match(/^\/agent\/tickets\/(\d+)/)){var n=e[1],t=window.location.href,o=document.querySelector(".ticket.section .pane_header input:not([disabled])").value;return window.open(["https://platform.harvestapp.com/platform/timer","?format=platform","&app_name=Zendesk","&service=zendesk.com","&base_url="+encodeURIComponent(t),"&external_group_id=0","&external_item_id="+encodeURIComponent(n),"&external_item_name="+encodeURIComponent("#"+n+": "+o)].join("")),!0}return!1};return e()||n()}(); |
This file contains hidden or 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
(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