This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const addDollarBash = () => Array.from(document.querySelectorAll("div[class*='code-block-pro']")) | |
// check if direct child has a span with text "Bash" | |
.filter((b) => b.querySelector(':scope > span')?.textContent === 'Bash') | |
// add language-bash class to the parent | |
.forEach((b) => b.classList.add('language-bash')); | |
document.addEventListener("DOMContentLoaded", addDollarBash); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const parseEvent = (eventData) => { | |
const lines = eventData.split('\n'); | |
const eventType = ( | |
lines.find((line) => line.startsWith('event:')) || 'event:message' | |
) | |
.slice(6) | |
.trim(); | |
const eventDataExtracted = lines | |
.filter((line) => line.startsWith('data:')) | |
.map((line) => line.slice(5).trim()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { registerPlugin } from '@wordpress/plugins'; | |
import { | |
PanelBody, | |
BaseControl, | |
createSlotFill, | |
Button, | |
} from '@wordpress/components'; | |
import { __ } from '@wordpress/i18n'; | |
// CodeBlockPro.Sidebar.Start |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const handleTabSizeAdjustToggle = () => { | |
const blocks = Array.from( | |
document.querySelectorAll( | |
'.wp-block-kevinbatdorf-code-block-pro:not(.cbp-tab-size-loaded)', | |
), | |
); | |
blocks.forEach((block) => { | |
block.classList.add('cbp-tab-size-loaded'); | |
const button = document.createElement('span'); | |
button.setAttribute('role', 'button'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const blocks = Array.from( | |
document.querySelectorAll('.wp-block-kevinbatdorf-code-block-pro'), | |
); | |
const copyText = 'Click anywhere to copy'; | |
const copiedText = 'Copied!'; | |
blocks && | |
blocks.forEach((block) => { | |
if (!block.querySelector('span[data-code]')) return | |
block.insertAdjacentHTML( | |
'beforeend', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
div.wp-block-kevinbatdorf-code-block-pro:not(.code-block-pro-editor) pre code { | |
overflow-wrap: break-word !important; | |
/* In some cases you may need the max() */ | |
padding: 0 2rem 0 max(var(--cbp-line-number-width), 2rem) !important; | |
white-space: pre-wrap !important; | |
word-break: break-word !important; | |
} | |
div.wp-block-kevinbatdorf-code-block-pro:not(.code-block-pro-editor) pre code .line { | |
min-height: 1.625rem; | |
position: static !important; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#topicBar, | |
.time { | |
display: none; | |
} | |
.sender { | |
width: 6rem; | |
border-right: 1px solid #333; | |
background: transparent; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
defined( 'ABSPATH' ) or die; | |
namespace Kevin; | |
class Router extends \WP_REST_Controller | |
{ | |
protected static $instance = null; | |
public function getHandler($namespace, $endpoint, $callback) { | |
\register_rest_route( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
defined('ABSPATH') or die; | |
add_action('admin_init', 'my_namespace_register_settings'); | |
add_action('rest_api_init', 'my_namespace_register_settings'); | |
function my_namespace_register_settings() { | |
register_setting('my_namespace_settings', 'my_namespace_settings', [ | |
'type' => 'object', | |
'show_in_rest' => [ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name MDN fixes | |
// @namespace kevinbatdorf | |
// @version 0.1 | |
// @description Make MDN great again | |
// @author You | |
// @match https://developer.mozilla.org/* | |
// @icon https://www.google.com/s2/favicons?sz=64&domain=mozilla.org | |
// @grant none | |
// ==/UserScript== |
NewerOlder