Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Slightly off-topic but this is an important PSA.

Firefox keyword search has one little known killer feature: You can combine it with data URIs and JavaScript to run small "command line snippets" stored in your bookmarks from your browser bar.

To get started, create a keyword search from any form (like the search bar on duckduckgo.com) and edit the URL of the entry in the bookmark manager to point to

  data:text/html,<script>alert("%s")</script>
instead.

What you can do with this is (fortunately) limited by cross-origin restrictions but there are some useful applications. For example, I use this snippet

  data:text/html,<script>i="%s";firstSep=i.indexOf(" ");if(firstSep==-1)firstSep=i.length;subreddit=i.substr(0,firstSep);searchTerm=i.substr(firstSep+1);location=`https://old.reddit.com/r/${encodeURIComponent(subreddit)}${(searchTerm!=null&&searchTerm.replace(/\s/,"").length>0)?`/search?q=${encodeURIComponent(searchTerm)}&restrict_sr=1`:""}`</script>
as a nice shortcut to Reddit ("<keyword> <subreddit>" to jump to a Subreddit, "<keyword> <subreddit> <search string>" to search within a Subreddit).

You can also insert content directly into the document which opens the possibility for instant marquee

  data:text/html,<marquee>%s</marquee>


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: