TODO: 重构inject.js 利用tabs.executeScript 回调通信. 实现对内容的判断与获取.
This commit is contained in:
@@ -8,11 +8,15 @@ function GetTask(sender) {
|
||||
response.json().then(function (task) {
|
||||
if(task.code == 200) {
|
||||
task_manager[sender.tab.id] = task;
|
||||
var execCode = `window.location.href = "${task.data.url}";`
|
||||
if(task.data.content_condition) {
|
||||
execCode += `PassContentCondition = ${task.data.content_condition};`
|
||||
execCode = `PassContentCondition = ${task.data.content_condition};`
|
||||
}
|
||||
chrome.tabs.executeScript(sender.tab.id, {runAt: "document_end", code: execCode})
|
||||
chrome.tabs.executeScript(sender.tab.id, {runAt: "document_end", code: `window.location.href = "${task.data.url}";`}, function (result) {
|
||||
if(execCode) {
|
||||
console.log(execCode);
|
||||
chrome.tabs.executeScript(sender.tab.id, {code: execCode});
|
||||
}
|
||||
})
|
||||
Tell(sender, InjectMsgType.FETCH);
|
||||
} else {
|
||||
Tell(sender, InjectMsgType.NOTASK);
|
||||
|
||||
Reference in New Issue
Block a user