message identities optimize
This commit is contained in:
@ -1,19 +1,14 @@
|
||||
chrome.runtime.onMessage.addListener(
|
||||
function (request, sender, sendResponse) {
|
||||
// console.log(request);
|
||||
if (request.from == "doExtractRequest") {
|
||||
// console.log(request);
|
||||
if (request.from == "DataExtracter:Extract") {
|
||||
let data = extractData(request.itemsSelector, request.fieldSelectors);
|
||||
// console.log(data);
|
||||
if (sendResponse) sendResponse(data);
|
||||
} else if (request.from == "doExtractGotoUrl") {
|
||||
// console.log(request);
|
||||
} else if (request.from == "DataExtracter:GotoUrl") {
|
||||
window.location.replace(request.url);
|
||||
} else if (request.from == "doExtractReportIn") {
|
||||
// console.log("doExtractReportIn");
|
||||
} else if (request.from == "DataExtracter:ReportIn") {
|
||||
if (sendResponse) sendResponse(request.from);
|
||||
} else if (request.from == "doExtractQueryUrl") {
|
||||
// console.log("doExtractReportIn");
|
||||
} else if (request.from == "DataExtracter:QueryUrl") {
|
||||
if (sendResponse) sendResponse(window.location.href);
|
||||
}
|
||||
}
|
||||
@ -29,6 +24,7 @@ function extractData(itemsSelector, fieldSelectors) {
|
||||
|
||||
function extract(...args) {
|
||||
let sig = `Invalid call args.
|
||||
|
||||
function extract(itemsSelector:string, fieldSelectors:string[])
|
||||
function extract(itemsSelector:string, fieldSelectors:string[], url:string, from:number, to:number, interval:number)
|
||||
function extract(itemsSelector:string, fieldSelectors:string, url:string, pages:number[])`;
|
||||
@ -41,7 +37,7 @@ function extract(itemsSelector:string, fieldSelectors:string, url:string, pages:
|
||||
return;
|
||||
}
|
||||
let message = {
|
||||
from: "doExtractRequest",
|
||||
from: "DataExtracter:Extract",
|
||||
args: args
|
||||
}
|
||||
chrome.runtime.sendMessage(message, r => {
|
||||
|
||||
Reference in New Issue
Block a user