closeDoublePage

Closes the old tab, if a new one with the same URL emerges

目前为 2021-12-15 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name closeDoublePage
  3. // @version 0.4.2
  4. // @description Closes the old tab, if a new one with the same URL emerges
  5. // @author CennoxX
  6. // @contact cesar.bernard@gmx.de
  7. // @namespace https://greasyfork.org/users/21515
  8. // @homepage https://github.com/CennoxX/userscripts
  9. // @supportURL https://github.com/CennoxX/userscripts/issues/new?title=[closeDoublePage]%20
  10. // @include *
  11. // @grant GM_getValue
  12. // @grant GM_setValue
  13. // @grant window.close
  14. // @license MIT
  15. // ==/UserScript==
  16.  
  17. sessionStorage.setItem('firstTimeOpened',new Date());
  18. GM_setValue('log', document.URL + '##' + sessionStorage.getItem('firstTimeOpened'));
  19. var oldLogs = '';
  20. setInterval(function() {
  21. var logs = GM_getValue('log');
  22. if (oldLogs != logs) {
  23. if (document.URL==logs.split('##')[0] && sessionStorage.getItem('firstTimeOpened') != logs.split('##')[1])
  24. {
  25. window.close()
  26. }
  27. else
  28. {
  29. oldLogs = logs;
  30. }
  31. }
  32. }, 500);