Bookmarklets

From Rest of What I Know
Revision as of 19:49, 28 October 2024 by Roshan (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Bookmarklets in general are a bit out of fashion, but they're still quite useful. I'll add ones I like here.

Convert a Tweet into Wikitext Template[edit]

javascript:void(function(){const e=document.querySelector('article[tabindex="-1"]');if(!e){console.log('No tweet found on this page');return}const t=e.querySelector('[data-testid="User-Name"]'),n=t.getElementsByTagName('span'),a=n[0]?.textContent||%27%27,r=t.querySelector(%27div[dir="ltr"]%27)?.textContent.replace(%27@%27,%27%27)||%27%27,l=Array.from(e.querySelectorAll(%27[data-testid="tweetText"]%27)),s=l.map(e=>e.textContent).join(%27\n%27).trim(),i=window.location.pathname.split(%27/%27).pop(),o=e.querySelector(%27time%27),d=o?new Date(o.getAttribute(%27datetime%27)):null,c=d?d.toLocaleDateString(%27en-US%27,{month:%27short%27,day:%27numeric%27,year:%27numeric%27}):%27%27;let m=%27{{Tweet\n| name = %27+a+%27\n| username = %27+r+%27\n| text = %27+s+%27\n| date = %27+c+%27\n| ID = %27+i+%27\n}}%27;console.log(m)})();

Using an LLM you can transform the code into something readable and then encode it back into a Bookmarklet if you'd like.