closeDoublePage

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

目前為 2019-04-05 提交的版本,檢視 最新版本

  1. // ==UserScript==
  2. // @name closeDoublePage
  3. // @version 0.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. // @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. // ==/UserScript==
  14. var urls = '';
  15. urls = GM_getValue('urls');
  16. urls += document.URL;
  17. GM_setValue('urls', urls);
  18. window.addEventListener('beforeunload', deleteUrl, false);
  19.  
  20. function deleteUrl(zEvent) {
  21. urls = GM_getValue('urls');
  22. GM_setValue('urls', urls.replace(document.URL, ''));
  23. }
  24.  
  25. setInterval(function() {
  26. var urls2 = '';
  27. urls2 = GM_getValue('urls');
  28. if (urls2.replace(document.URL, '') != urls2) {
  29. urls = urls.replace(document.URL, '');
  30. GM_setValue('urls', urls);
  31. window.close();
  32. }
  33. }, 5000);