You are an expert at JavaScript and C#
. You must format indents using 2 spaces, and you must wrap strings using doublequotes " instead of '.
Let's think step by step.
// above.js (PARENT element, levels = #) + next.js (SIBLING element, levels = #) helper functions instead of foo.parentElement.parentElement.parentElement etc. | |
// https://gist.github.com/DarrenSem/4d37711fb71a484b6ed2356c60e3c94a | |
// PARENT element: ... | |
const above = (startingElement, levels = 1) => { | |
let el = startingElement; | |
while ( levels-- && (el = el?.parentElement) ); | |
return el || null; |
// SwapBranches(GitHub compare).js -- Bookmarklet for toggling/reversing order of [base: targetBranch] <-- [compare: sourceBranch] | |
// 287 char: javascript:void function(){const a=a=>{const b=a?.href??a??"",c=/(\/compare\/)([^.\/]+)\.\.\.([^.\/]+)/;return c.test(b)?b.replace(c,(a,b,c,d)=>`${b}${d}...${c}`):b},b=(b=location)=>{const c=b?.href??b??"",d=a(c);return c!=d&&((b?.href?b:{}).href=d)};console.clear(),console.log(b())}(); | |
const getSwappedGitHubBranches = (url) => { | |
const href = url?.href ?? url ?? ""; | |
const pattern = /(\/compare\/)([^.\/]+)\.\.\.([^.\/]+)/; | |
const replacer = (_, prefix, branch1, branch2) => `${prefix}${branch2}...${branch1}` |
// width.js - Bookmarklet for OpenAI playground to fix maxWidth of "Configure" panel (due to latest layout update); add as browser Favorite then click to toggle visibility | |
// https://gist.github.com/DarrenSem/0d9da09fc5a7b95abcc0df95d65b02c7 | |
// 05Apr2025 234pm: will now FIRST close "Configure" if already opened as slide-in panel version (could have BOTH versions visible!) | |
// 2016 char javascript:void function(){const a=null,b="innerText",c=(b,c=1)=>{let d=b;for(;c--&&(d=d?.parentElement););return d||a},d=(a,b)=>a.test(b??""),e=()=>{const a=document.querySelectorAll("button > span > span + span.sr-only"),c=Array.from(a).filter((a,c)=>{const e=a[b],f=d(/Configure/,e);return console.log({isTextConfigure:f,text:e,el:a,i:c}),f});return console.log({collConfigureButtons:c,collButtonSpans:a,selButtonSpans:"button > span > span + span.sr-only"}),c},f=e=>{let f,g,h=a;const i=c(e,1),j=i.querySelectorAll("button");for(f of j)if(g=f.dataset,console.log({dataset:g,elButton:f}),!d(/\S/,f[b])&&"secondary"==g?.color&&"md" |
// DLasMD - DOWNLOAD contents as MarkDown.js | |
// old as of 15Jan2025; start using DLasMD-console.save.js | |
// 27Dec2024 1053am NEW promptData rules (Blank or Empty or =FILENAME.EXT defaults to document.body.innerText) | |
// 477 char javascript:void function(){let a=document,b=(b,c=`DL-${+new Date}.md`,d="octet-stream")=>{let e=URL.createObjectURL(new Blob([b],{type:d}));Object.assign(a.createElement("a"),{href:e,download:c}).click(),URL.revokeObjectURL(e)},c=prompt("Enter data to download...\n\n(Blank or Empty or =FILENAME.EXT defaults to document.body.innerText)")?.trim();if(null!=c){let d=c.startsWith("=")&&c.slice(1);b(c.length&&!d?c:a.body.innerText,d?`${d}${d.includes(".")?"":".md"}`:void 0)}}(); | |
let doc=document; | |
let saveDataAsFilenameMime = ( |
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<title>ChatGPT Playground (starting up)</title> | |
<style> | |
.byline { | |
font-family: Verdana; | |
font-size: 80%; |
// MarkDownLivePreview.com-resizer.js -- bookmarklet to add [Toggle Editor] (and also horizontal resizer) - instead of waiting for repo update using <script defer src="resizer.js"></script> | |
// 1710 char javascript:void function(){if(!document.getElementById("resizer")){let a=location,b="markdownlivepreview.com";if(a.hostname!=b)a.href="https://"+b;else{let a=document,b=b=>a.getElementById(b),c=b("container"),d=b("edit"),e=b("preview"),f=!1,g=b("copy-button");a.head.insertAdjacentElement("afterBegin",Object.assign(a.createElement("style"),{id:"resizer.css",innerHTML:"\n body {\n margin: 0;\n height: 100vh;\n overflow: hidden;\n }\n #container {\n display: flex;\n width: 100%;\n height: 100%;\n overflow: hidden;\n }\n #edit, #preview {\n flex-grow: 1;\n overflow: auto;\n transition: flex 0.3s ease;\n }\n #resizer {\n width: 4px;\n background-color: green;\n cursor: col-resize;\n flex-shrink: 0;\n }\n #toggle-button {\n margin-left: 16px;\n }\n .shrunk {\n |
// ytSubs.js (SEE DISCLAIMER) - via @DarrenSem https://gist.github.com/DarrenSem (22Mar2024) | |
// YouTube subtitles - English (auto-generated) CC (closed captions) | |
// Usage: node ytSubs.js videoIdOrUrl | |
// or Web browser BOOKMARKLET (contents open in a new window) | |
// ES6 clickable Bookmarklet = 3923 chars: | |
//javascript:void function(){"use strict";var e=String.fromCharCode;const n=!1,d=globalThis,{process:i}=d,t=console,u=async(e,n,d="text")=>fetch(e,n).then(e=>e[d]()),a=e=>{try{e=(e||"")+"";const n=e.match(/"captionTracks":.*"isTranslatable"\:.*?}]/),d=JSON.parse(`{${(n||[""])[0]}}`).captionTracks||[],i=d.map(e=>{const n=e.name;return[l(n.simpleText||n.runs&&n.runs[0].text),e.baseUrl+"&fmt=json3"]});return i}catch(n){}},r=e=>{e=new Date(e);let n=e.getDate();return isNaN(n)?null:`${(n+"").padStart(2,"0")}${e.toLocaleString("default",{month:"short"})}${e.getFullYear()}`},f=e=>{e="string"!=typeof e&&e?new URL(e):{href:e||""};const n=e&&e.href.trim()||"",d=n.replace(/(https?:\/\/)?\/*(.+?)\/?$/,"https://$2"),i=d |
"use strict"; | |
const { URL } = require("."); | |
const inputs = [ | |
"https://\u0000y", | |
"https://x/\u0000y", | |
"https://x/?\u0000y", | |
"https://x/?#\u0000y" | |
]; |
// store.js ALL-IN-ONE function: () = dump Storage, (keyOrNS, value OTHER THAN undefined) = return value after setting it, (keyOrNS) = return value - UNDEFINED if missing, (null, keyOrNS) = removeItem(keyOrNS) then return keyOrNS | |
// let store=(k,d,s=localStorage,z=s.getItem(k))=>null==k?null==d?s:(s.removeItem(d),d):void 0===d?null==z?void 0:JSON.parse(z):(s.setItem(k,JSON.stringify(d,0,"\t")),d); | |
let store = ( | |
keyOrNS, | |
data, | |
storage = [localStorage, sessionStorage][0], | |
_z = storage.getItem(keyOrNS) | |
) => { |