Skip to content

Instantly share code, notes, and snippets.

@gregory-seidman
Last active October 26, 2023 15:03
Show Gist options
  • Save gregory-seidman/d3d0cae4ea69e8c324b944f4bb165dfa to your computer and use it in GitHub Desktop.
Save gregory-seidman/d3d0cae4ea69e8c324b944f4bb165dfa to your computer and use it in GitHub Desktop.
GitHub Mark Files Viewed Function
// ==UserScript==
// @name GitHub viewed files utility
// @namespace https://gist.github.com/gregory-seidman/dd8b7a93f4603ef3e484c82d45809a95
// @version 1.0.0
// @description Add function markViewed(CSS attribute pattern on value) to mark files viewed by file pattern
// @downloadURL https://gist.github.com/gregory-seidman/d3d0cae4ea69e8c324b944f4bb165dfa/raw/github_markViewed_func.user.js
// @updateURL https://gist.github.com/gregory-seidman/d3d0cae4ea69e8c324b944f4bb165dfa/raw/github_markViewed_func.user.js
// @author Gregory Seidman
// @match https://github.com/*/pull/*/files*
// @icon https://www.google.com/s2/favicons?sz=64&domain=github.com
// @grant unsafeWindow
// ==/UserScript==
(function(win) {
'use strict';
// example pattern for HTML files: 'value$=".html"'
win.markViewed = function(pattern) {
Array.prototype.map.call(win.document.querySelectorAll(`form input[type="hidden"][${pattern}]`),
e => e.parentNode.querySelector('label input[type="checkbox"]'))
.filter(e => e && !e.checked)
.forEach(e => e.click())
}
})(unsafeWindow);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment