您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
在 Web of Science 自動點擊所有「显示更多 / Show more」等展開按鈕
// ==UserScript== // @name Web of Science 自動展開「显示更多」(robust) // @namespace https://114514.1919.com/ // @version 1.0 // @description 在 Web of Science 自動點擊所有「显示更多 / Show more」等展開按鈕 // @author // @match https://*.webofscience.com/* // @grant GM_addStyle // @license MIT // @run-at document-idle // 確保主要 DOM 已安靜 // ==/UserScript== (() => { "use strict"; /** 關鍵字正則,不分大小寫 */ const KW = /显示更多|Show more/i; /** 取得當前畫面中「可點擊且文字符合」的元素 */ function getTargets() { return Array.from(document.querySelectorAll("button, a, [role='button'], div, span")) .filter(el => KW.test(el.textContent.trim())) .map(el => el.closest("button, a, [role='button']") || el); } /** 逐一點擊,並避免重複 */ function clickAll() { getTargets().forEach(el => { if (!el.dataset.__wosClicked) { el.dataset.__wosClicked = "1"; el.click(); } }); } /* -------------------- 主程式 -------------------- */ /** 第一次:延遲 1 秒,等 Ajax 首波內容進來 */ setTimeout(clickAll, 1000); /** 其後:監聽動態載入 */ const obs = new MutationObserver(clickAll); obs.observe(document.body, { childList: true, subtree: true }); /** 快捷鍵 Ctrl+Shift+M 手動再掃瞄一次 */ window.addEventListener("keydown", e => { if (e.ctrlKey && e.shiftKey && e.code === "KeyM") clickAll(); }); })();