连续番茄时钟和长休息

  1. 去支持Tempermonkey的浏览器的Add-ons安装
  2. 代码
  3. https://pomodoro.pomodorotechnique.com/ 打开后刷新一次
// ==UserScript==
// @name         Automated Pomodoro with Long Break
// @namespace    http://tampermonkey.net/
// @version      1.4
// @description  Automated Pomodoro cycles with long breaks after user-defined intervals (e.g., every 4 pomodoros with 15 or 50 minutes break options)
// @author       Syl
// @match        https://pomodoro.pomodorotechnique.com/*
// @grant        none
// ==/UserScript==(function () {'use strict';let isRunning = false;let timeoutHandles = [];function findButtonByText(text) {const buttons = Array.from(document.querySelectorAll('button'));return buttons.find(button => button.textContent.trim() === text);}function simulateUserClick(element) {if (!element) return console.error("Element not found.");const mouseDownEvent = new MouseEvent('mousedown', { bubbles: true, cancelable: true, view: window });const clickEvent = new MouseEvent('click', { bubbles: true, cancelable: true, view: window });element.dispatchEvent(mouseDownEvent);element.dispatchEvent(clickEvent);}function waitForButton(text, callback) {const interval = setInterval(() => {if (!isRunning) {clearInterval(interval);return;}const button = findButtonByText(text);if (button) {clearInterval(interval);callback(button);}}, 500);}function startPomodoroCycles(cycles, longBreakInterval, longBreakTime) {let currentCycle = 0;function runCycle() {if (!isRunning) return;if (currentCycle >= cycles) {console.log("All Pomodoro cycles completed!");endPomodoroProcess();return;}console.log(`Starting pomodoro cycle ${currentCycle + 1}`);waitForButton("Wind Up", (windUpButton) => {console.log("Clicking Wind Up button...");simulateUserClick(windUpButton);const workTimeout = setTimeout(() => {if (!isRunning) return;console.log(`Work session for cycle ${currentCycle + 1} completed.`);if (longBreakInterval > 0 && (currentCycle + 1) % longBreakInterval === 0) {console.log(`Long break required after cycle ${currentCycle + 1}.`);waitForPageState("Take a break").then(() => {const longBreakText = longBreakTime === 15 ? "15" : "30";waitForButton(longBreakText, (longBreakButton) => {simulateUserClick(longBreakButton);const longBreakTimeout = setTimeout(() => {if (!isRunning) return;currentCycle++;runCycle();}, longBreakTime * 60 * 1000);timeoutHandles.push(longBreakTimeout);});});} else {currentCycle++;runCycle();}}, 30 * 1000 * 60);timeoutHandles.push(workTimeout);});}runCycle();}function endPomodoroProcess() {console.log("Pomodoro process ended.");isRunning = false;}function stopPomodoro() {console.log("Stopping Pomodoro...");isRunning = false;timeoutHandles.forEach(handle => clearTimeout(handle));timeoutHandles = [];}function waitForPageState(targetText, timeout = 30000) {return new Promise((resolve, reject) => {const interval = 500;let elapsedTime = 0;const checkState = setInterval(() => {elapsedTime += interval;if (elapsedTime > timeout) {clearInterval(checkState);console.error(`Timeout: Page did not reach the expected state with text "${targetText}".`);resolve(null);return;}const targetElement = Array.from(document.querySelectorAll('button, div, span')).find(el => el.textContent.trim() === targetText);if (targetElement) {clearInterval(checkState);resolve(targetElement);}}, interval);});}const inputContainer = document.createElement('div');inputContainer.style.position = 'fixed';inputContainer.style.top = '100px';inputContainer.style.right = '25px';inputContainer.style.backgroundColor = 'white';inputContainer.style.border = '2px solid grey';inputContainer.style.borderRadius = '10px'; // 添加圆角样式inputContainer.style.padding = '10px';inputContainer.style.zIndex = '1000';inputContainer.style.display = 'flex';inputContainer.style.flexDirection = 'column';inputContainer.style.gap = '10px';const cyclesRow = document.createElement('div');cyclesRow.style.display = 'flex';cyclesRow.style.alignItems = 'center';cyclesRow.style.justifyContent = 'space-between';const inputLabel1 = document.createElement('label');inputLabel1.textContent = 'Number of cycles: ';const inputBox1 = document.createElement('input');inputBox1.type = 'number';inputBox1.min = '1';inputBox1.value = '4';inputBox1.style.width = '60px';cyclesRow.appendChild(inputLabel1);cyclesRow.appendChild(inputBox1);const everyRow = document.createElement('div');everyRow.style.display = 'flex';everyRow.style.alignItems = 'center';everyRow.style.justifyContent = 'space-between';const inputLabel2 = document.createElement('label');inputLabel2.textContent = 'Long break after every: ';const inputBox2 = document.createElement('input');inputBox2.type = 'number';inputBox2.min = '0';inputBox2.value = '0';inputBox2.style.width = '60px';everyRow.appendChild(inputLabel2);everyRow.appendChild(inputBox2);const durationRow = document.createElement('div');durationRow.style.display = 'flex';durationRow.style.alignItems = 'center';durationRow.style.justifyContent = 'space-between';const inputLabel3 = document.createElement('label');inputLabel3.textContent = 'Long break duration: ';const selectBox = document.createElement('select');selectBox.style.width = '80px';const option15 = document.createElement('option');option15.value = '15';option15.textContent = '15 min';const option30 = document.createElement('option');option30.value = '30';option30.textContent = '30 min';selectBox.appendChild(option15);selectBox.appendChild(option30);durationRow.appendChild(inputLabel3);durationRow.appendChild(selectBox);const buttonRow = document.createElement('div');buttonRow.style.display = 'flex';buttonRow.style.justifyContent = 'space-between';const startButton = document.createElement('button');startButton.textContent = 'Start';const endButton = document.createElement('button');endButton.textContent = 'End';buttonRow.appendChild(startButton);buttonRow.appendChild(endButton);inputContainer.appendChild(cyclesRow);inputContainer.appendChild(everyRow);inputContainer.appendChild(durationRow);inputContainer.appendChild(buttonRow);document.body.appendChild(inputContainer);startButton.addEventListener('click', () => {const cycles = parseInt(inputBox1.value, 10);const longBreakInterval = parseInt(inputBox2.value, 10);const longBreakTime = parseInt(selectBox.value, 10);if (!isNaN(cycles) && !isNaN(longBreakInterval) && !isNaN(longBreakTime) && cycles > 0) {isRunning = true;startPomodoroCycles(cycles, longBreakInterval, longBreakTime);} else {alert('Please enter valid numbers for cycles and long break settings.');}});endButton.addEventListener('click', () => {stopPomodoro();alert("Pomodoro cycle stopped.");});
})();

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.hqwc.cn/news/870143.html

