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%; |
| //// Update: Go here instead, works as a Bookmarklet or as an included file via <script src="...">. (I also added a printButton.js) | |
| //// https://github.com/DarrenSem/markdown/blob/master/static/resizer.js | |
| // MarkDownLivePreview.com-resizer.js -- bookmarklet to add 'Toggle Editor' (and also width-resizer) - instead of waiting for repo update that might use something like this <script src="./static/resizer.js"></script> | |
| // (09Sep2025 938am) 2209 char javascript:void function(){"use strict";const e="minedit",t="extra-button",i="mouse",n="width",r=document,o=e=>r.getElementById(e),s=(e,t)=>Object.assign(r.createElement(e||"div"),t),d=(e,...t)=>e.addEventListener(...t),l=(e,...t)=>e.removeEventListener(...t),a=e=>e.preventDefault(),c=setTimeout,g=40,m=window,f=(e="resizer-css")=>{if(o(e))return;const i=["\nbody {\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#resizer {\n width: 4px;\n background-color: green;\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) | |
| ) => { |