Multiple chrome.webNavigation.onHistoryStateUpdated not working
<p>The goal of this is to have my extension wait for a change in the History, depending on what it says, do a certain action.</p>

<p>Here is what I have so far</p>

<p><strong>popup.js</strong></p>

<pre><code>chrome.tabs.update({ url: "https://www.WEBSITE.com/messages" });

chrome.webNavigation.onHistoryStateUpdated.addListener(function(details) {
    if (details.url.indexOf("messages") &gt;= 0) {
        chrome.extension.getBackgroundPage().chrome.tabs.executeScript(null, {
            file: 'getInboxStats.js'
        });;
    } else {//if (details.url.indexOf("match") &gt;= 0) {
        chrome.extension.getBackgroundPage().chrome.tabs.executeScript(null, {
            file: 'startBotting.js'
        });;
    }
});

chrome.runtime.onMessage.addListener(function(message) {
    if (message.type == "emptyAmount") {
        emptyAmount = message.content;
        if (!(percentageOfMessages &gt; 0)) {
            percentageOfMessages = 50;
        }
        amountToSend = Math.floor(emptyAmount * (percentageOfMessages / 100));
        alert(amountToSend);
        chrome.tabs.update({ url: "https://www.WEBSITE.com/match" });
    }

});
</code></pre>

<p><strong>getInboxStats.js</strong></p>

<pre><code>var currentAmount = document.getElementsByClassName('count')[1].innerHTML;
var maxAmount = document.getElementsByClassName('total')[0].innerHTML;
var emptyAmount = maxAmount - currentAmount;

chrome.runtime.sendMessage({ content: emptyAmount, type: "emptyAmount" });
</code></pre>

<p><strong>startBotting.js</strong></p>

<pre><code>alert("TEST");
</code></pre>

<p>The issue I have is that the <code>getInboxStats.js</code> starts, but it's like the <code>onHistoryStateUpdated</code> only seems to work once because the file <code>startBotting.js</code> never displays an alert that says 'TEST'</p>