I have created a setInterval function that scrolls onlimited times and two buttons start and end, I want when I click on start button the condition starts and when clicked on end the condition stops. Is there any way to do that? Here is my code:
pophtml:-
 <button class="input-btn start-button"><i class="fa fa-play" aria-hidden="true"></i> Start</button>
    <button class="input-btn scrap-button"><i class="fa fa-share-square" aria-hidden="true"></i> Export to csv</button>
     <button class="input-btn end-button"><i class="fa fa-stop" aria-hidden="true"></i> End</button>
popup js:-
   document.querySelector(".end-button").addEventListener("click", function () {
   chrome.tabs.query({active: true, currentWindow: true}, function(tabs) {
        chrome.tabs.sendMessage(tabs[0].id, {action: "end"});
    });
});
my content.js:-
 chrome.runtime.onMessage.addListener(
function(request, sender, sendResponse) {
    var interval = '';
   if(request.action == 'start'){
    interval = setInterval(function(){
        $(document).scrollTop($(document).height());
              },1000);
        }
       else if(request.action == 'scrap')
       {
        alert('work in process');
       }
       else if(request.action == 'end')
       {
        clearInterval(interval);
       }
       else
       {
        alert('Wrong button placed')
       }
});
i tried it by using that previous method present but i am not getting which id to pass...
 
    