Skip to content

Instantly share code, notes, and snippets.

@Saber2pr
Last active September 20, 2021 07:30
Show Gist options
  • Save Saber2pr/a0578aa6ae4b4ac97cc0264f159a2565 to your computer and use it in GitHub Desktop.
Save Saber2pr/a0578aa6ae4b4ac97cc0264f159a2565 to your computer and use it in GitHub Desktop.
github
// ==UserScript==
// @name Github
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author You
// @match https://github.com/*
// @icon https://www.google.com/s2/favicons?domain=github.com
// @grant none
// ==/UserScript==
;(function () {
const diffbar = document.querySelector('.diffbar-item')
if (!diffbar) return
// Collapse
const input = document.createElement('input')
input.type = 'checkbox'
const id = setTimeout(() => {})
input.id = id
const label = document.createElement('label')
label.htmlFor = id
label.style.marginLeft = '8px'
label.textContent = 'Collapse All'
input.checked = location.search === '?file-filters%5B%5D='
input.style.marginLeft = '16px'
input.style.cursor = 'pointer'
input.oninput = e =>
e.target.checked
? (location.search = 'file-filters%5B%5D=')
: (location.search = '')
// Review
const review = document.createElement('button')
review.textContent = 'Review All'
review.style.marginLeft = '8px'
review.onclick = () =>
Array.from(document.querySelectorAll('.js-toggle-user-reviewed-file-form'))
.filter(f => !f.querySelector('.js-reviewed-file'))
.map(f => f.querySelector('label'))
.forEach(l => l.click())
diffbar.after(input, label, review)
})()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment