Skip to content

Commit f2869b4

Browse files
gh-autoload-large-diffs.user.js v0.2
1 parent 0f16e7f commit f2869b4

File tree

1 file changed

+19
-4
lines changed

1 file changed

+19
-4
lines changed

userscripts/gh-autoload-large-diffs.user.js

+19-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// ==UserScript==
22
// @name GitHub Autoload Large Diffs
33
// @namespace http://github.com/softwareengineerprogrammer
4-
// @version 0.1
4+
// @version 0.2
55
// @description I want to see large diffs
66
// @author softwareengineerprogrammer
77
// @match https://github.com/*/*/pull/*/files*
@@ -13,8 +13,22 @@
1313
(function() {
1414
'use strict';
1515

16-
setTimeout(function(){
17-
document.querySelectorAll('button.load-diff-button').forEach(it => {
16+
const max_tries = 5
17+
18+
let autoloadLargeDiffs = function(tries){
19+
let diffBtns = document.querySelectorAll('button.load-diff-button')
20+
21+
if(!diffBtns.length){
22+
if(tries < max_tries){
23+
setTimeout(function(){autoloadLargeDiffs(tries+1)}, 2000);
24+
}else{
25+
console.debug('did not find any large diff buttons')
26+
}
27+
28+
return
29+
}
30+
31+
diffBtns.forEach(it => {
1832
let doLoad = true;
1933
try{
2034
let viewedElt = it.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.querySelector('form.js-toggle-user-reviewed-file-form input[value="viewed"]')
@@ -29,5 +43,6 @@
2943
it.click()
3044
}
3145
});
32-
}, 2000);
46+
}
47+
setTimeout(function(){autoloadLargeDiffs(0)}, 2000);
3348
})();

0 commit comments

Comments
 (0)