diff --git a/bitbucket-show-approvers.user.js b/bitbucket-show-approvers.user.js
index 1ebc5e7..93ed12e 100644
--- a/bitbucket-show-approvers.user.js
+++ b/bitbucket-show-approvers.user.js
@@ -26,6 +26,8 @@
let settings = {};
let alreadyProcessedParticipants = {};
+ let inhibitLoading = false;
+
const API_BASE = "https://bitbucket.org/api/2.0/";
@@ -33,6 +35,7 @@
const COMMIT_TABLE_HEADLINE_SELECTOR = 'section[data-qa="commit-list-styles"] h2';
const COMMIT_TABLE_SELECTOR = 'section[data-qa="commit-list-styles"] table';
+ const LOAD_MORE_COMMITS_SELECTOR = 'button > span:contains("Load more commits")';
const SVG_CHECKMARK_GREEN = '';
const SVG_CHECKMARK_GREY = '';
@@ -200,6 +203,44 @@
headline.append(button);
}
+ function addLoadAllCommitsButton() {
+ let headline = $(COMMIT_TABLE_HEADLINE_SELECTOR).parent().parent().parent();
+ let button = $('');
+ button.click(
+ function (ev) {
+ inhibitLoading = false;
+ loadMoreCommits();
+ ev.stopPropagation();
+ });
+ headline.append(button);
+ }
+
+ function addStopLoadingCommitsButton() {
+ let headline = $(COMMIT_TABLE_HEADLINE_SELECTOR).parent().parent().parent();
+ let button = $('');
+ button.click(
+ function (ev) {
+ inhibitLoading = true;
+ ev.stopPropagation();
+ });
+ headline.append(button);
+ }
+
+ function loadMoreCommits(){
+ if (inhibitLoading === true) {
+ debugOutput("Loading inhibited");
+ return;
+ }
+ let span = $(LOAD_MORE_COMMITS_SELECTOR);
+ if (span.length === 0) {
+ debugOutput("No more commits to load");
+ return;
+ }
+ span.parent().click();
+ debugOutput("Clicked the load more button");
+ setTimeout(loadMoreCommits, settings.loadMoreDelay);
+ }
+
function refreshApprovers() {
debugOutput("Started to load / refresh approvers")
loadCommitHashes().then(hashList => {
@@ -219,7 +260,8 @@
bb_appPassword: '',
activationDelay: 5000,
removeEmptyTds: true,
- debugOutput: false
+ debugOutput: false,
+ loadMoreDelay: 1000,
}
for (let key in DEFAULT_SETTINGS) {
let value = GM_getValue(key, '!unset!');
@@ -236,6 +278,8 @@
identifyPrData();
registerMutationObserver();
addRefreshButton();
+ addLoadAllCommitsButton();
+ addStopLoadingCommitsButton();
refreshApprovers();
}