Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@subtleGradient
subtleGradient / command.js
Last active August 9, 2021 14:45 — forked from jonathantneal/command.js
Executable JavaScript Modules
":" /*prettier-ignore*/ //#;exec /usr/bin/env node --input-type=module - "$@" < "$0"
import process from "process";
const { argv } = process;
console.log(argv);
WEBVTT|(?<=^[A-Z][^.?!]+$)\n|^\d+.+align:center$| +|<[^>]+>|$\n\n
#!/usr/bin/env osascript -l JavaScript
// macOS JXA JavaScript for Automation
// eslint-disable-next-line @typescript-eslint/no-unused-vars
function run(argv) {
Application('Safari').activate();
const { Safari } = Application('System Events').applicationProcesses;
const { Develop } = Safari.menuBars[0].menuBarItems;
@subtleGradient
subtleGradient / Safari iOS Debug.jxa.js
Created April 29, 2021 21:26
Safari iOS Debug.jxa.js
#!/usr/bin/env osascript -l JavaScript
// macOS JXA JavaScript for Automation
// eslint-disable-next-line @typescript-eslint/no-unused-vars
function run(argv) {
Application('Safari').activate();
const { Safari } = Application('System Events').applicationProcesses;
const { Develop } = Safari.menuBars[0].menuBarItems;
<!doctype html>
<meta charset=utf-8>
<title>inspector</title>
<style>
html{background:#333}
</style>
<!-- <script src="lib/monkey keycodes.js"></script> -->
<script>
@subtleGradient
subtleGradient / monkeydancer.sh
Created November 24, 2020 17:15
monkeydancer.sh
#!/usr/bin/env bash -l
# set -x
echo "Usage: $0 -s $SERIAL < /path/to/script.monkey" 1>&2
echo " More info: https://github.com/android/platform_development/blob/master/cmds/monkey/README.NETWORK.txt" 1>&2
echo " Example: https://github.com/android/platform_development/blob/master/cmds/monkey/example_script.txt" 1>&2
echo "" 1>&2
echo " type 'Hello World'" 1>&2
echo " press KEYCODE_ENTER" 1>&2
echo "" 1>&2
@subtleGradient
subtleGradient / ignoreEscapeKey.js
Last active November 18, 2020 17:48
Ignore ESC macOS
// ==UserScript==
// @name Keep Full Screen
// @namespace http://superuser.com/q/315949
// @description Prevents Escape key from leaving full screen.
// @include http://*
// @include https://*
// ==/UserScript==
document.documentElement.onkeydown = (event) => {
if (event.keyCode == 27) event.preventDefault();
console.log("Keep Full Screen");
@subtleGradient
subtleGradient / importUMD.js
Last active November 6, 2020 20:59
import(UMD)
export default async (url, module = {exports:{}}) =>
(Function('module', 'exports', await (await fetch(url)).text()).call(module, module, module.exports), module).exports
// ==UserScript==
// @name JW Image focus
// @namespace https://gist.github.com/subtleGradient/663a61bf1e9f04b00dd7943950128dcb
// @version 1.0.1
// @description Block 3rd party related images when doing Google image searches using site:jw.org
// @author Thomas Aylott
// @match https://www.google.com/search?*
// @grant none
// ==/UserScript==
@subtleGradient
subtleGradient / setWindow.cypress.js
Last active September 29, 2023 20:23
Test multiple popup windows and iframes with Cypress, including window.open
/*
The MIT License
Copyright 2020 Thomas Aylott <oblivious@subtlegradient.com>
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF O