您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Fixes anchor scrolling on wazeopedia due to having a fixed height header
// ==UserScript== // @name Wazeopedia Enhancements // @namespace https://greasyfork.org/users/30701-justins83-waze // @version 2017.11.17.01 // @description Fixes anchor scrolling on wazeopedia due to having a fixed height header // @author JustinS83 // @include https://wazeopedia.waze.com* // @grant none // ==/UserScript== (function() { 'use strict'; function bootstrap(tries) { tries = tries || 1; if ($) { init(); } else if (tries < 1000) { setTimeout(function () {bootstrap(tries++);}, 200); } } bootstrap(); function init(){ $('a[href*=#]:not([href=#])').click(function() { if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) { var target = $(this.hash); target = target.length ? target : $('[name="' + this.hash.slice(1) +'"]'); if (target.length) { $('html,body').animate({ scrollTop: target.offset().top - 60 //offsets for fixed header }, 250); //return false; } } }); $(window).load(function(){setTimeout(function(){ //Executed on page load with URL containing an anchor tag. if($(location.href.split("#")[1])) { //debugger; var target = $('#'+location.href.split("#")[1]); if (target.length) { $('html,body').animate({ scrollTop: target.offset().top - 60 //offset height of header here too. }, 250); return false; } }},25);}); } })();