CodeSpaces Close Confirmation

Ask before you close GitHub or VS Codespaces

  1. // ==UserScript==
  2. // @name CodeSpaces Close Confirmation
  3. // @namespace https://github.com/wei
  4. // @version 0.2
  5. // @description Ask before you close GitHub or VS Codespaces
  6. // @author Wei <github@weispot.com>
  7. // @match https://*.github.dev
  8. // @match https://online.visualstudio.com/*
  9. // @grant none
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. 'use strict';
  14.  
  15. window.addEventListener('beforeunload', function (e) {
  16. e.preventDefault();
  17. e.returnValue = 'Are you sure?';
  18. });
  19. })();