Skip to content

Instantly share code, notes, and snippets.

@glenjamin
Last active February 26, 2025 09:23

Revisions

  1. glenjamin revised this gist Feb 26, 2025. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion bookmarklet.md
    Original file line number Diff line number Diff line change
    @@ -9,7 +9,7 @@ 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);})();])
    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.
  2. glenjamin revised this gist Nov 15, 2024. 1 changed file with 12 additions and 2 deletions.
    14 changes: 12 additions & 2 deletions bookmarklet.md
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,15 @@
    # Honeycomb env-switching bookmarklet

    Save the following bookmarklet as a bookmark
    This will toggle between the `staging` and `production` environments by default. Adjust the naming if that isn't what yours are called.

    <a href="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);})();]">Honeycomb Environment Switcher</a>
    ## 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.
  3. glenjamin created this gist Nov 15, 2024.
    5 changes: 5 additions & 0 deletions bookmarklet.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,5 @@
    # Honeycomb env-switching bookmarklet

    Save the following bookmarklet as a bookmark

    <a href="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);})();]">Honeycomb Environment Switcher</a>
    18 changes: 18 additions & 0 deletions full.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,18 @@
    (() => {
    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);
    })();