Last active
October 26, 2023 15:03
-
-
Save gregory-seidman/d3d0cae4ea69e8c324b944f4bb165dfa to your computer and use it in GitHub Desktop.
GitHub Mark Files Viewed Function
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==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