Skip to content

Instantly share code, notes, and snippets.

@avioli
Last active October 25, 2016 23:26
Show Gist options
  • Save avioli/aef6cac52bfba7bdeeba490b67517f33 to your computer and use it in GitHub Desktop.
Save avioli/aef6cac52bfba7bdeeba490b67517f33 to your computer and use it in GitHub Desktop.
Harvest Redirect - Overview to Timesheets

Harvest Redirect - Overview to Timesheets

A Google Chrome extension

How to install

  1. Open Google Chrome and navigate to chrome://extensions.

  2. Enable Developer mode

  3. Select Load unpacked extension...

    3.1. Navigate to the directory with manifest.json and script.js and hit Select/Open/Whatever

  4. Visit https://<TEAM>.harvestapp.com/overview and you will be redirected to /time

Configure

If you want to configure this extension open manifest.json and edit content_scripts.matches or harvest_redirect_config.redirect_to to suit your needs.

If you have the extension already loaded - visit chrome://extensions and hit Reload under the extension.

Hide the tooblar icon

Right click the icon and tab Hide in Chrome Menu.

{
"manifest_version": 2,
"name": "Harvest Redirect - Overview to Timesheets",
"description": "This extension redirects from the overview to the timesheets page",
"version": "1.0",
"content_scripts": [
{
"matches": ["https://*.harvestapp.com/overview"],
"js": ["script.js"],
"harvest_redirect_config": {
"redirect_to": "/time"
}
}
],
"permissions": [
"activeTab"
]
}
// NOTE(evo): Get config from manifest
var _config = (chrome.runtime
.getManifest().content_scripts
.filter(function(s) { return !!s.harvest_redirect_config })[0] || {})
.harvest_redirect_config;
// NOTE(evo): Check if config has correct value
if (_config && typeof _config.redirect_to === 'string' && _config.redirect_to.length > 0) {
var actualCode = '(' + function(config) {
// NOTE(evo): Actually redirect
window.location.href = config.redirect_to
} + ')(' + JSON.stringify(_config) + ');';
var script = document.createElement('script');
script.textContent = actualCode;
(document.head || document.documentElement).appendChild(script);
script.remove();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment