Skip to content

Instantly share code, notes, and snippets.

@jr-codes
Created August 19, 2016 21:32
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jr-codes/2a3b0fd3eb3610555bddc382340e5dfa to your computer and use it in GitHub Desktop.
Save jr-codes/2a3b0fd3eb3610555bddc382340e5dfa to your computer and use it in GitHub Desktop.
Userscript for opening JSON in the Chrome JSON Viewer extension
// ==UserScript==
// @name Open JSON
// @version 1.0.0
// @description Opens JSON in a json-viewer window
// @match http://*/*
// @match https://*/*
// ==/UserScript==
const exec = fn => {
const script = document.createElement('script');
script.textContent = `(${fn})()`;
document.head.appendChild(script);
};
const main = () => {
window.openJSON = obj => {
const url = 'chrome-extension://gbmdgpbipfallnflgajpaliibnhdgobh/pages/omnibox.html';
const json = JSON.stringify(obj);
window.open(`${url}?json=${encodeURIComponent(json)}`, '_blank');
};
};
exec(main);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment