您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
switch between last two discord channels using caps
// ==UserScript== // @name Discord channel switcher // @namespace http://tampermonkey.net/ // @version 1.0 // @description switch between last two discord channels using caps // @author You // @match https://discord.com/channels/* // @grant none // ==/UserScript== (function () { 'use strict'; let channelHistory = []; function getCurrentChannelPath() { return window.location.pathname; } function navigateToChannel(path) { if (window.location.pathname !== path) { window.history.pushState({}, '', path); window.dispatchEvent(new PopStateEvent('popstate')); } } function updateChannelHistory() { const currentPath = getCurrentChannelPath(); if (channelHistory.length === 0 || channelHistory[channelHistory.length - 1] !== currentPath) { channelHistory.push(currentPath); if (channelHistory.length > 2) { channelHistory.shift(); } } } updateChannelHistory(); window.addEventListener('popstate', updateChannelHistory); window.addEventListener('pushstate', updateChannelHistory); window.addEventListener('replacestate', updateChannelHistory); const originalPushState = history.pushState; history.pushState = function () { originalPushState.apply(this, arguments); window.dispatchEvent(new Event('pushstate')); }; const originalReplaceState = history.replaceState; history.replaceState = function () { originalReplaceState.apply(this, arguments); window.dispatchEvent(new Event('replacestate')); }; window.addEventListener('keydown', function (e) { if (e.code === 'CapsLock') { e.preventDefault(); e.stopPropagation(); if (channelHistory.length === 2) { const currentPath = getCurrentChannelPath(); const targetPath = channelHistory.find(path => path !== currentPath); if (targetPath) { navigateToChannel(targetPath); } } } }, true); })();