bokub / nopaste

:clipboard: Client-side paste service
https://nopaste.boris.sh
MIT License
372 stars 133 forks source link

Add shorten url with v.gd #17

Closed abhishekmj303 closed 1 year ago

abhishekmj303 commented 1 year ago

I use this feature very often, so thought of opening a PR. I totally agree if you think this goes against its philosophy

bokub commented 1 year ago

Hello !

What you can do if you do this manually very often, is to copy & paste the following code in a browser bookmark:

javascript:void(generateLink("url"),interval=setInterval((()=>{if(!byId("copy").classList.contains("hidden")){clearInterval(interval),window.shortenUrlCallback=l=>{document.body.removeChild(e),l.shorturl&&(byId("copy-link").value=l.shorturl)};let e=document.createElement("script");e.src="https://v.gd/create.php?format=json&callback=shortenUrlCallback&url="+encodeURIComponent(byId("copy-link").value),document.body.appendChild(e)}}),10))

Then, just click on the bookmark to generate a link and shorten it with one single click!

image

abhishekmj303 commented 1 year ago

Thanks for the bookmark code. Didn't thought we could run js like that with bookmark.

Anyway, I'll be maintaining fork since I use it with my friends who also need this functionality. Deployed on: nopaste303.vercel.app

bokub commented 1 year ago

Great idea ! I'll close this PR if you don't mind