Skip to content

Instantly share code, notes, and snippets.

@kellenmace
Created October 4, 2018 20:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kellenmace/3fbd2f579147a96dd9554484a8693a74 to your computer and use it in GitHub Desktop.
Save kellenmace/3fbd2f579147a96dd9554484a8693a74 to your computer and use it in GitHub Desktop.
sandbox.onlinephpfunctions.com Tampermonkey Script
// ==UserScript==
// @name PHP Sandbox
// @version 0.1
// @description Customize PHP Sandbox styles
// @author Kellen Mace
// @match http://sandbox.onlinephpfunctions.com/
// @grant none
// ==/UserScript==
(function() {
'use strict';
const darkGray = '#414141';
const styles = `
body {
background-color: ${darkGray};
color: #fff;
}
h2, p, #topBar, #headerTop, #contentWrapperTop, #menu, .breadCrumbs, .hr, #comments {
display: none;
}
#content {
background-color: ${darkGray};
width: auto;
}
table {
padding-top: 20px;
padding-bottom: 20px;
}
input[type=submit] {
padding: 10px;
font-size: 16px;
}
input[type=button] {
padding: 10px;
font-size: 16px;
margin-left: 5px;
}
.result {
border: none;
padding: 0;
background: inherit;
}
.result textarea {
margin-top: 5px;
width: 100%;
height: 500px;
}
`;
// Append styles to the <head> as a new <style> tag.
const css = document.createElement('style');
css.type = 'text/css';
if (css.styleSheet) {
css.styleSheet.cssText = styles;
} else {
css.appendChild(document.createTextNode(styles));
}
document.getElementsByTagName('head')[0].appendChild(css);
// <b> tag styles.
const bTags = document.getElementsByTagName('b');
bTags[0].style.display = 'none';
bTags[1].innerText = 'PHP Version';
// Remove "Notes" heading.
const h3s = document.getElementsByTagName('h3');
h3s[1].style.display = 'none';
// Remove all <br>s.
[...document.getElementById('onlineFunction').querySelectorAll('br')].map(br => br.parentNode.removeChild(br) );
// Must be set in JS to override element styles.
const editor = document.getElementById('aceeditor');
editor.style.height = '500px';
editor.style.width = '100%';
document.title = 'PHP Sandbox';
const setFavicon = imageUrl => {
const link = document.querySelector("link[rel*='icon']") || document.createElement('link');
link.type = 'image/x-icon';
link.rel = 'shortcut icon';
link.href = imageUrl;
document.getElementsByTagName('head')[0].appendChild(link);
};
setFavicon( 'https://www.shareicon.net/download/2015/09/25/107049_html.ico' );
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment