A bookmarklet is a small JavaScript script that you can store as a bookmark and run over any site.
This is a bookmarklet to post whatever page you are visiting to ~bitcoin on SN:
javascript:window.location="https://stacker.news/~bitcoin/post?type=link&url="+encodeURIComponent(document.location)+"&title="+encodeURIComponent(document.title)You can save it as a bookmark (right click on this post's link) and adapt it for other territories.
Inspired by the one from HN: https://news.ycombinator.com/bookmarklet.html
Can use this instead, then you will be able to choose territory before posting, no need to separate ones for different territories.
javascript:window.location="https://stacker.news/post?type=link&url="+encodeURIComponent(document.location)+"&title="+encodeURIComponent(document.title)I'm using a mix of that one with opening in a new window:
javascript:(function(){window.open("https://stacker.news/post?type=link&url="+encodeURIComponent(document.location)+"&title="+encodeURIComponent(document.title),"_blank")})();Good point! I'll use that one too.
Doesn’t work in brave sadly
It does!
Yeah, did work for me on Linux and Brave, very cool!
But I noticed it doesn't work when you open the bookmark in a new tab. URL will then be
about:blank.But it's still really cool for how simple it is!
I've got you:
javascript:(function(){window.open("https://stacker.news/~bitcoin/post?type=link&url="+encodeURIComponent(document.location)+"&title="+encodeURIComponent(document.title),"_blank")})();This one will instead open the submission in a new tab. So you won't open the bookmark for a new tab, but the submission page will.
🤯
why didn't I think of that haha
edit: btw, if you don't include ~bitcoin in the URL, it will still work but the user can select a territory. Might make more sense.
I'm sure there's a lot more that can be done with this concept of bookmarklets. Automating submissions was the obvious one, and very useful for me.
Awesome! I wanted this in the past and also talked about it in one of our meetings but it never materialized, thanks!
I know this is a legit thing, but it feels unsafe, like I'm going to get XSS'd or something
Running JavaScript code found on the internet has that fame xD
In this case is short and simple enough to understand what it does even without much JS knowledge.
I agree! This is neat, thank you for sharing it.