🎉 欢迎访问GreasyFork.Org 镜像站!本镜像站由公众号【爱吃馍】搭建,用于分享脚本。联系邮箱📮

Greasy fork 爱吃馍镜像

Greasy Fork is available in English.

📂 缓存分发状态(共享加速已生效)
🕒 页面同步时间:2026/02/01 12:20:23
🔄 下次更新时间:2026/02/01 13:20:23
手动刷新缓存

SoundCloud Cooldown (Tooltip Version)

Long-Press-Hold play/pause 2s for 2h countdown. Music stops when timer ends.

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

🚀 安装遇到问题?关注公众号获取帮助

公众号二维码

扫码关注【爱吃馍】

回复【脚本】获取最新教程和防失联地址

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

🚀 安装遇到问题?关注公众号获取帮助

公众号二维码

扫码关注【爱吃馍】

回复【脚本】获取最新教程和防失联地址

// ==UserScript==
// @name         SoundCloud Cooldown (Tooltip Version)
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  Long-Press-Hold play/pause 2s for 2h countdown. Music stops when timer ends.
// @author       moony
// @icon         https://soundcloud.com/favicon.ico
// @match        *://soundcloud.com/*
// @grant        none
// @run-at       document-end
// @license      MIT
// ==/UserScript==

(function() { 'use strict';
    const HOLD_MS = 2000, COUNTDOWN_S = 10 * 6 * 120; // ((10s) * 6 = 1m) * 120 = 2 hour
    let playBtn, holdTimer, ticker, blockClick;

    const setupButton = button => {
        if (!button || button._timer) return; // prevent double attachment
        playBtn = button, playBtn._timer = 1;
        const clearHold = () => clearTimeout(holdTimer);
        const startHold = () => {
            if (ticker) return; blockClick = false, clearHold(); // blockClick prevents unwanted click after hold
            holdTimer = setTimeout(() => { let secs = COUNTDOWN_S;
                blockClick = true, playBtn._saved = [playBtn.title || '', playBtn.getAttribute('aria-label') || '']; // store original tooltip
                ticker = setInterval(() => {
                    ['title','aria-label'].forEach(attr => playBtn.setAttribute(attr, `${secs/60|0}m ${secs%60}s`)); // update countdown display
                    if (!--secs) clearInterval(ticker), ticker = null, playBtn.setAttribute('title', playBtn._saved[0]),
                        playBtn.setAttribute('aria-label', playBtn._saved[1]),
                        playBtn.classList.contains('playing') && playBtn.click(); // only click if playing (prevents double-toggle)
                }, 1000);
            }, HOLD_MS);
        };

        playBtn.addEventListener('mousedown', startHold);
        playBtn.addEventListener('mouseup', clearHold);
        playBtn.addEventListener('mouseleave', clearHold); // ↓ capture phase (true) intercepts click before SoundCloud handlers
        playBtn.addEventListener('click', evt => blockClick && (evt.preventDefault(), evt.stopPropagation(), blockClick = false), true);
    }; // MutationObserver needed - SoundCloud recreates DOM on navigation
    new MutationObserver(() => { const button = document.querySelector('.playControl.sc-button-play'); button && button !== playBtn && setupButton(button);
                               }).observe(document.body, {childList: true, subtree: true});

    setupButton(document.querySelector('.playControl.sc-button-play'));
})();