// ==UserScript==// @name Hide Amazon Buy Now Button// @namespace http://tampermonkey.net/// @version 0.1// @description Hide the Buy Now button and replace checkout buttons before 8pm PST// @author NickolayKon@// @match https://*.amazon.com/*// @grant none// ==/UserScript==(function() { 'use strict'; // Get the Buy Now button(s) by IDs that contain 'buy-now' or 'buy-right-now'. var buyNowButtons = document.querySelectorAll("[id*='buy-now'], [id*='buy-right-now']"); // Loop through the NodeList and hide each button for (var i = 0; i < buyNowButtons.length; i++) { buyNowButtons[i].style.display = "none"; }})();(function() { 'use strict'; // Get the current date/time in PST let date = new Date(); let pstDate = new Date(date.toLocaleString("en-US", {timeZone: "America/Los_Angeles"})); // If it's before 8pm PST, hide the checkout buttons and replace them with a message if (pstDate.getHours() < 20) { console.log("It is before 8pm lets hide the checkout") // Classes that contain 'sc-buy-box-inner-box', or 'checkoutNowBuyNow' let buttonClasses = ["sc-buy-box-inner-box", "checkoutNowBuyNow"]; buttonClasses.forEach(function(cls) { var buttons = document.querySelectorAll(`.${cls}`); for (var i = 0; i < buttons.length; i++) { buttons[i].style.display = "none"; // Create a new element for the message var messageElement = document.createElement("div"); messageElement.textContent = "It's before 8pm PST. Checkout is unavailable at this time for improvement of your own habits."; // Add the message element to the page in place of the button buttons[i].parentNode.insertBefore(messageElement, buttons[i]); } }); }})();