developer.chrome.com fast back/forward

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

اعتبارا من 05-12-2023. شاهد أحدث إصدار.

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.

ستحتاج إلى تثبيت إضافة مثل Stylus لتثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتتمكن من تثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتثبيت هذا النمط.

(لدي بالفعل مثبت أنماط للمستخدم، دعني أقم بتثبيته!)

// ==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.0
// @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.querySelector(`[id="${a.hash}"]`))
      (document.querySelector('h1') || document.body).scrollIntoView();
    requestAnimationFrame(() => scrollBy(0, -30));
  }
}, true);