Shallow Thoughts : tags : bookmarklets
Akkana's Musings on Open Source Computing and Technology, Science, and Nature.
Mon, 06 Apr 2015
The local bird community has gotten me using
eBird.
It's sort of social networking for birders -- you can report sightings,
keep track of what birds you've seen where, and see what other people
are seeing in your area.
The only problem is the user interface for that last part. The data is
all there, but asking a question like "Where in this county have people
seen broad-tailed hummingbirds so far this spring?" is a lengthy
process, involving clicking through many screens and typing the
county name (not even a zip code -- you have to type the name).
If you want some region smaller than the county, good luck.
I found myself wanting that so often that I wrote an entry page for it.
My Bird Maps page
is meant to be used as a smart bookmark (also known as bookmarklets
or keyword bookmarks),
so you can type birdmap hummingbird or birdmap golden eagle
in your location bar as a quick way of searching for a species.
It reads the bird you've typed in, and looks through a list of
species, and if there's only one bird that matches, it takes you
straight to the eBird map to show you where people have reported
the bird so far this year.
If there's more than one match -- for instance, for birdmap hummingbird
or birdmap sparrow -- it will show you a list of possible matches,
and you can click on one to go to the map.
Like every Javascript project, it was both fun and annoying to write.
Though the hardest part wasn't programming; it was getting a list of
the nonstandard 4-letter bird codes eBird uses. I had to scrape one
of their HTML pages for that.
But it was worth it: I'm finding the page quite useful.
How to make a smart bookmark
I think all the major browsers offer smart bookmarks now, but I can
only give details for Firefox.
But
here's a page about using them in Chrome.
Firefox has made it increasingly difficult with every release to make
smart bookmarks. There are a few extensions, such as "Add Bookmark Here",
which make it a little easier. But without any extensions installed,
here's how you do it in Firefox 36:
First, go to the birdmap page
(or whatever page you want to smart-bookmark) and click on the * button
that makes a bookmark. Then click on the = next to the *, and in the
menu, choose Show all bookmarks.
In the dialog that comes up, find the bookmark you just made (maybe in
Unsorted bookmarks?) and click on it.
Click the More button at the bottom of the dialog.
(Click on the image at right for a full-sized screenshot.)
Now you should see a Keyword entry under the Tags entry
in the lower right of that dialog.
Change the Location to
http://shallowsky.com/birdmap.html?bird=%s
.
Then give it a Keyword of birdmap
(or anything else you want to call it).
Close the dialog.
Now, you should be able to go to your location bar and type:
birdmap common raven
or
birdmap sparrow
and it will take you to my birdmap page. If the bird name specifies
just one bird, like common raven, you'll go straight from there to
the eBird map. If there are lots of possible matches, as with sparrow,
you'll stay on the birdmap page so you can choose which sparrow you want.
How to change the default location
If you're not in Los Alamos, you probably want a way to set your own
coordinates. Fortunately, you can; but first you have to get those
coordinates.
Here's the fastest way I've found to get coordinates for a region on eBird:
- Click "Explore a Region"
- Type in your region and hit Enter
- Click on the map in the upper right
Then look at the URL: a part of it should look something like this:
env.minX=-122.202087&env.minY=36.89291&env.maxX=-121.208778&env.maxY=37.484802
If the map isn't right where you want it, try editing the URL, hitting
Enter for each change, and watch the map reload until it points where
you want it to. Then copy the four parameters and add them to your
smart bookmark, like this:
http://shallowsky.com/birdmap.html?bird=%s&minX=-122.202087&minY=36.89291&maxX=-121.208778&maxY=37.484802
Note that all of the the "env." have been removed.
The only catch is that I got my list of 4-letter eBird codes from an
eBird page for New Mexico.
I haven't found any way of getting the list for the entire US.
So if you want a bird that doesn't occur in New Mexico, my page might
not find it. If you like birdmap but want to use it in a different
state, contact me and tell me which state
you need, and I'll add those birds.
Tags: nature, birds, eBird, web, programming, javascript, firefox, bookmarklets
[
14:30 Apr 06, 2015
More nature/birds |
permalink to this entry |
]
Tue, 18 Aug 2009
I'm not a big fan of URL-shortening services -- I like to see what
page I'm about to load so I know if I want to go there. But with
Twitter's 160-character limit, URL shorteners become necessary.
It's tiresome to type in bit.ly every time, so I wanted a bookmark
to say "give me a shortened version of the current URL".
Surprisingly, I had a hard time finding one. bit.ly itself has one
on their front page, but it didn't work for me. Upon examination, it
looks like their bookmark wants to read the clipboard, so you'd have
to select a URL first before shortening it (though they don't actually
tell you that). I don't want that extra step, so I made my own.
Actually two of them.
First, a
Javascript
version that takes the current URL, encodes it and sends it to bit.ly.
I gave it the keyword "bitly", so when I'm on a page, I just type
"bitly" in the URLbar and it goes to bit.ly and makes the shortened URL.
The only problem with that is that I'd rather have the option of
opening it in a new tab, so I can continue to read the original
page. Normally I open new tabs by typing in a URL and typing
Ctrl-Return (normally it's Alt-Return in Firefox, but it drives me
nuts that Firefox uses Ctrl-click for new tab but Alt-Return and I
can never keep them straight, and Firefox's normal behavior for
Ctrl-Return is brain-dead useless so that's the first thing I fix
when I get a Firefox update).
With this bitly bookmarklet, Ctrl-Return and Alt-Return don't work --
because then you lose the original tab's URL, and bitly gives you a
shortened URL to nowhere ... "nowhere" being defined, in the bitly
universe, as http://about.com (go figure). What to do?
So I made a second bookmarklet using a different technique:
instead of using Javascript to get the current page's URL,
call the bookmarklet
with the URL as argument. I called this one bitly2.
So if I'm pointing at http://shallowsky.com/blog/ and I
want a shortened version in a new tab, I type:
Ctrl-L to go to the URLbar
Ctrl-A to go to the beginning of the URL
bitly2 and a space (inserted at the beginning before the URL)
so now I'll see bitly2 http://shallowsky.com/blog/
Ctrl-Return (or Alt-Return) to open in a new tab.
I'm not sure which one I'll end up using more, but I'll obviously
change the bitly2 name to something better if I end up using it a lot.
If you want to use either of these bookmarklets: right-click on the
link and choose Bookmark this link. Then, alas, since Firefox
still doesn't let you enter a keyword in its Bookmarks dialog,
you have to go to Bookmarks->Organize Bookmarks, find the
bookmarklet you just added and click on it, click on More,
and finally you can give it a keyword.
There used to be a Firefox extension
called Openbook that let you see the Keyword field when you first add
a bookmark, but it doesn't work any more in 3.5, alas.
There's another extension called "Add Bookmark Here 2" that's
supposed to do it, but the file on addons.mozilla.org is apparently
corrupted and won't install.
I don't understand why the Firefox crew is so obsessed with bookmark tags
(for which I've never found any use) but won't let you add something as
truly useful as a keyword. (It's bug
242834, marked WONTFIX.)
Of course, after I had my bookmarklets I finally found a page with
a decent bit.ly bookmarklet very similar to my first one:
A
Quick Tutorial on JavaScript Bookmarklets.
Tags: bookmarklets, twitter, javascript
[
15:34 Aug 18, 2009
More tech/web |
permalink to this entry |
]
Mon, 03 Nov 2008
This posting ended up being published as a Linux Planet Quick Tip.
You can read about my nifty word counting bookmarklet there:
Quick
Firefox Tip: Word Count Bookmarklet.
Tags: firefox, mozilla, bookmarklets, writing, programming
[
23:41 Nov 03, 2008
More tech/web |
permalink to this entry |
]
Sun, 26 Oct 2008
Fri, 04 Jul 2008
I finally broke down and spent the time to get Firefox 3 working
properly for me ... meaning, mostly, finding replacement extensions
for the bare minimum of what I need in a browser: control over cookies
(specifically, enabling/disabling them for specific sites),
flashblock, and blocking of animated images. I'd downloaded extensions
for all those a few weeks ago, but I found that although Firefox 3.0
said the FF3 extensions were active, and Firefox 2 said the old ones
were, neither set actually worked.
I decided to start from scratch: remove all extensions --
rm -rf .mozilla/firefox/extensions/* .mozilla/firefox/extensions.*
plus apt-get remove firefox-2-dom-inspector
--
then install a new set of Firefox 3 add-ons.
After much hunting
(I sure wish addons.mozilla.org
would offer a way to limit the view to only extensions that work with
Firefox 3! Combing through 15 pages of extensions looking for the
handful that will actually install gets old fast) I found the
replacements I needed:
CS Lite for the cookie controls,
a newer Flashblock,
and Custom Toolbar Buttons as a stopgap for image animation
(though I suspect updating anidisable will be a better solution
in the long run). This time, with the old firefox 2 extensions purged,
the new ones took hold and worked.
I also added a nice extension called OpenBook that fixes the horrible
Firefox "Add bookmark" dialog. You know: the one that has two nearly
identical dropdown category menus side by side, with the bigger one
giving you only a tiny subset of your bookmark categories, and the
smaller one being the real one. The one that doesn't offer a space for
keyword, so to set up a bookmarklet you have to Add Bookmark, OK,
Organize Bookmarks, find the bookmark you just added, Ctrl-I to
get the Bookmark info dialog, and finally you can add your
keyword. OpenBook gives you a dialog where you can set the keyword
to begin with, and it only gives you one menu to list categories
so you aren't constantly tempted to click on the wrong one.
Now for the urlbar -- that new firefox 3 "smarter" urlbar that slows
down typing in the middle of a word so it can pop up a big fancy
window full of guesses (all wrong) about where I might be trying to
go. Actually, even if the guesses were right, it wouldn't help,
because I'd have to stop typing, search the list visually, then if
one of the suggestions was right, move my hand to the mouse or the
arrow keys to choose that suggestion. That takes way longer than just
typing the url.
But I guess I don't mind unhelpful suggestions popping up as long as
it doesn't mess up focus (preventing me from clicking or tabbing to
other apps on my screen) or slow down typing. Firefox 3 seems to be
handling the focus issue better than firefox 2 did, but the slowdown
was quite noticeable on the poor old laptop. So I wanted a way to
disable the behavior. A little googling revealed that the Firefox crew
immodestly calls their new urlbar the "awesomebar", which aside from
giggle factor also proves quite useful in googling: a search on
firefox
disable awesomebar reveals that I'm not the only one who doesn't
like it, and got me several preferences
I could tweak in about:config plus a couple of extensions to
turn it off entirely. I won't try to summarize, since the best
settings depend on your machine's spec, plus personal preference.
Making progress! Now the only issue was getting my urlbar tweaks working,
so that typing <Ctrl-Return> after typing a URL opened the URL in a new
tab instead of tacking on various silly extensions (oh, yes, of course
I wanted to go to http://www.firefox disable awesomebar.com
rather than googling for those terms in a new tab).
Fortunately, it turned out that the javascript that runs the urlbar
has changed very little since firefox 2, and I hardly needed to change
anything to get my
kitfox extension (v. 0.2)
working in Firefox 3.
Only one more issue: this blog. The CSS that handles the right sidebar
wasn't displaying right. Seems that Firefox 2 has changed something
about its interpretation of CSS, so it was floating the right sidebar
way down to the bottom of the page below the last content line.
Eventually (after adding firefox-3.0-dom-inspector,
another extension that had stopped working in the transition)
I discovered the problem: the #content was set to width: 77%
while the #rightsidebar's left-margin was at 76%. Apparently Firefox 2
rounded up as needed, whereas Firefox 3 just ignores the left-margin
if it would overlap the content, and then floats the sidebar anywhere
it thinks it can fit it. Fixing those percentages helped quite a bit,
and I added an overflow-x: hidden (on a tip from a helpful person in
#firefox) so that wide calendar doesn't hurt layout for narrow windows.
I think it's working now ... any readers having problems with the
layout in any browser, by all means let me know.
Tags: mozilla, firefox, user interface, css, bookmarklets
[
12:04 Jul 04, 2008
More tech/web |
permalink to this entry |
]
Tue, 08 Apr 2008
A friend pointed me to a story she'd written. It was online as a .txt
file. Unfortunately, it had no line breaks, and Firefox presented it
with a horizontal scrollbar and no option to wrap the text to fit in
the browser window.
But I was sure that was a long-solved problem -- surely there must
be a userContent.css rule or a bookmarklet to handle text with long
lines. The trick was to come up with the right Google query.
Like this one:
firefox OR mozilla wrap text userContent OR bookmarklet
I settled on the simple CSS rule from Tero Karvinen's page on
Making
preformated <pre> text wrap in CSS3, Mozilla, Opera and IE:
pre {
white-space: -moz-pre-wrap !important;
}
Add it to
chrome/userContent.css and you're done.
But some people might prefer not to apply the rule to all text.
If you'd prefer a rule that can be applied at will, a bookmarklet
would be better. Like the
word
wrap bookmarklet from Return of the Sasquatch
or the one from Jesse Ruderman's
Bookmarklets
for Zapping Annoyances collection.
Tags: tech, web, mozilla, firefox, css, bookmarklets
[
11:47 Apr 08, 2008
More tech/web |
permalink to this entry |
]
Sat, 30 Jun 2007
Today's topics are three: the excellent comic called xkcd,
the use of google to search a site but exclude parts of that site,
and, most important, the useful Mozilla technique called Bookmarklets.
I found myself wanting to show someone a particular xkcd comic
(the one about dreams).
Xkcd, for anyone who hasn't been introduced, is a wonderfully
geeky, smart, and thoughtful comic strip drawn by Randall
Munroe.
How to search for a comic strip? Xkcd has an archive page but that
seems to have a fairly small subset of all the comics. But fortunately
the comics also have titles and alt tags, which google can index.
But googling for dreams site:xkcd.org
gets me lots of
hits on xkcd's forum and blag pages (which I hadn't even known
existed) rather than just finding the comic I wanted. After some
fiddling, though, I managed to find a way to exclude all the fora
and blag pages: google for
xkcd dreams site:xkcd.com -site:forums.xkcd.com -site:fora.xkcd.com -site:blag.xkcd.com
Nifty!
In fact, it was so nifty that I decided I might want to use it again.
Fortunately, Mozilla browsers like Firefox have a great feature called
bookmarklets. Bookmarklets are like shell aliases in Linux:
they let you assign an alias to a bookmark, then substitute in your
own terms each time you use it.
That's probably not clear, so here's how it works in this specific
case:
- I did the google search I listed above, which gave me this long
and seemingly scary URL:
http://www.google.com/search?hl=en&q=xkcd+dreams+site%3Axkcd.com+-site%3Aforums.xkcd.com+-site%3Afora.xkcd.com+-site%3Ablag.xkcd.com&btnG=Search
- Bookmarks->Bookmark this page. Unfortunately Firefox
doesn't let you change any bookmark properties at the time you make
the bookmark, so:
- Bookmarks->Organize Bookmarks, find the new bookmark
(down at the bottom of the list) and Edit->Properties...
- Change the Name to something useful (I called it
Xkcd search)
then choose a simple word for the Keyword field. This is the "alias"
you'll use for the bookmark. I chose xkcd.
- In the Location field, find the term you want to be
variable. In this case, that's "dreams", because I won't always be
searching for the comic about dreams, I might want to search for anything.
Change that term to %s.
(Note to non-programmers: %s is a term often used in programming
languages to mean "replace the %s with a string I'll provide
later.")
So now the Location looks like:
http://www.google.com/search?hl=en&q=xkcd+%s+site%3Axkcd.com+-site%3Aforums.xkcd.com+-site%3Afora.xkcd.com+-site%3Ablag.xkcd.com&btnG=Search
- Save the bookmarklet (click OK) and, optionally, drag it
into a folder somewhere where it won't clutter up your bookmarks menu.
You aren't ever going to be choosing this from the menu.
Now I had a new bookmarklet. To test it, I went to the urlbar in
Firefox and typed:
xkcd "regular expressions"
Voila! The first hit was exactly the comic I wanted.
(You'll find many more useful bookmarklets by
googling on
bookmarklets.)
Tags: tech, web, bookmarklets
[
22:13 Jun 30, 2007
More tech/web |
permalink to this entry |
]