From 7e0c8f0129bbfac98b2b043ee71f003660f95db4 Mon Sep 17 00:00:00 2001 From: Einzieg <94288565+Einzieg@users.noreply.github.com> Date: Mon, 29 Dec 2025 11:51:36 +0800 Subject: [PATCH 1/5] Update user script for Linuxdo helper --- linuxdo-helper.user.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/linuxdo-helper.user.js b/linuxdo-helper.user.js index 0dcac75..4e85ffc 100644 --- a/linuxdo-helper.user.js +++ b/linuxdo-helper.user.js @@ -39,7 +39,7 @@ headerIcons: '.d-header-icons', headerDropdown: 'ul.header-dropdown-toggle', header: 'header.d-header', - commentList: 'html.desktop-view.not-mobile-device.text-size-normal.no-touch.discourse-no-touch', + commentList: 'html.desktop-view.not-mobile-device.text-size-normal.touch.discourse-touch', rawLinks: '.raw-link' }; @@ -576,3 +576,4 @@ window.addEventListener('load', main); } })(); + From 530f8544d20616340f925d2ea4d0a3df60e428ec Mon Sep 17 00:00:00 2001 From: Einzieg <94288565+Einzieg@users.noreply.github.com> Date: Sun, 18 Jan 2026 08:46:00 +0800 Subject: [PATCH 2/5] Refactor Linuxdo helper script for improved functionality --- linuxdo-helper.user.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/linuxdo-helper.user.js b/linuxdo-helper.user.js index 4e85ffc..cc54a42 100644 --- a/linuxdo-helper.user.js +++ b/linuxdo-helper.user.js @@ -39,7 +39,7 @@ headerIcons: '.d-header-icons', headerDropdown: 'ul.header-dropdown-toggle', header: 'header.d-header', - commentList: 'html.desktop-view.not-mobile-device.text-size-normal.touch.discourse-touch', + commentList: 'html.desktop-view.not-mobile-device.text-size-normal.np-touch.discourse-no-touch', rawLinks: '.raw-link' }; @@ -577,3 +577,4 @@ } })(); + From 15e78fabe9d7659fff50c69030a89d8c4b62f514 Mon Sep 17 00:00:00 2001 From: Einzieg <94288565+Einzieg@users.noreply.github.com> Date: Sun, 18 Jan 2026 08:46:56 +0800 Subject: [PATCH 3/5] Refactor user script for Linuxdo helper --- linuxdo-helper.user.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/linuxdo-helper.user.js b/linuxdo-helper.user.js index cc54a42..6724ed0 100644 --- a/linuxdo-helper.user.js +++ b/linuxdo-helper.user.js @@ -39,7 +39,7 @@ headerIcons: '.d-header-icons', headerDropdown: 'ul.header-dropdown-toggle', header: 'header.d-header', - commentList: 'html.desktop-view.not-mobile-device.text-size-normal.np-touch.discourse-no-touch', + commentList: 'html.desktop-view.not-mobile-device.text-size-normal.no-touch.discourse-no-touch', rawLinks: '.raw-link' }; @@ -578,3 +578,4 @@ })(); + From c758bdd668bc0f3337dd29a061bd225e47a917fd Mon Sep 17 00:00:00 2001 From: Einzieg <94288565+Einzieg@users.noreply.github.com> Date: Sun, 18 Jan 2026 08:46:56 +0800 Subject: [PATCH 4/5] Refactor user script for Linuxdo helper --- linuxdo-helper.user.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/linuxdo-helper.user.js b/linuxdo-helper.user.js index cc54a42..6724ed0 100644 --- a/linuxdo-helper.user.js +++ b/linuxdo-helper.user.js @@ -39,7 +39,7 @@ headerIcons: '.d-header-icons', headerDropdown: 'ul.header-dropdown-toggle', header: 'header.d-header', - commentList: 'html.desktop-view.not-mobile-device.text-size-normal.np-touch.discourse-no-touch', + commentList: 'html.desktop-view.not-mobile-device.text-size-normal.no-touch.discourse-no-touch', rawLinks: '.raw-link' }; @@ -578,3 +578,4 @@ })(); + From 5b330679c6dbb1839df1fadbbf5ad2db7aa2110a Mon Sep 17 00:00:00 2001 From: Einzieg <1936343575wang@gmail.com> Date: Mon, 19 Jan 2026 04:16:26 +0800 Subject: [PATCH 5/5] =?UTF-8?q?fix:=20commentList=20=E9=80=89=E6=8B=A9?= =?UTF-8?q?=E5=99=A8=E5=85=BC=E5=AE=B9=20touch=20class?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- linuxdo-helper.user.js | 107 +++++++++++++++++++++++------------------ 1 file changed, 61 insertions(+), 46 deletions(-) diff --git a/linuxdo-helper.user.js b/linuxdo-helper.user.js index 6724ed0..c34ee2e 100644 --- a/linuxdo-helper.user.js +++ b/linuxdo-helper.user.js @@ -1,12 +1,12 @@ -// ==UserScript== -// @name Linuxdo活跃 -// @namespace http://tampermonkey.net/ -// @version 2.0.0 -// @description Linuxdo小助手(可控制开关) -// @author Cressida -// @match https://linux.do/* -// @grant GM_setValue -// @grant GM_getValue +// ==UserScript== +// @name Linuxdo活跃 +// @namespace http://tampermonkey.net/ +// @version 2.0.1 +// @description Linuxdo小助手(可控制开关) +// @author Cressida +// @match https://linux.do/* +// @grant GM_setValue +// @grant GM_getValue // @run-at document-idle // ==/UserScript== @@ -31,17 +31,17 @@ default: 1.0 }; - /** 元素选择器配置 */ - const SELECTORS = { - chatButton: 'li.chat-header-icon', - chatLink: 'a[href="/chat"]', - headerButtons: '.header-buttons', - headerIcons: '.d-header-icons', - headerDropdown: 'ul.header-dropdown-toggle', - header: 'header.d-header', - commentList: 'html.desktop-view.not-mobile-device.text-size-normal.no-touch.discourse-no-touch', - rawLinks: '.raw-link' - }; + /** 元素选择器配置 */ + const SELECTORS = { + chatButton: 'li.chat-header-icon', + chatLink: 'a[href="/chat"]', + headerButtons: '.header-buttons', + headerIcons: '.d-header-icons', + headerDropdown: 'ul.header-dropdown-toggle', + header: 'header.d-header', + commentList: 'html.desktop-view.not-mobile-device', + rawLinks: '.raw-link' + }; /** 存储键名 */ const STORAGE_KEYS = { @@ -375,14 +375,14 @@ * @param {string} selector - CSS选择器 * @returns {Promise} 找到的元素 */ - function waitForElement(selector) { - return new Promise((resolve, reject) => { - // 先尝试直接查找 - const element = document.querySelector(selector); - if (element) { - resolve(element); - return; - } + function waitForElement(selector) { + return new Promise((resolve, reject) => { + // 先尝试直接查找 + const element = document.querySelector(selector); + if (element) { + resolve(element); + return; + } // 使用MutationObserver监听DOM变化 const observer = new MutationObserver(() => { @@ -403,15 +403,23 @@ observer.disconnect(); console.log("【错误】未找到元素:", selector); reject(new Error('未找到:' + selector)); - }, getConfig().waitForElement); - }); - } - - /** - * 获取页面中的原始链接列表 - * @returns {Array} 链接对象数组,包含index、href、text - */ - function getRawLinks() { + }, getConfig().waitForElement); + }); + } + + /** + * 获取页面滚动容器(兼容不同浏览器/页面滚动实现) + * @returns {HTMLElement|null} 滚动容器元素 + */ + function getScrollContainer() { + return document.scrollingElement || document.documentElement || document.body; + } + + /** + * 获取页面中的原始链接列表 + * @returns {Array} 链接对象数组,包含index、href、text + */ + function getRawLinks() { const linkElements = document.querySelectorAll(SELECTORS.rawLinks); return Array.from(linkElements) .map((element, index) => ({ @@ -538,15 +546,22 @@ /** * 启动自动滚动功能 */ - async function startAutoScroll() { - try { - const commentElement = await waitForElement(SELECTORS.commentList); - console.log('找到评论列表元素:', commentElement); - scrollComment(commentElement); - } catch (error) { - console.error('启动自动滚动失败:', error); - } - } + async function startAutoScroll() { + try { + // 等待进入桌面端视图(避免移动端/未初始化完成时误触发) + await waitForElement(SELECTORS.commentList); + + const scrollContainer = getScrollContainer(); + if (!scrollContainer) { + throw new Error('未找到滚动容器元素'); + } + + console.log('找到滚动容器元素:', scrollContainer); + scrollComment(scrollContainer); + } catch (error) { + console.error('启动自动滚动失败:', error); + } + } // ==================== 主程序入口 ====================