// ==UserScript== // @name CSS Anchors // @description Shim for CSS Anchors // @version 0.01 // @author jacob@krawaller.se // @license MIT License // @namespace http://blog.krawaller.se // @include http://* // ==/UserScript== (function(){ var hash, el, t = 0; if (window.pageYOffset == 0 && (hash = (location.href.match(/#(.*)$/) || [])[1]) && (el = document.querySelector(hash)) ) { do { t += el.offsetTop; } while (el.offsetParent && (el = el.offsetParent)); window.scrollTo(0, t); } })();