Notification Spam Block

Blocks intrusive spam ads notification websites.

  1. // ==UserScript==
  2. // @name Notification Spam Block
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.2
  5. // @description Blocks intrusive spam ads notification websites.
  6. // @author cool66
  7. // @match https://*/*
  8. // @icon data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
  9. // @grant none
  10. // @license MIT
  11. // ==/UserScript==
  12.  
  13. var tnrp = Notification.requestPermission;
  14. Notification.requestPermission = async () => {
  15. return new Promise(async (resolve, reject) => {
  16. if (document.body.innerHTML.toLowerCase().includes("allow")) {
  17. var d = document.createElement("div");
  18. var db = document.createElement("button");
  19. var ctm = document.createElement("button");
  20. d.innerHTML = `This website is being blocked because this website shows you intrusive spam ads notification. Close this tab now.<br><br>`;
  21. d.setAttribute("style", "position: fixed; top: 5px; left: 5px; width: calc(100% - 20px); height: calc(100% - 20px); background-color: gray; color: white; padding: 5px; text-align: center; font-size: 16px; font-family: Arial; z-index: 999999999999999999999999;");
  22. ctm.innerHTML = "Close this message";
  23. db.innerHTML = "Don't block";
  24. document.body.appendChild(d);
  25. d.appendChild(ctm);
  26. d.appendChild(db);
  27. db.addEventListener("click", async () => {
  28. d.remove();
  29. resolve(await tnrp());
  30. });
  31. ctm.addEventListener("click", () => {
  32. d.remove();
  33. });
  34. } else {
  35. resolve(await tnrp());
  36. }
  37. });
  38. };