Skip to content

Instantly share code, notes, and snippets.

@illixion
Last active May 23, 2021 09:42
Show Gist options
  • Save illixion/1cf35b68bc0f8142d77fb5b05022be11 to your computer and use it in GitHub Desktop.
Save illixion/1cf35b68bc0f8142d77fb5b05022be11 to your computer and use it in GitHub Desktop.
Makes it so that the back button always works in YouTube polymer interface when using non-Chromium browsers. Without this userscript, the currently playing video reloads on pressing the back button.
// ==UserScript==
// @name Fix back button on YouTube
// @description Fixes the back button in YouTube Polymer for non-Chromium browsers
// @match https://*.youtube.com/*
// ==/UserScript==
globalThis.removeEventListener("popstate", getEventListeners(globalThis)["popstate"][0]["listener"])
document.body.addEventListener("yt-history-pop", () => window.location.href = document.location.href)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment