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
| //// 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 |
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
| // consoleRestore.js -- Bookmarklet to bring back [something close to] the native console.log() etc. that have been replaced with a custom override (e.g. by Microsoft Teams April 2025) | |
| // https://gist.github.com/DarrenSem/48f853b2bca6d8334320affde48e225e | |
| // also adds `console.tableEach(...args)` = args.forEach( arg => console.table(arg) ) + `console.dirEach(...args)` | |
| // ^ purpose and examples here: https://gist.github.com/DarrenSem/a0109f95056c0c2512fe2abeb930bab2 | |
| // Silent: 398 char javascript:void function(){(()=>{const a="table",b=console,c=/\bnative code|^\(\.\.\.\w+\)=>\w+\.(forEach\(\w+=>\w+(\[\w+\])|\.assert)\(/;if(!c.test(b.log)){const d=c.test(b[a])?(...c)=>c.forEach(c=>b[a](c)):(...a)=>b.assert(!1,"\n",...a);["debug","error","info","log","warn"].forEach(a=>b[a]=d)}return b.tableEach=(...a)=>a.forEach(a=>b.table(a)),b.dirEach=(...a)=>a.forEach(a=>b.dir(a)),b})()}(); |
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
| // 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" |
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
| // 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; |
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
| // console.tableEach() - and also console.dirEach().js | |
| ///////////////////// | |
| console.tableEach = (...args) => args.forEach( arg => console.table(arg) ); | |
| // comparing native log() and table() functions vs. new custom function tableEach()... |
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
| // 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}` |
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
| // 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 = ( |
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
| // innerText.js bookmarklet for mobile (to show webpage text contents OR html) (including PARTIAL source of SELECTION) | |
| // https://gist.github.com/DarrenSem/7e1216bda80e6269ad53b43d90603158 | |
| // 26Jan2025 BUGFIX: now missing ONLY the "System instructions" section (one extra div layer was added SIGH) | |
| // 4784 char javascript:void function(){"use strict";const e="main div[data-collapsed",n="engine-select",t=`div.model-select>button>span`,d=[]._,i=((e,t,i,a,n,l,d,r)=>(t=new Date(e||Date()),[i,a,,n]=t.toLocaleTimeString().replace(/(a|p)\.(m)\./i,"$1$2").split(/\W/),[,,l,d]=t.toString().split(" "),r=t.toLocaleString().replace(/(\d+)-(\d+)-(\d+)/,"$2/$1/$3").split("/")[0].padStart(2,0),`${i}${a}${(n||"").toLowerCase()} ${d}-${r}-${l}`))(),a=`${""} ${i}`,l=top.document,r=location,u=(e,n)=>(n||l).querySelectorAll(e||null),o=(e,n)=>{const t=e?.[n?"value":x],i=t==d?d:n?t:t.replace(/\n{3,}/g,"\n\n\n").replace(/\n\n/g,"\n");return i},f=e=>e.trim(),s=e=>(e??"").replace(/\nSYNC$/i,"").replace(/ INSTRUCTIONS$/i,""),c=e=>(e?? |
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
| // ordinal.js - one-liner returns ordinal(1)="1st", (2)="2nd", (3)="3rd", (11)="11th", (21)="21st", (111)="111th", (121)="121st", etc. | |
| let ordinal = num => `${num}${[, "st", "nd", "rd"][ (num % 100 < 11 || num % 100 > 13) && (num % 10) ] || "th"}`; | |
| // ^ Final Answer. (below = the story of how I got there...) | |
| "use strict";// ordinal.js - one-liner returns ordinal(1)="1st", (2)="2nd", (3)="3rd", (11)="11th", (21)="21st", (111)="111th", (121)="121st", etc. | |
| let ordinal = num => `${num}${[, "st", "nd", "rd"][ (num % 100 < 11 || num % 100 > 13) && (num % 10) ] || "th"}`; |
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
| // 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) | |
| ) => { |
NewerOlder