Skip to content

Instantly share code, notes, and snippets.

@glenjamin
Last active February 26, 2025 09:23
Show Gist options
  • Save glenjamin/186888638a0044eea11a05a51ad546ba to your computer and use it in GitHub Desktop.
Save glenjamin/186888638a0044eea11a05a51ad546ba to your computer and use it in GitHub Desktop.
Honeycomb E&S Environment toggle bookmarklet

Honeycomb env-switching bookmarklet

This will toggle between the staging and production environments by default. Adjust the naming if that isn't what yours are called.

Setup

Create a bookmark named "Honeycomb Environment Switcher"

Set the target URL as the following, which is the content from full.js with newlines and indents removed.

javascript:(() => {const f = (tag, text) =>Array.from(document.querySelectorAll(tag)).find((el) => el.textContent === text,);f('button', 'Share').click();setTimeout(() => {f('button', 'Get Template Link').click();setTimeout(() => {const h = f('h4', 'Query Template Link');let url = h.closest('section').querySelector('textarea').value;const swap = ['/production/', '/staging/'];if (url.includes('/staging/')) swap.reverse();url = url.replace(...swap);location.href = url;}, 10);}, 10);})();

When you click this bookmark from a query page, you'll be switched to the same query but run against the other environment.

(() => {
const f = (tag, text) =>
Array.from(document.querySelectorAll(tag)).find(
(el) => el.textContent === text,
);
f('button', 'Share').click();
setTimeout(() => {
f('button', 'Get Template Link').click();
setTimeout(() => {
const h = f('h4', 'Query Template Link');
let url = h.closest('section').querySelector('textarea').value;
const swap = ['/production/', '/staging/'];
if (url.includes('/staging/')) swap.reverse();
url = url.replace(...swap);
location.href = url;
}, 10);
}, 10);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment