n/programu/Str · 2024-10-12
注册 登录
n/program · 2024-10-12 · 407 次浏览
u/Str荣誉会员王者

【赤石科技】入戏太深

写了个油猴脚本,如果你在一个网页内最近30分钟中的每5分钟都有操作网页,那么就一键 The End
这个是的初心是提示不要过度沉迷网络世界

```js
// ==UserScript==
// @name The End
// @namespace 入戏太深
// @version 2024-10-11
// @description 劇終
// @Author You
// @match http:///
// @match https:///
// ==/UserScript==

// 创建一个 <style> 元素
const style = document.createElement('style');
style.type = 'text/css';

// 添加 CSS 规则
style.appendChild(document.createTextNode(`
.THEEND {
position: fixed;
top: 0px;
left: 0px;
width: 100%;
height: 100%;
background-color: rgba(124, 103, 10, 0.5);
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
z-index: 9999;
font-family: SimSun, serif;
color: white;
text-align: center;
}
.TheEnd_rxts {
white-space: pre;
font-size: 24px;
font-weight: bold;
position: fixed;
top: 0;
margin: 40px 0;
padding: 20px 0;
width: 100%;
background: #00000050;
}

@media (min-width: 600px) {
    .TheEnd_rxts {
        width: 300px !important;
    }
}

`));

document.head.appendChild(style);

let userActivity = Array(6).fill(false);
let activityTimeout;
let theend = false;
const activityDuration = 5 * 60 * 1000;
const totalDuration = 30 * 60 * 1000;

function markUserActive() {
const currentSegment = Math.floor((Date.now() - activityStartTime) / activityDuration);

if (currentSegment &lt; userActivity.length) {
    userActivity[currentSegment] = true;
}

checkActivityStatus();

}

function checkActivityStatus() {
if (userActivity.every(segment => segment)) {
TheEnd();
resetActivity();
}
}

function resetActivity() {
userActivity.fill(false);
activityStartTime = Date.now();
}

let activityStartTime = Date.now();
resetActivity();

document.addEventListener('mousemove', markUserActive);
document.addEventListener('keydown', markUserActive);

setInterval(checkActivityStatus, activityDuration);

window.onload = function() {
setInterval(resetActivity, totalDuration);
};

function TheEnd() {
if (theend) return;
theend = true;

const overlay = document.createElement('div');
overlay.classList.add("THEEND");

const mainText = document.createElement('div');
mainText.textContent = '劇終';
mainText.style.fontSize = '48px';
mainText.style.fontWeight = "bold";
overlay.appendChild(mainText);

const subText = document.createElement('div');
subText.textContent = 'T h e  E n d';
subText.style.whiteSpace = "pre";
subText.style.fontSize = '24px';
subText.style.fontWeight = "bold";
overlay.appendChild(subText);

const RXTS = document.createElement('div');
RXTS.textContent = '入戏太深';
RXTS.classList.add("TheEnd_rxts");
overlay.appendChild(RXTS);


const audio = document.createElement('audio');
audio.src = 'https://camo.hach.chat/?proxyUrl=https://files.catbox.moe/em9lsq.mp3&amp;mine=audio/mpeg';
audio.autoplay = true;
audio.loop = true;
audio.addEventListener('canplaythrough', () =&gt; {
    setTimeout(()=&gt;{
        document.body.appendChild(overlay);

        window.addEventListener('click', removeOverlay);
        window.addEventListener('keydown', removeOverlay);
        audio.play();
    }, 2222);
});

document.body.appendChild(audio);

const removeOverlay = () =&gt; {
    document.body.removeChild(overlay);
    document.body.removeChild(audio);
    window.removeEventListener('click', removeOverlay);
    window.removeEventListener('keydown', removeOverlay);

    theend = false;
};

}
```
[upl-image-preview url=https://6waed6lo6phn6.pages.dev/uploads/default/2024-10-12/1728662656-423157-image.png]

0
6
登录后参与讨论。
u/udc2b6nr 广告
QuicksilverVPN

快银 VPN,一键连接全球节点,线路稳定、延迟低。支持 Windows、macOS 等多平台,TUN 全局模式覆盖全部应用流量。无需复杂配置,下载即用。

umami.dnsl.top 了解更多

6 条回复

排序
  1. James 💯 传奇 MANAGER 2024-10-12

    NL需要防沉迷了???

    0
  2. Str 荣誉会员 王者 楼主 2024-10-12

    @"James"#p110570 debug的时候调的 1分钟内5次检测(

    0
  3. yucho 荣誉会员 钻石 2024-10-12

    浏览器防沉迷系统:ac01:

    0
  4. nod302 黄金 2024-10-12

    自建防沉迷

    0
  5. shape-isaac 白银 2024-10-12

    论坛佬友健康守护系统

    0
  6. Str 荣誉会员 王者 楼主 2024-10-13

    @"shape-isaac"#p110722 雀氏,到时间就可以先休息一下

    0