-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgh-autoload-large-diffs.user.js
More file actions
48 lines (41 loc) · 1.68 KB
/
Copy pathgh-autoload-large-diffs.user.js
File metadata and controls
48 lines (41 loc) · 1.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
// ==UserScript==
// @name GitHub Autoload Large Diffs
// @namespace http://github.com/softwareengineerprogrammer
// @version 0.2
// @description I want to see large diffs
// @author softwareengineerprogrammer
// @match https://github.com/*/*/pull/*/files*
// @grant none
// @updateURL https://softwareengineerprogrammer.github.io/userscripts/gh-autoload-large-diffs.user.js
// @downloadURL https://softwareengineerprogrammer.github.io/userscripts/gh-autoload-large-diffs.user.js
// ==/UserScript==
(function() {
'use strict';
const max_tries = 5
let autoloadLargeDiffs = function(tries){
let diffBtns = document.querySelectorAll('button.load-diff-button')
if(!diffBtns.length){
if(tries < max_tries){
setTimeout(function(){autoloadLargeDiffs(tries+1)}, 2000);
}else{
console.debug('did not find any large diff buttons')
}
return
}
diffBtns.forEach(it => {
let doLoad = true;
try{
let viewedElt = it.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.querySelector('form.js-toggle-user-reviewed-file-form input[value="viewed"]')
let isMarkedViewed = viewedElt.checked || false;
console.log(it, viewedElt, isMarkedViewed)
doLoad = !isMarkedViewed
}catch(e){
console.warning('Failed determine whether large diff file has been marked as viewed',e)
}
if(doLoad) {
it.click()
}
});
}
setTimeout(function(){autoloadLargeDiffs(0)}, 2000);
})();