您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
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;
- }
- })();