Tag Archives: Chrome upgrade 91 extension error

[Solved] Chrome upgrade 91 extension error: Tabs cannot be edited right now (user may be dragging a tab)

This article mainly introduces how to use the extension to report an error after the Chrome browser is upgraded to 91, and the error: Unchecked runtime.lastError: Tabs cannot be edited right now (user may be dragging a tab), and related sample code.

problem causes:

After the recent Chrome 91 update, when you try to use chrome.tabs API, extensions given: “Unchecked runtime.lastError: Tabs cannot be edit right (user may be drag a tab)”.

Solution:

chrome.tabs.onActivated.addListener(function(activeInfo) {getActivatedTab();});
function getActivatedTab() {
    chrome.tabs.query({'active': true, 'lastFocusedWindow': true}, function (tabs) {
        try{
            if(tabs[0]!=undefined){
            
                console.log(tabs[0].url);   
            }
        }
        catch(err){
            setTimeout(function() {
            getActivatedTab();
            }, 100 );
        }
    })
}