Prevent tab history flooding

Never again click Back and stay on the same page

  1. // ==UserScript==
  2. // @name Prevent tab history flooding
  3. // @description Never again click Back and stay on the same page
  4. // @include *
  5. // @run-at document-start
  6. // @version 1.1
  7. // @author xiaoxiaoflood
  8. // @namespace https://github.com/xiaoxiaoflood
  9. // ==/UserScript==
  10.  
  11. history.pushState = new Proxy(history.pushState, {
  12. apply (target, thisArg, args) {
  13. let el = document.createElement('a');
  14. el.href = args[2];
  15. if (el.href != location.href) {
  16. return target.apply(thisArg, args);
  17. }
  18. }
  19. });
  20.  
  21. unsafeWindow.history.pushState = exportFunction(history.pushState, unsafeWindow);

QingJ © 2025

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