pull down to refresh

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.
700 sats \ 1 reply \ @kristapsk 10h
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)
reply
0 sats \ 0 replies \ @klk OP 10h
Good point! I'll use that one too.
reply
I know this is a legit thing, but it feels unsafe, like I'm going to get XSS'd or something
reply
121 sats \ 1 reply \ @klk OP 20 May
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.
reply
I agree! This is neat, thank you for sharing it.
reply
10 sats \ 5 replies \ @k00b 20 May
Doesn’t work in brave sadly
reply
100 sats \ 4 replies \ @klk OP 20 May
It does!
  1. Copy the code from this post.
  2. Create a new bookmark for this page with Ctrl+d.
  3. Edit the bookmark URL to the code, and the title to whatever you want.
  4. Open any website.
  5. Click on the bookmark.
  6. Profit.
reply
57 sats \ 3 replies \ @ek 20 May
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!
reply
1154 sats \ 2 replies \ @klk OP 20 May
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.
reply
83 sats \ 1 reply \ @ek 23h
🤯
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.
reply
57 sats \ 0 replies \ @klk OP 23h
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.
48 sats \ 0 replies \ @sox 10h
Awesome! I wanted this in the past and also talked about it in one of our meetings but it never materialized, thanks!
reply