Guest User

close_all_tabs_on_domain.user.js

a guest
Jun 26th, 2014
262
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name       Close All Tabs on Domain
  3. // @version    0.1
  4. // @description   Close all tabs on current domain - userscript
  5. // @match      http://*/*
  6. // @match      https://*/*
  7. // ==/UserScript==
  8.  
  9. function chls4c(){
  10.     if(new Date().getTime() - localStorage.getItem('lsc2ls3') < 2000 && new Date().getTime() - localStorage.getItem('lsc2ls3') > 0 ){        
  11.         var o=document.createElement('a');
  12.         o.href='javascript: window.close();';
  13.         document.getElementsByTagName('body')[0].appendChild(o);
  14.         o.click();
  15.         window.close();
  16.         open(location, '_self').close();
  17.     }
  18. }
  19.  
  20. setInterval(chls4c, 1000);
  21. /*
  22. This is .user.js part of the script. It's provides the way to use a bookmarklet to close all tabs on domain. The bookmarklet is
  23. ____________________________________________
  24. javascript:var o=document.createElement('a');o.href='javascript: localStorage.setItem("lsc2ls3", new Date().getTime());';document.getElementsByTagName('body')[0].appendChild(o); o.click();
  25.  
  26. _______________________________________________
  27. */
Advertisement
Add Comment
Please, Sign In to add comment