Chrome inject script inconsistency issue

前端 未结 1 1481
天命终不由人
天命终不由人 2021-01-25 03:43

Below function I did was to redirect user to a login page, and then inject a js to login the user. The code below worked well but not consistent, I hardly can debug it because t

相关标签:
1条回答
  • 2021-01-25 04:04

    By default scripts are injected at document_idle which doesn't work consistently with jQuery, probably because it's big or uses some asynchronous initialization.

    Solution: explicitly specify that the injected scripts should run immediately.

    chrome.tabs.executeScript({file: "jquery.js", runAt: "document_start"}, function(result) {
    });
    
    0 讨论(0)
提交回复
热议问题