Bookmarklets: Difference between revisions
From Rest of What I Know
Created page with "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 == <syntaxhighlight lang=js> 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..." |
mNo edit summary |
||
Line 8: | Line 8: | ||
[https://chatgpt.com/share/671fea77-1614-800c-9d82-541aeb946d52 Using an LLM] you can transform the code into something readable and then encode it back into a Bookmarklet if you'd like. | [https://chatgpt.com/share/671fea77-1614-800c-9d82-541aeb946d52 Using an LLM] you can transform the code into something readable and then encode it back into a Bookmarklet if you'd like. | ||
[[Category:Tips]] |
Latest revision as of 19:49, 28 October 2024
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.