THIS IS A STATIC MIRROR OF USERSCRIPTS.ORG - LOGINS DO NOT WORK

findhash

By myfonj Last update Mar 13, 2009 — Installed 326 times.

Script Summary: Finds text from url hash (#...) if no element of matching ID or anchor is present in the page.



[Remotely hosted version](http://eldar.cz/myf/pub/firefox/findhash.user.js)

A very simple script. Allows you to point to certain phrase anywhere in the page simply by adding the phrase after '#' sign at the end of the page URL. I missed this functionality very much while chatting with friends and frequently pasting URLs with note FAYT:foo bar or look for 'foo bar' there or something like that. But when I found the built-in [window.find()](http://developer.mozilla.org/en/docs/DOM:window.find) method I was redeemed and immediately wrote this. :] (I suppose many further tweaks are possible.)

Install and try it yourself: open [a href="#foo bar"](#foo bar) in a new tab!

Notes:

  • No need to manually rewrite white-space (or anything): browser does it, and the script decodes it back, losslessly :]
  • Does not work in frames (yet).
  • [LocationbarĀ² extension](http://en.design-noir.de/mozilla/locationbar2/) decodes URLs in location bar for better readability. (Pressing escape in there will show you the real URL again.)
  • Case insensitive (but it seems it can be changed simply).
  • It would be nice if it was a part of standard browser functionality, wouldn't it?
  • Recently, I've made few interesting find()ings:
    • There is [Idiri Extension](http://www.schepers.cc/?p=39), which finds the nearest existing 'anchor' of your context-menu click. This is disadvantage, because it relies on the quality of the code structure, but in the other hand, anchors found this way will work always, even for those without this extension. I like it very much! : )
    • Existence of [xpointer](http://www.w3.org/TR/xptr-xpointer/).
    • Fact that it is also (partially - for XML parsed documents only) [implemented in Firefox](http://developer.mozilla.org/en/docs/XML_in_Mozilla#XML_Linking_and_Pointing).
    • So something like #xpath1(//text()[contains(.,'foo bar')]) with configured FF by pref("layout.selectanchor", true); would work very alike the findhash does (it would just select whole element containing the phrase instead selecting just the phrase itself).
    • There is [FXPointer Extension](http://www.codedread.com/fxpointer/), which partially fixes it. It creates and works with 'anchors' from the DOM context: #element(content/3/6/5). But hey, it has context menu option! : )
    • XPath bookmark (userscript) works fine, too. Uses such anchors: #xpath:/html/body/h2[3]

Known issues:

  • (Focused) selection created by the find() method can be "pushed out" of your viewport by additionally loaded objects (images and such), what makes this script quite useless.Fixed 2007-10-05.