Disable Notifications API

Disable Notifications API where sites may show popup notifications message at bottom-right of the web browser. Any sites which require Notifications API may cause the web browser to ask user for a permission to display notifications. This script disables both the notifications and the permission prompt. It is intended for users who find them annoying.

  1. // ==UserScript==
  2. // @name Disable Notifications API
  3. // @namespace https://greasyfork.org/en/users/85671-jcunews
  4. // @version 1.0.1
  5. // @license GNU AGPLv3
  6. // @description Disable Notifications API where sites may show popup notifications message at bottom-right of the web browser. Any sites which require Notifications API may cause the web browser to ask user for a permission to display notifications. This script disables both the notifications and the permission prompt. It is intended for users who find them annoying.
  7. // @author jcunews
  8. // @match *://*/*
  9. // @grant none
  10. // @run-at document-start
  11. // ==/UserScript==
  12.  
  13. (function() {
  14. window.Notification = {
  15. get permission() {
  16. return "denied";
  17. },
  18. set permission(a) {
  19. return "denied";
  20. },
  21. requestPermission: function(fn) {
  22. if ("function" === typeof fn) {
  23. fn("denied");
  24. return;
  25. } else {
  26. return {
  27. then: function(fn) {
  28. fn("denied");
  29. return this;
  30. }
  31. };
  32. }
  33. }
  34. };
  35. })();