This file contains hidden or 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== |
This file contains hidden or 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 { store as blockEditorStore } from '@wordpress/block-editor' | |
import { createBlock } from '@wordpress/blocks' | |
import { useSelect, useDispatch } from '@wordpress/data' | |
import { useEffect } from '@wordpress/element' | |
export const BlockReplacer = ({ clientId, blockType }) => { | |
const block = useSelect( | |
(select) => select(blockEditorStore).getBlock(clientId ?? ''), | |
[clientId], | |
) |
This file contains hidden or 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
// You need to set up `window.myPlugin.nonce` and `window.myPlugin.wpRoot` in PHP | |
/* | |
\wp_add_inline_script('script-name', | |
'window.myPlugin = ' . wp_json_encode([ | |
'wpRoot' => \esc_url_raw(\rest_url()), | |
'nonce' => \wp_create_nonce('wp_rest') | |
]); | |
); | |
*/ |
This file contains hidden or 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 Download AlpineJs version from Tailwind UI | |
// @namespace kevinbatdorf | |
// @version 1.0 | |
// @description When you press copy, it will download an html file containing the script code and alpine HTML | |
// @author https://twitter.com/kevinbatdorf | |
// @match https://tailwindui.com/components/* | |
// @grant none | |
// ==/UserScript== |
This file contains hidden or 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 apiFetch from '@wordpress/api-fetch' | |
// This is also set up to clone fields from an existing image. | |
// Just remove imageToClone and supply the missing fields on your own. | |
export const uploadImage = async (image: ImageData, imageToClone: WpImage): Promise<WpImage | undefined> => { | |
const canvas = document.createElement('canvas') | |
canvas.width = image.width | |
canvas.height = image.height | |
const ctx = canvas.getContext('2d') | |
if (!ctx) return |
This file contains hidden or 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
// Go to the old.reddit.com site | |
for (const dltbtn of document.querySelectorAll('[data-event-action="delete"]')) { | |
dltbtn.click(); | |
await new Promise(requestAnimationFrame); | |
dltbtn.closest('form')?.querySelector('.yes')?.click() | |
await new Promise(r => setTimeout(r, 300)); | |
} | |
// No longer works | |
// for (const dotdotdot of document.querySelectorAll('[aria-label*=more ]')) { |
This file contains hidden or 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
export const isValidJson = (str) => { | |
try { | |
JSON.parse(str) | |
return true | |
} catch (e) { | |
return false | |
} | |
} |
This file contains hidden or 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 | |
// add this to functions.php or as an mu-plugin (if needed) | |
add_action('wp_enqueue_scripts', function () { | |
wp_dequeue_script('pb-accordion-blocks-frontend-script'); | |
wp_dequeue_style('pb-accordion-blocks-style'); | |
}); |
This file contains hidden or 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 | |
add_action('admin_footer', function () { ?> | |
<script> | |
window.addEventListener('load', () => { | |
window.setTimeout(() => { | |
if (wp.data && wp.data.select('core/edit-post').isFeatureActive('welcomeGuide')) { | |
wp.data.dispatch('core/edit-post').toggleFeature('welcomeGuide'); | |
} | |
}) |
This file contains hidden or 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
[ | |
/** | |
* Panels | |
**/ | |
{ | |
"key": "cmd+k cmd+e", | |
"command": "workbench.view.explorer" | |
}, | |
{ | |
"key": "cmd+k cmd+g", |