Allow YouTube access only during specified hours
当前为
// ==UserScript==
// @name Access Control For Maintaning Mindfulness
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Allow YouTube access only during specified hours
// @author KQ yang
// @match *://*.youtube.com/*
// @match *://*.reddit.com/*
// @match *://*.zhihu.com/*
// @grant none
// @license MIT
// ==/UserScript==
// Configuration variables
const CONFIG = {
startHour: 12, // Access start time (24-hour format)
endHour: 14, // Access end time (24-hour format)
messageStyle: "background-color: white; margin-top: 20vh; margin-left: 100px; margin-right: 100px; font-size:64px",
blockMessage: `
<h1 style="background-color: white;margin-top: 20vh;margin-left: 100px;margin-right: 100px;font-size:64px">
Dear Me!<br>
You preserved this page 👍<br><br>
👏 Congratulations! You successfully maintained mindfulness! Well done!👏<br><br>
This is restricted time.<br>
Welcome back between 12:00 and 14:00.
</h1>`
};
(function() {
'use strict';
// Get current time
const now = new Date();
const hours = now.getHours();
const minutes = now.getMinutes();
// Check if current time is within allowed range
if (hours < CONFIG.startHour || (hours >= CONFIG.endHour && minutes > 0)) {
// If outside allowed time range, replace page content with warning message
document.body.innerHTML = CONFIG.blockMessage;
}
})();