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 | |
| //// 13Jul2026 723am: start over from scratch, making it the simplest possible ONE-LINER... | |
| // 740am: 287 char javascript:(a=>{"0px"==getComputedStyle(a).maxWidth?a.style.removeProperty("max-width"):a.style.setProperty("max-width","0px","important");document.querySelector("button[aria-label=\"Close panel\"]")?.click()})([...document.querySelectorAll("[data-config-sidebar-side=\"left\"]")].pop()) | |
| // [FINAL ANSWER] 803am: 287 char javascript:((a,b,c="max-width")=>{(b=[...a.querySelectorAll("[data-config-sidebar-side=\"left\"]")].pop())&&("0px"==getComputedStyle(b).maxWidth?b.style.removeProperty(c):b.style.setProperty(c,"0px","important"));a.querySelector("button[aria-label=\"Close panel\"]")?.click()})(document) | |
| ( (doc, configurePane, MW = "max-width") => { |
| // DLasMD-console.save.js -- Download your JavaScript objects from your web browser's F12 Dev Tools console! (also Bookmarklet click defaults to saving prompt text data or body.innerText as `DL-[date].md`) [as of 15Jan2025 started using DLasMD-console.save.js] | |
| // this GIST url: https://gist.github.com/DarrenSem/444cc1c0539226a4902e7f265f23820f | |
| // DOWNLOAD contents as MarkDown.js, plus adds console.save() function | |
| // javascript:void function(){"use strict";let a=document,b=a._,c="",d="\n\n",e="innerText",f="application/octet-stream",g=URL,h=Date.now,i=Object.assign,j=b=>a.createElement(b),k=(c,f="onselectstart")=>{if(c=a=>a,a[f]&&a[f]!=c)return a[f]=c,alert("Text selecting was disabled!"+d+"Try again, it is now enabled...");let g=a.getSelection(),h=g&&"Range"===g.type&&g.getRangeAt(0),i=h&&j("div");return i&&(i.appendChild(h.cloneContents()),i[e])||b},l=(a,b,d,e)=>{e=g.createObjectURL(a=new Blob([a],{type:d||a?.type||f})),b??="DL-"+h()+".md";i(j("a"),{href:e},!0===b?{target:"_blank"}:{download:b||c}).clic |
| <!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) | |
| ) => { |