closeDoublePage

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

目前为 2019-06-12 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name closeDoublePage
  3. // @version 0.3
  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. // @homepage https://twitter.com/CennoxX
  8. // @namespace https://greasyfork.org/users/21515
  9. // @include *
  10. // @grant GM_getValue
  11. // @grant GM_setValue
  12. // @grant window.close
  13. // @grant unsafeWindow
  14. // @license MIT
  15. // ==/UserScript==
  16. unsafeWindow.cdp_firstTimeOpened=new Date();
  17. GM_setValue('log', document.URL + '##' + unsafeWindow.cdp_firstTimeOpened);
  18. var oldLogs = '';
  19. setInterval(function() {
  20. var logs = GM_getValue('log');
  21. if (oldLogs != logs) {
  22. if (document.URL==logs.split('##')[0] && unsafeWindow.cdp_firstTimeOpened != logs.split('##')[1])
  23. {
  24. window.close()
  25. }
  26. else
  27. {
  28. oldLogs = logs;
  29. }
  30. }
  31. }, 500);