Error 404 Button

Adds a button to trigger an "Error 404" page replacement.

  1. // ==UserScript==
  2. // @name Error 404 Button
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.4
  5. // @description Adds a button to trigger an "Error 404" page replacement.
  6. // @author Game Dude
  7. // @match *://*/*
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11. (function() {
  12. 'use strict';
  13.  
  14. // Create the button element
  15. const button = document.createElement('button');
  16. button.textContent = '◯';
  17. button.style.position = 'fixed';
  18. button.style.bottom = '20px';
  19. button.style.right = '20px';
  20. button.style.zIndex = '9999';
  21. button.style.padding = '10px 15px';
  22. button.style.border = 'none';
  23. button.style.borderRadius = '50%';
  24. button.style.backgroundColor = '#dc3545';
  25. button.style.color = '#fff';
  26. button.style.fontSize = '18px';
  27. button.style.cursor = 'pointer';
  28. button.style.boxShadow = '0 4px 6px rgba(0, 0, 0, 0.1)';
  29.  
  30. // Add a hover effect
  31. button.addEventListener('mouseover', () => {
  32. button.style.backgroundColor = '#c82333';
  33. });
  34. button.addEventListener('mouseout', () => {
  35. button.style.backgroundColor = '#dc3545';
  36. });
  37.  
  38. // Append the button to the document body
  39. document.body.appendChild(button);
  40.  
  41. // Add a click event listener to the button
  42. button.addEventListener('click', () => {
  43. // Clear the body content
  44. while (document.body.firstChild) {
  45. document.body.removeChild(document.body.firstChild);
  46. }
  47.  
  48. // Create a new style element for the page
  49. const style = document.createElement('style');
  50. style.textContent = `
  51. body {
  52. display: flex;
  53. justify-content: center;
  54. align-items: center;
  55. height: 100vh;
  56. margin: 0;
  57. font-family: Arial, sans-serif;
  58. color: #333;
  59. background-color: #f8f9fa;
  60. }
  61. h1 {
  62. font-size: 3rem;
  63. color: #dc3545;
  64. }
  65. `;
  66. document.head.appendChild(style);
  67.  
  68. // Create and append the "Error 404" message
  69. const errorMessage = document.createElement('h1');
  70. errorMessage.textContent = 'Error 404: Page Not Found';
  71. document.body.appendChild(errorMessage);
  72.  
  73. // Remove the button from memory
  74. button.remove();
  75. });
  76. })();