From 4c4fdd23ce85ecab92f5c315620e91daec4361fe Mon Sep 17 00:00:00 2001 From: Glorfindel Date: Thu, 21 Dec 2017 23:37:25 +0100 Subject: [PATCH] bugfixes --- why-no-bounty/why-no-bounty.user.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/why-no-bounty/why-no-bounty.user.js b/why-no-bounty/why-no-bounty.user.js index bd63a06..3e8608f 100644 --- a/why-no-bounty/why-no-bounty.user.js +++ b/why-no-bounty/why-no-bounty.user.js @@ -17,6 +17,12 @@ (function () { "use strict"; + // Is this a Q&A page? + var questionLink = $("#question-header a").attr("href"); + if (typeof(questionLink) === "undefined") { + return; + } + // If there's a 'start a bounty' link, we have nothing to do. if ($("a.bounty-link.bounty").length !== 0) { return; @@ -75,7 +81,6 @@ } // Find previous bounties on this question by current user - var questionLink = $("#question-header a").attr("href"); var questionID = /^\/questions\/(\d+)\//.exec(questionLink)[1]; $.get("https://" + window.location.host + "/users/current?tab=bounties&sort=offered", function (data) { var summaries = $(data).find("#question-summary-" + questionID); @@ -93,5 +98,14 @@ addInformation("minimum bounty (" + minimumBounty + ") higher than reputation (" + reputation + ")"); return; } + + // Find currently active bounties by current user + $.get("https://" + window.location.host + "/users/current?tab=bounties&sort=active", function (data) { + var activeCount = parseInt($(data).find("#user-tab-bounties h1 span.count").text(), 10); + if (activeCount >= 3) { + addInformation("you have " + activeCount + " currently active bounties"); + return; + } + }); }); })();