您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Adds a button to expand all files in a GitHub pull request or commit view.
当前为
// ==UserScript== // @name GitHub expand files button // @namespace https://puac.de/ // @version 0.1.0 // @description Adds a button to expand all files in a GitHub pull request or commit view. // @author Hans Puac // @match https://github.com/*/pull/*/files // @match https://github.com/*/commit/* // @run-at document-end // ==/UserScript== (function () { 'use strict'; var expanding = false; var expandButton = document.createElement('button'); var btnClicked = function () { if (!expanding) { expanding = true; expandAllFiles(); } }; var expandAllFiles = function () { expandButton.innerText = 'Expanding files ...'; expandButton.classList.add('btn-outline', 'bg-gray-light', 'text-gray-light'); expandButton.setAttribute('disabled', true); var expand = function () { var anchors = document.querySelectorAll('.diff-expander.js-expand'); var len = anchors.length; if (len < 1) { expandButton.innerText = 'All Files expanded'; return; } anchors.forEach(function (item) { item.click(); }); setTimeout(function () { expand(); }, 1000); }; expand(); }; expandButton.innerText = 'Expand all files'; expandButton.classList.add('btn', 'btn-sm'); expandButton.style.float = 'left'; expandButton.style.marginRight = '20px'; expandButton.addEventListener('click', btnClicked, false); var btnWrapper = document.querySelector('.pr-review-tools'); if (btnWrapper === null) { btnWrapper = document.querySelector('.js-details-container .BtnGroup'); } btnWrapper.prepend(expandButton); })();