No Surf Constant Splash Reminder + Timer

Every time you navigate to websites such as Reddit, Youtube, TikTok, Facebook you will get a full-face splash saying "Are you sure you want to waste your time here?".

  1. // ==UserScript==
  2. // @name No Surf Constant Splash Reminder + Timer
  3. // @author bajspuss@reddit + sudface
  4. // @version 0.2
  5. // @description Every time you navigate to websites such as Reddit, Youtube, TikTok, Facebook you will get a full-face splash saying "Are you sure you want to waste your time here?".
  6. // @require https://code.jquery.com/jquery-3.6.0.min.js
  7. // @include https://www.reddit.com/*
  8. // @include https://www.youtube.com/*
  9. // @include https://www.tiktok.com/*
  10. // @include https://www.facebook.com/*
  11. // @include https://twitter.com/*
  12. // @noframes
  13. // @namespace https://greatest.deepsurf.us/users/809510
  14. // ==/UserScript==
  15.  
  16. (function ()
  17. {
  18.  
  19. // !!!!!!!!!!!! N O T I C E M E !!!!!!!!!!!!!!
  20.  
  21. // !!!!!!!!!!!! N O T I C E M E !!!!!!!!!!!!!!
  22.  
  23. // !!!!!!!!!!!! N O T I C E M E !!!!!!!!!!!!!!
  24.  
  25. // This is a tampermonkey script.
  26. // Change the below values to your liking.
  27. // count is the countdown before the proceed button enables, in seconds.
  28. // Default Value = 5
  29. // redirectsite is the site that the do something better button takes you to.
  30. // Note: The full link, including the http:// at the start must be present. Remember to enclose the whole link in quotation marks.
  31. // Default Value = "https://phys.libretexts.org/Bookshelves/Quantum_Mechanics/Book%3A_Introductory_Quantum_Mechanics_(Fitzpatrick)/"
  32.  
  33. // !!!!!!!!!!!! N O T I C E M E !!!!!!!!!!!!!!
  34.  
  35. // !!!!!!!!!!!! N O T I C E M E !!!!!!!!!!!!!!
  36.  
  37. // !!!!!!!!!!!! N O T I C E M E !!!!!!!!!!!!!!
  38.  
  39. let $ = window.$;
  40. var count = 5;
  41. var redirectsite = "https://phys.libretexts.org/Bookshelves/Quantum_Mechanics/Book%3A_Introductory_Quantum_Mechanics_(Fitzpatrick)/"
  42.  
  43. $("head").append(`<style>
  44. #fullscreen-overlay {
  45. display: visible;
  46. position: fixed;
  47. height: 100vh;
  48. width: 100vw;
  49. top: 0px;
  50. left: 0px;
  51. background: rgba(0, 0, 0, 1);
  52. z-index: 999999999;
  53. }
  54. .centertext
  55. {
  56. margin: 0;
  57. position: absolute;
  58. top: 50%;
  59. left: 50%;
  60. transform: translate(-50%, -50%);
  61. text-align: center;
  62. font-family: sans-serif;
  63. font-size: 50px;
  64. color: #fff;
  65. }
  66. button.btn {
  67. height: 42px;
  68. text-align: center;
  69. text-decoration: none;
  70. display: inline-block;
  71. font-size: 16px;
  72. border: none;
  73. border-radius: 8px;
  74. }
  75. button.no {
  76. width: 50%;
  77. margin-left: 5%;
  78. background-color: #4CAF50; /* Green */
  79. color: white;
  80. }
  81. button.no:hover {
  82. color: #4CAF50;
  83. background-color: white;
  84. }
  85. button.yes {
  86. width: 10%;
  87. margin-right: 5%;
  88. background-color: rgba(0, 0, 0, 1);
  89. color: #f44336;
  90. }
  91. button.yes:hover {
  92. color: rgba(0, 0, 0, 1);
  93. background-color: #f44336;
  94. }
  95. button.yes:disabled:hover {
  96. background-color: rgba(0, 0, 0, 1);
  97. color: #f44336;
  98. }
  99. </style>`);
  100.  
  101. let [w, h] = [, window.innerHeight];
  102. $("body").append(`<div id="fullscreen-overlay">
  103. <div class="centertext">
  104. Are you sure you want to waste your time here?
  105. <br>
  106. <button id="keeponsite" class="yes btn" disabled>yes (<span id="countdowntimer"></span>)</button>
  107. <button id="quit" class="no btn">No I'll do something better.</button>
  108. </div>
  109. </div>`);
  110.  
  111. var spn = document.getElementById("countdowntimer");
  112. var btn = document.getElementById("keeponsite");
  113.  
  114. var timer = null; // For referencing the timer
  115.  
  116. (function countDown(){
  117. // Display counter and start counting down
  118. spn.textContent = count;
  119.  
  120. // Run the function again every second if the count is not zero
  121. if(count !== 0){
  122. timer = setTimeout(countDown, 1000);
  123. count--; // decrease the timer
  124. } else {
  125. // Enable the button
  126. btn.removeAttribute("disabled");
  127. }
  128. }());
  129.  
  130. $("#keeponsite").click((e) => {
  131. $("#fullscreen-overlay").css("display", "none");
  132. console.log('ignoring');
  133. });
  134.  
  135. $("#quit").click((e) => {
  136. window.location.href = redirectsite;
  137. console.log('bye');
  138. });
  139.  
  140. window.addEventListener('popstate', () => {
  141. $("#fullscreen-overlay").css("display", "visible");
  142. });
  143.  
  144. window.addEventListener('hashchange', () => {
  145. $("#fullscreen-overlay").css("display", "visible");
  146. });
  147. })()