TL;DR
- base URL is:
https://gist.github.com/search
- use
q=user:your_username+your_search_term
- include
s=stars
ando=desc
to sort by "most stars" (most stars on top, least stars at the end). - include
s=stars
ando=asc
to sort by "least stars" (least stars on top, most stars at the end). - same goes for
s=forks
. - same goes for
s=updated
. - if you do not include
s=
, it will sort by "best match" .
for example: https://gist.github.com/search?&s=stars&o=desc&q=user%3Aeladkarako+ffmpeg
will search for my gists for ffmpeg
, sorting them so the ones with the most stars will be on top.
making a bookmarklet so the search term will be dynamic (using JavaScript's native inputbox - prompt
) is very easy,
use this "template", change the username and optionally the default value for the prompt
, currently ffmpeg
:
javascript:top.location.assign("https://gist.github.com/search?&s=stars&o=desc&q=user%3Aeladkarako+"+encodeURIComponent(prompt("ffmpeg")));
make sure to properly escape the search term using encodeURIComponent
,
- the current version will search the exact term, replacing whitespace with
%20
,
a better way is to also replace any whitespace with+
using something like thisencodeURIComponent(prompt("ffmpeg")).replace(/%20/gm,"+")
or
encodeURIComponent(prompt("ffmpeg").replace(/\s+/gm,"+")).replace(/%2B/gmi,"+")
make sure to do not include whitespaces,
(this is still a URL, and it will get encoded to a pretty ugly %20
).
note:
a best practice for a bookmarklet is to always explicitly specify the top frame location
,
instead of just calling location
, or window.location
,
although it should probably work anyway.
keep in-mind a bookmarklet
is kind of a protocol,
old browsers supported it,
but newer browsers, as well as websites with Content-Security-Policy
header with a strict javascript limitation,
might break bookmarklets, luckily it works fine in GitHub...
finally,
add a new bookmark to your bookmarks toolbar,
give it a nice title, I usually add some emoji on bookmarklets.
you can use Win+. on Windows to open the emoji toolbar,
or copy one from https://eladkarako.github.io/umoji/index.html
note: all the ones from there are having an additional \uFE0E
which makes them use the black/white variation of the emoji,
you can paste it into a notepad2/++ and place your cursor at the end, and press one time on the BackSpace to remove that character,
it will get the default colorful variation..