Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
// ==UserScript==
// @name CodePen from Snippet
// @namespace
// @version 0.3
// @description adds a button to SO snippets to forward the snippet data to CodePen
// @author Paul Roub <>
// @match*
// @grant none
// ==/UserScript==
function setUpButtons() {
function() {
var btn = $(this);
var ctr = btn.closest('.snippet-code');
var html = ctr.children('.snippet-code-html').text();
var js = ctr.children('.snippet-code-js').text();
var css = ctr.children('.snippet-code-css').text();
var datastr = JSON.stringify(
'html': html,
'js': js,
'css': css,
'description': "Source: " + document.location.href,
'title': "Snippet from " + document.title
var form = $('<form action="" method="POST" target="_blank" style="display: inline-block">');
$('<input type="hidden" name="data">').
$('<input class="cpSnippet" type="submit" value="Copy snippet to CodePen">').
attr('style', btn.attr('style')).
setTimeout( setUpButtons, 1000 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.