Chrome扩展程序中的“更新"选项卡,然后等待直到它打开以打开另一个下载链接.如何等待直到在选项卡中打开url? [英] Update Tab in Chrome Extension And Wait Till It opened to open another download link. How to wait till url is opened in the tab?

查看:40
本文介绍了Chrome扩展程序中的“更新"选项卡,然后等待直到它打开以打开另一个下载链接.如何等待直到在选项卡中打开url?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想一个接一个地打开100个链接,等到每个链接都打开,以便我可以从中下载数据.如何等待直到在选项卡中打开URL?

I want to open 100 links one by one and wait till each one is opened so that i can download data from it. How to wait till URL is opened in the tab?

    function downloadreport()
    { 
        chrome.tabs.getSelected(null,function(tab)
        {
            var reportlink=tab.url;
            looplink=tab.url.slice(0,tab.url.length-1);
            var indexcode=reportlink.indexOf('code')
            reportlink=reportlink.slice(0,indexcode+4)+"/getReport.php";
            var i;
            for (i=0;i<100;i++)
            {
                chrome.tabs.update(tab.id,{url: looplink+i});
                /*

                How To Wait Here Till Tab Is Opened


                */
               chrome.tabs.update(tab.id,{url: reportlink});
            }
        });
    }
    document.addEventListener('DOMContentLoaded', function () {
    document.getElementById('start').addEventListener('click',downloadreport);
    }); 

推荐答案

使用 WebExtension polyfill 查看全文

相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