您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
A userscript that toggles all expanders when one expander is shift-clicked
当前为
- // ==UserScript==
- // @name GitHub Toggle Expanders
- // @version 1.0.2
- // @description A userscript that toggles all expanders when one expander is shift-clicked
- // @license https://creativecommons.org/licenses/by-sa/4.0/
- // @namespace https://github.com/Mottie
- // @include https://github.com/*
- // @run-at document-idle
- // @author Rob Garrison
- // ==/UserScript==
- /* jshint esnext:true, unused:true */
- (() => {
- "use strict";
- function toggle(el) {
- const state = closest(el, ".commits-list-item, .js-details-container")
- .classList.contains("open"),
- // target buttons inside commits_bucket - fixes #8
- selector = `.commits-listing .commits-list-item,
- #commits_bucket .js-details-container`;
- Array.from(document.querySelectorAll(selector)).forEach(el => {
- el.classList[state ? "add" : "remove"]("open");
- });
- }
- function closest(el, selector) {
- while (el && el.nodeName !== "BODY" && !el.matches(selector)) {
- el = el.parentNode;
- }
- return el && el.matches(selector) ? el : [];
- }
- document.body.addEventListener("click", event => {
- const target = event.target;
- if (
- target && event.getModifierState("Shift") &&
- target.matches(".ellipsis-expander")
- ) {
- // give GitHub time to add the class
- setTimeout(() => {
- toggle(target);
- }, 100);
- }
- });
- })();