developer.chrome.com fast back/forward

Makes back/forward navigation fast as they should be instead of half a second

Från och med 2023-12-06. Se den senaste versionen.

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name        developer.chrome.com fast back/forward
// @namespace   https://greatest.deepsurf.us/en/users/2159-woxxom
// @description Makes back/forward navigation fast as they should be instead of half a second
// @version     1.0.1
// @license     MIT
// @match       https://developer.chrome.com/*
// @run-at      document-start
// @grant       none
// ==/UserScript==

const {addEventListener} = window;
window.addEventListener = function (type) {
  if (type !== 'popstate') addEventListener.apply(this, arguments);
};
Object.defineProperty(history, 'scrollRestoration', {
  value: history.scrollRestoration = 'auto',
  writable: false,
});
addEventListener('click', e => {
  const a = e.target.closest('a');
  if (a && a.href && a.getAttribute('href') !== '#') {
    e.stopPropagation();
    a.click();
    if (!document.getElementById(a.hash.slice(1)))
      (document.querySelector('h1') || document.body).scrollIntoView();
    requestAnimationFrame(() => scrollBy(0, -30));
  }
}, true);