Youtube Remove Timestamp

Removes the timestamp from URL, so it doesn't invalidate your progress when you reload the page.

  1. // ==UserScript==
  2. // @name Youtube Remove Timestamp
  3. // @namespace https://github.com/Alistair1231/my-userscripts/
  4. // @version 0.4.0
  5. // @description Removes the timestamp from URL, so it doesn't invalidate your progress when you reload the page.
  6. // @author Alistair1231
  7. // @match https://www.youtube.com/*
  8. // @icon https://icons.duckduckgo.com/ip2/youtube.com.ico
  9. // @license MIT
  10. // ==/UserScript==
  11. // https://gf.qytechs.cn/en/scripts/535336-youtube-remove-timestamp/
  12. // https://github.com/Alistair1231/my-userscripts/blob/master/youtube-remove-timestamp.user.js
  13.  
  14. (function () {
  15. "use strict";
  16.  
  17. function removeTimestamp() {
  18. if (!window.location.href.includes("https://www.youtube.com/watch")) return;
  19.  
  20. // Parse query parameters
  21. const params = new URLSearchParams(window.location.search);
  22. if (!params.has("t")) return; // No timestamp, nothing to do
  23.  
  24. console.log("Removing timestamp from URL");
  25. params.delete("t");
  26. const newSearch = params.toString() ? `?${params.toString()}` : "";
  27. const newUrl = `${window.location.origin}${window.location.pathname}${newSearch}${window.location.hash}`;
  28. // Only update if different
  29. if (window.location.href !== newUrl) {
  30. window.history.replaceState(null, "", newUrl);
  31. }
  32. }
  33.  
  34. removeTimestamp();
  35. let lastUrl = location.href;
  36. setInterval(() => {
  37. if (location.href !== lastUrl) {
  38. lastUrl = location.href;
  39. removeTimestamp();
  40. }
  41. }, 200);
  42. })();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址