Disable Confirmation Dialog When Leaving A Web Page

Disable confirmation dialog when leaving a web page

目前为 2018-10-20 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name Disable Confirmation Dialog When Leaving A Web Page
  3. // @namespace DisableConfirmationDialogWhenLeavingAWebPage
  4. // @description Disable confirmation dialog when leaving a web page
  5. // @license GNU AGPLv3
  6. // @author jcunews
  7. // @match *://*/*
  8. // @version 1.0.4
  9. // @grant none
  10. // @run-at document-start
  11. // ==/UserScript==
  12.  
  13. (function(d) {
  14. d = Object.getOwnPropertyDescriptor(window, "onbeforeunload");
  15. d.set = function(f) {
  16. return f;
  17. };
  18. Object.defineProperty(window, "onbeforeunload", d);
  19.  
  20. d = window.addEventListener;
  21. window.addEventListener = function(typ) {
  22. if (typ.toLowerCase() === "beforeunload") return;
  23. return d.apply(this, arguments);
  24. };
  25. })();