如若内容造成侵权/违法违规/事实不符,请联系编程知识网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

Kernel Memory: 强大的AI驱动记忆系统

Kernel Memory简介 Kernel Memory(简称KM)是由微软开发的一个强大的多模态AI服务,专门用于高效索引和处理大规模数据集。它支持检索增强生成(RAG)、合成记忆、提示工程和自定义语义记忆处理等先进功能,为构建智能应用提供了强大的基础设施。 KM可以作为Web服务、Docker容器、C…

亚矩阵云手机:服务于未来新型电商矩阵的助力者

亚矩阵云手机是基于端云一体虚拟化技术 通过云网、安全、AI等数字化能力,弹性适配用户个性化需求,释放手机本身硬件资源,随需加载海量云上应用的手机形态 简单来说,云手机=云服务器+Android OS,用户可以远程实时控制云手机,实现安卓APP的云端运行;也可以基于云手机的基础算力,高…

0.LED基础控制

典中典之发光二极管,我从小学到大长脚是正级,断脚是负极 里面大块的是负级,小块的是正极 电阻标注:若标注102 -> 代表着为1K电阻(10^2) 若标注473 -> 代表着为47K电阻(47 * 10^3) 以此类推 其他器件标注也为类似模式RP7 RP9模块为限流电阻 此单片机使用TTL规范(高…

ITIL 4的4个维度

ITIL 4 于 2019 年推出,其中包含 ITIL 的一些新方面,例如服务价值体系和四个维度(后者是本文的主题)。ITIL 的大部分价值和可信度在于 缺乏原创性:ITIL 中的想法和建议基于常识、经过验证的有效性和悠久的使用历史。这四个维度是经过充分验证和广泛使用的概念的完美示例 阐…

小红书已被TikTok“难民”攻占!谁能接住这泼天富贵?

谁都不会想到,美国即将对Tiktok发出的禁令会让故事发生这样的转向,小红书竟成最后“赢家”。 小红书首页的“国际范” 一夜之间,小红书的首页被大量英文帖子“攻占”。中国网友纷纷表示:“一觉醒来,我成外国人了?”。这些新用户自称“TikTok难民”,并迅速在小红书上开设…

elasticsearch之DSL查询结果处理

搜索的结果可以按照用户指定的方式去处理或展示。排序 分页 搜索关键词高亮排序 elasticsearch默认是根据相关度算分(_score)来排序,但是也支持自定义方式对搜索结果排序。可以排序字段类型有:keyword类型、数值类型、地理坐标类型、日期类型等。 普通字段排序 keyword、数…

倍增求lca

非常重要的东西 我甚至模拟赛都不打了来打笔记 很简单啊,朴素lca是这样,两个节点,先令深度相等,然后一个一个往上跳直到跳到相同的位置则那个点为两点的lca 但是令深度相等与往上跳的过程都要一个一个慢慢跳所以时间复杂度拉满了 那么我们能以什么方式优化呢 我们可以发现,…

可视化管理:并行开发的必备工具

随着软件开发复杂度的提升,如何在并行开发模式中有效管理资源与进度成为团队面临的重要挑战。而看板工具以其对瓶颈的直观展示与管理能力,成为解决这一问题的关键手段。一、并行开发中的典型瓶颈问题 并行开发是一种高效但复杂的模式,其主要瓶颈包括: 1. 资源分配不均:各模…

C# NAudio 获取控制系统音量

https://github.com/naudio/NAudio NAudio 是一个开源的 .NET 音频库,由 Mark Heath 开发,开源地址:https://github.com/naudio/NAudio 支持多种音频操作,可实现多种API播放与录制、多种不同音频格式、音频格式转换(重采样、位深、声道等)、音频编码、多通道播放、音频效…

DBeaver随笔(1)——如何生成改表sql语句

用习惯了Navicat,非常喜欢改完表之后点击SQL预览直接查看改表sql的功能一图看懂,只需要新增或修改字段后点击保存就弹出改表sql了。

初识ES ---倒排索引

正向索引: mysql 倒排索引: elasticsearch采用倒排索引:文档(document):每条数据就是一个文档。 词条(term): 文档按照语义分成的词语(中文按照中文语义分)。词条不能重复。 eg: 会对用户输入的关键字数据进行分词 华为手机-》分词: 华为 手机 可以看出: 正向索引:…

构造刷题记录

[AGC001D] Arrays and Palindrome 首先观察发现奇数的个数看起来很重要,然后手玩一会发现最多只能有两个奇数,然后再分讨构造就可以了。[AT_hitachi2020_c] ThREE 观察到 \(3\mid a\times b\) 要求 \(a,b\) 中至少一个 3 的倍数。 发现如果两个点的距离为 3 的话他们的深度的…