uso - Anchor Bookmarks

By Marti Last update Jan 23, 2013 — Installed 1,979 times.

SUGGESTIONS

in
Subscribe to SUGGESTIONS 6 posts, 2 voices



Marti Script's Author
FirefoxX11

Suggestions a.k.a. Feedback which includes new additions or alternate coding styles for this script go here as usual :)

Current TODO list:

  • Trim left and right
  • Limit maximum string size for long lines
  • In the event of the same string in one page occurring twice, contemplate making id/names unique.
  • Show DOM image to allow for linking
  • Remove all periods in pre filter
  • Walk up the DOM in topics and possibly use native bookmark style
  • Not sure if parenthesis should be encoded with escape or not... contemplate ramifications
  • Cross-browser port (IE is out of the loop since it does not support XPATH on the document Object... Konqueror KDE4 Userscripting plugin appears to be dead too)

 
sizzlemctwizzle Scriptwright
FirefoxMacintosh

Add the end of the script I added:

if (window.location.hash.indexOf('#bookmark-') == 0)
    window.location.href = window.location.href;

Which sends the user to the correct anchor if they follow a link there. After you make my change follow this example link.

 
Marti Script's Author
FirefoxX11

sizzlemctwizzle wrote:
Which sends the user to the correct anchor if they follow a link there.
I hope this works... I did some quick testing with something similar last night under Nix and it didn't seem to want to do anything... but I'll give your snippet a shot. Thanks :)


Test link QSP... COOL it works! :) Thanks sizzlemctwizzle... I was trying just changing the hash and it didn't occur to me to redirect the whole uri. :)

 
sizzlemctwizzle Scriptwright
SafariMacintosh

My code doesn't work in Safari, but this does:

var hash = window.location.hash;
if (hash.indexOf('#bookmark-') == 0)
    document.getElementById(hash.substr(1, hash.length-1)).scrollIntoView(true);

You should make the ids unique. Just stash them in an object while you're adding them and tack a number on the end if you encounter multiples.

 
Marti Script's Author
FirefoxX11

sizzlemctwizzle wrote:
You should make the ids unique.
The reason why I said contemplate is that mediawiki and the general coding ethic out there in the past has been defying unique id's and names in their software... Not sure I want to go against the norm even though id/names should be unique.

I'll try out your "move" routine and see if it works everywhere else... bunch of code just to support Safari though... almost as bad as the "proper" way to use rex ;)... I did find out that IE doesn't support XPATH natively and I'm not sure I want to support IE or not... the equivalent getElementById wouldn't be as simple (and probably wouldn't work on null ids) as the XPATH equivalent... so I think IE is out of the loop for now.


Well scrollIntoView doesn't position the browser anywhere near to the element properly if userscripts.org alternate CSS occurs after uso - Anchor Bookmarks in this Firefox browser... hmm.


Thanks for your suggestions and debug help. Works in Mac Safari, Opera and Goo too... but remember to execute this script after userscripts.org alternate CSS if you are using it.

 
Marti Script's Author
FirefoxX11

sizzlemctwizzle wrote:
You should make the ids unique. Just stash them in an object while you're adding them and tack a number on the end if you encounter multiples.
It's actually a bit more complicated than just this process. 0.0.11 is up... All other supported browsers that I have check out.


I've modified most of my scripts summary information to include relevant anchored bookmarks :)