Skip to content

Instantly share code, notes, and snippets.

@zbicin
Created June 28, 2018 09:40
Show Gist options
  • Select an option

  • Save zbicin/c215184c24f63368d4c27e2ffa9f6a9c to your computer and use it in GitHub Desktop.

Select an option

Save zbicin/c215184c24f63368d4c27e2ffa9f6a9c to your computer and use it in GitHub Desktop.
A userscript that adds copyJson method to the window object.
// ==UserScript==
// @name copyJson
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Stringifies given argument and copies it to the clipboard.
// @author @zbicin
// @match *://localhost*/*
// @grant none
// ==/UserScript==
(function() {
'use strict';
window.copyJson = (arg) => {
let json = JSON.stringify(arg, null, 2);
copy(json);
console.log('📋 Copied!')
};
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment