水一贴, 用claude搓的, 附截图, 为方便各位佬复制贴上代码
右上角加了个摸鱼切换按钮
// ==UserScript==
// @name Linux.do 摸鱼模式切换
// @namespace http://tampermonkey.net/
// @version 0.1
// @description 在 Linux.do 摸鱼模式切换按钮
// @author hexsean
// @match https://linux.do/*
// @grant none
// ==/UserScript==
(function() {
'use strict';
const SVG_ICONS = {
fish: '<path d="M327.1 96c-89.97 0-168.54 54.77-212.27 101.63L27.5 131.58c-12.13-9.18-30.24.6-27.14 14.66L24.54 256 .35 365.77c-3.1 14.06 15.01 23.83 27.14 14.66l87.33-66.05C158.55 361.23 237.13 416 327.1 416 464.56 416 576 288 576 256S464.56 96 327.1 96zm87.43 184c-13.25 0-24-10.75-24-24 0-13.26 10.75-24 24-24 13.26 0 24 10.74 24 24 0 13.25-10.75 24-24 24z"/>',
eye: '<path d="M572.52 241.4C518.29 135.59 410.93 64 288 64S57.68 135.64 3.48 241.41a32.35 32.35 0 0 0 0 29.19C57.71 376.41 165.07 448 288 448s230.32-71.64 284.52-177.41a32.35 32.35 0 0 0 0-29.19zM288 400a144 144 0 1 1 144-144 143.93 143.93 0 0 1-144 144zm0-240a95.31 95.31 0 0 0-25.31 3.79 47.85 47.85 0 0 1-66.9 66.9A95.78 95.78 0 1 0 288 160z"/>'
};
function addMoyuButton() {
const headerIcons = document.querySelector('ul.icons.d-header-icons');
if (!headerIcons) {
setTimeout(addMoyuButton, 100);
return;
}
const li = document.createElement('li');
li.className = 'header-dropdown-toggle';
const button = document.createElement('button');
button.className = 'btn no-text btn-icon icon btn-flat';
button.type = 'button';
const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
svg.classList.add('fa', 'd-icon', 'svg-icon', 'svg-string');
svg.setAttribute('viewBox', '0 0 576 512');
svg.style.width = '1.25em';
svg.style.height = '1.25em';
function updateButtonState() {
const isMoyuMode = localStorage.getItem('linuxdo_moyu_mode') === 'true';
button.title = isMoyuMode ? '退出摸鱼模式' : '进入摸鱼模式';
svg.innerHTML = isMoyuMode ? SVG_ICONS.eye : SVG_ICONS.fish;
}
button.addEventListener('click', function() {
const currentMode = localStorage.getItem('linuxdo_moyu_mode') === 'true';
if (currentMode) {
localStorage.removeItem('linuxdo_moyu_mode');
} else {
localStorage.setItem('linuxdo_moyu_mode', true);
}
location.reload();
});
updateButtonState();
button.appendChild(svg);
li.appendChild(button);
const searchLi = headerIcons.querySelector('.search-dropdown');
headerIcons.insertBefore(li, searchLi);
}
addMoyuButton();
})();